Class ProteinDatabase
- java.lang.Object
-
- edu.rit.compbio.seq.ProteinDatabase
-
public class ProteinDatabase extends java.lang.ObjectClass ProteinDatabase encapsulates a protein sequence database stored in a file. Class ProteinDatabase is used to read ProteinSequence objects from the database.A protein sequence database file consists of one or more protein sequences stored in FASTA format. A FASTA format protein sequence consists of one description line and one or more sequence lines. The description line consists of an initial '>' character followed by zero or more characters (the protein's description). A sequence line consists of one or more characters 'A' through 'Z', 'a' through 'z', '*', or '-'. For further information, see class ProteinSequence.
Along with the protein sequence database file, there is a protein sequence index file. The index file tells where each protein is located in the database file. Class ProteinDatabase's constructor requires both the database file and the index file to be supplied as arguments.
Class ProteinDatabase includes a main program that reads a protein sequence database file and creates the requisite protein sequence index file. If the n argument is specified, the program creates an index file for just the first n sequences in the database. If the n argument is omitted, the program creates an index file for all the sequences in the database.
Usage: java edu.rit.compbio.seq.ProteinDatabase databasefile indexfile [ n ]
databasefile = Input protein sequence database file
indexfile = Output protein sequence index file
n = Number of sequences in the index (default: all)
-
-
Constructor Summary
Constructors Constructor and Description ProteinDatabase(java.io.File theDatabaseFile, java.io.File theIndexFile)Construct a new protein sequence database.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Close this protein sequence database.longgetDatabaseLength()Get the sum of the lengths of the protein sequences in this protein sequence database.longgetProteinCount()Get the number of protein sequences in this protein sequence database.ProteinSequencegetProteinSequence(long i)Get the protein sequence at the given index in this protein sequence database.static voidmain(java.lang.String[] args)Main program that reads a protein sequence database file and creates the requisite protein sequence index file.
-
-
-
Constructor Detail
-
ProteinDatabase
public ProteinDatabase(java.io.File theDatabaseFile, java.io.File theIndexFile) throws java.io.IOExceptionConstruct a new protein sequence database.- Parameters:
theDatabaseFile- Protein sequence database file.theIndexFile- Protein sequence index file.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theDatabaseFile is null. Thrown if theIndexFile is null.java.io.IOException- Thrown if an I/O error occurred.
-
-
Method Detail
-
getDatabaseLength
public long getDatabaseLength()
Get the sum of the lengths of the protein sequences in this protein sequence database.- Returns:
- Total protein sequence length.
-
getProteinCount
public long getProteinCount()
Get the number of protein sequences in this protein sequence database.- Returns:
- Number of protein sequences, N.
-
getProteinSequence
public ProteinSequence getProteinSequence(long i) throws java.io.IOException
Get the protein sequence at the given index in this protein sequence database.- Parameters:
i- Index in the range 0 ≤ i ≤ N−1.- Returns:
- Protein sequence.
- Throws:
java.lang.IndexOutOfBoundsException- (unchecked exception) Thrown if i is out of bounds.java.io.IOException- Thrown if an I/O error occurred.
-
close
public void close() throws java.io.IOExceptionClose this protein sequence database.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionMain program that reads a protein sequence database file and creates the requisite protein sequence index file. If the n argument is specified, the program creates an index file for just the first n sequences in the database. If the n argument is omitted, the program creates an index file for all the sequences in the database.Usage: java edu.rit.compbio.seq.ProteinDatabase databasefile indexfile [ n ]
databasefile = Input protein sequence database file
indexfile = Output protein sequence index file
n = Number of sequences in the index (default: all)- Throws:
java.lang.Exception
-
-
DMelt 3.0 © DataMelt by jWork.ORG