compbio.metadata
Class Limit<T>
java.lang.Object
compbio.metadata.Limit<T>
- Type Parameters:
T
- the type of an executable for which this limit is defined.
public class Limit<T>
- extends Object
A value object containing a maximum number of sequences and a maximum average
sequence length for a preset. Also contains static method for determining the
number of sequence and their average length in the List
- Version:
- 1.0 January 2010
- Author:
- pvtroshin
- See Also:
LimitsManager
Constructor Summary |
Limit(int seqNumber,
int seqLength,
String preset)
Instantiate the limit |
Limit(int seqNumber,
int seqLength,
String preset,
boolean isDefault)
|
Limit
public Limit(int seqNumber,
int seqLength,
String preset)
- Instantiate the limit
- Parameters:
seqNumber
- the maximum number of sequences allowed for calculation.
RequiredseqLength
- the average length of the sequence, optionalpreset
- the name of preset if any, optional
- Throws:
IllegalArgumentException
- if the seqNumber is not supplied or the seqLength is negative
Limit
public Limit(int seqNumber,
int seqLength,
String preset,
boolean isDefault)
getPreset
public String getPreset()
getAvgSeqLength
public int getAvgSeqLength()
- Returns:
- the allowed average sequence length
getSeqNumber
public int getSeqNumber()
- Returns:
- the maximum number of sequences allowed
isDefault
public boolean isDefault()
- Returns:
- true is this is a default limit to be used, false otherwise
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
equals
public boolean equals(Object obj)
- Overrides:
equals
in class Object
toString
public String toString()
- Overrides:
toString
in class Object
isExceeded
public boolean isExceeded(List<FastaSequence> data)
- Checks if the number of sequences or their average length in the dataset
exceeds this limit.
- Parameters:
data
- the dataset to measure
- Returns:
- true if a limit is exceeded (what is the dataset is larger then
the limit), false otherwise. First check the number of sequences
in the dataset and if it exceeds the limit return true
irrespective of the average length. If the number of sequences in
the dataset is less than the limit and average length is defined,
then check whether the total number of letters (number of
sequence multiplied by the average sequence length) is greater
then the total number of letters in the dataset. Returns true if
the total number of letters in the dataset is greater than the
limit, false otherwise.
getAvgSequenceLength
public static int getAvgSequenceLength(List<FastaSequence> data)
- Calculates an average sequence length of the dataset
- Parameters:
data
-
- Returns:
- an average sequence length in the input dataset