Package com.compomics.util.protein
Class Protein
java.lang.Object
com.compomics.util.protein.Protein
public class Protein extends Object
This class implements the behaviour for a Protein instance.
A lot of functionality is borrowed from the AASequenceImpl class.
The internal representation corresponds most closely to a FASTA
entry.
- Author:
- Lennart Martens
- See Also:
AASequenceImpl
-
Field Summary
Fields Modifier and Type Field Description static int
CTERMTRUNC
The code for an C-terminal truncation.static int
NTERMTRUNC
The code for an N-terminal truncation. -
Constructor Summary
Constructors Constructor Description Protein()
Empty default constructorProtein(Header aHeader, AASequenceImpl aSequence)
This constructor allows the passing of a Header, as well as an AASequenceImpl for this Protein.Protein(Header aHeader, AASequenceImpl aSequence, boolean aTruncated, int aTruncationPosition)
This constructor allows the passing of a Header, as well as an AASequenceImpl for this Protein.Protein(AASequenceImpl aSequence)
This constructor requires an AASequenceImpl as argument.Protein(String aFASTAString)
This constructor allows for the construction of a Protein instance by passing a FASTA entry.Protein(String aFASTAString, boolean aTruncated, int aTruncationPosition)
This constructor allows for the construction of a Protein instance by passing a FASTA entry and boolean flag for truncation.Protein(String aHeader, String aSequence)
This constructor allows for the construction of a Protein instance through the passing of a Header String and a Sequence String.Protein(String aHeader, String aSequence, boolean aTruncated, int aTruncationPosition)
This constructor allows for the construction of a Protein instance through the passing of a Header String and a Sequence String. -
Method Summary
Modifier and Type Method Description boolean
equals(Object o)
This method will check equality between this object and another Protein instance.Protein
getCTermTruncatedProtein(int aSize)
This method truncates the sequence for this protein on the C-terminus to the requested size.Header
getHeader()
This method reports on the header for the current protein.long
getLength()
This method reports on the length of the sequence for the current protein.double
getMass()
This method returns the protein weight in Da.Protein
getNTermTruncatedProtein(int aSize)
This method truncates the sequence for this protein on the N-terminus to the requested size.AASequenceImpl
getSequence()
This method reports on the sequence for the current protein.int
getTruncationPosition()
This method reports on the position of the truncation.boolean
isTruncated()
This method reports on the 'truncatedness' of the protein.void
setHeader(Header aHeader)
Simple setter for the header.void
setSequence(AASequenceImpl aSequence)
Simple setter for the sequence.void
writeToFASTAFile(PrintWriter aOut)
This method can be used to append this protein to the FASTA DB flatfile the PrintWriter points to.
-
Field Details
-
NTERMTRUNC
public static final int NTERMTRUNCThe code for an N-terminal truncation. These variables can be compared to the result of the 'getTruncationPosition()' method, BUT ONLY when the 'isTruncated()' method returns true.- See Also:
- Constant Field Values
-
CTERMTRUNC
public static final int CTERMTRUNCThe code for an C-terminal truncation. These variables can be compared to the result of the 'getTruncationPosition()' method, BUT ONLY when the 'isTruncated()' method returns true.- See Also:
- Constant Field Values
-
-
Constructor Details
-
Protein
public Protein()Empty default constructor -
Protein
This constructor requires an AASequenceImpl as argument. This will be the sequence around which the protein will be built.- Parameters:
aSequence
- AASequenceImpl around which this protein will be built.
-
Protein
This constructor allows the passing of a Header, as well as an AASequenceImpl for this Protein.- Parameters:
aHeader
- Header with the header information for this Protein.aSequence
- AASequenceImpl with the sequence for this Protein.
-
Protein
public Protein(Header aHeader, AASequenceImpl aSequence, boolean aTruncated, int aTruncationPosition)This constructor allows the passing of a Header, as well as an AASequenceImpl for this Protein. It also allows for the specification of the 'truncatedness' of the Protein.- Parameters:
aHeader
- Header with the header information for this Protein.aSequence
- AASequenceImpl with the sequence for this Protein.aTruncated
- boolean that indicates whether this Protein has been truncated.aTruncationPosition
- int with the coded position for the truncation (N-Term or C-Term).
-
Protein
This constructor allows for the construction of a Protein instance by passing a FASTA entry.- Parameters:
aFASTAString
- String with the FASTA representation of the Protein.
-
Protein
This constructor allows for the construction of a Protein instance by passing a FASTA entry and boolean flag for truncation.- Parameters:
aFASTAString
- String with the FASTA representation of the Protein.aTruncated
- boolean that indicates whether this Protein has been truncated.aTruncationPosition
- int with the coded position for the truncation (N-Term or C-Term).
-
Protein
This constructor allows for the construction of a Protein instance through the passing of a Header String and a Sequence String. This is mainly useful to obtain a Protein instance without a Header.- Parameters:
aHeader
- String with the header (can be 'null').aSequence
- String with the sequence.
-
Protein
This constructor allows for the construction of a Protein instance through the passing of a Header String and a Sequence String. This is mainly useful to obtain a Protein instance without a Header.- Parameters:
aHeader
- String with the header (can be 'null').aSequence
- String with the sequence.aTruncated
- boolean that indicates whether this Protein has been truncated.aTruncationPosition
- int with the coded position for the truncation (N-Term or C-Term).
-
-
Method Details
-
getHeader
This method reports on the header for the current protein.- Returns:
- Header with the current header for this protein.
-
getSequence
This method reports on the sequence for the current protein.- Returns:
- AASequenceImpl with the current sequence for this protein.
-
getNTermTruncatedProtein
This method truncates the sequence for this protein on the N-terminus to the requested size.- Parameters:
aSize
- int with the size of the resulting N-terminal sequence- Returns:
- Protein with an N-terminal truncated sequence.
-
getCTermTruncatedProtein
This method truncates the sequence for this protein on the C-terminus to the requested size.- Parameters:
aSize
- int with the size of the resulting C-terminal sequence- Returns:
- Protein with an C-terminal truncated sequence.
-
getLength
public long getLength()This method reports on the length of the sequence for the current protein.- Returns:
- long with the length of the sequence for the current protein.
-
getMass
public double getMass()This method returns the protein weight in Da.- Returns:
- double with the mass of the Protein in Da.
-
setHeader
Simple setter for the header.- Parameters:
aHeader
- the Header to set for this protein.
-
setSequence
Simple setter for the sequence.- Parameters:
aSequence
- the AASequenceImpl with the sequence to set for this protein.
-
writeToFASTAFile
This method can be used to append this protein to the FASTA DB flatfile the PrintWriter points to.- Parameters:
aOut
- PrintWriter to write the file to.- Throws:
IOException
- when the writing failed.
-
isTruncated
public boolean isTruncated()This method reports on the 'truncatedness' of the protein.- Returns:
- boolean whether this protein is the result of a truncation.
-
getTruncationPosition
public int getTruncationPosition()This method reports on the position of the truncation. Note that the method can only be trusted when the 'isTruncated()' method returns 'true'.- Returns:
- int with the code for the position (either N-term or C-term). This return code can be evaluated against the constants defined on this class.
-
equals
This method will check equality between this object and another Protein instance.
-