public final class SequenceUtilities extends Object
SequenceDocument,
SequenceExtractionUtilities| Modifier and Type | Method and Description |
|---|---|
static DefaultAlignmentDocument |
alignmentFromJeblSequences(String name,
List<Sequence> jeblSequences)
Converts the given alignment of Jebl sequences into a DefaultAlignmentDocument
|
static CharSequence |
asDna(CharSequence nucleotideCharSequence)
Views an underlying (nucleotide) CharSequence as DNA by dynamically
translating 'U's to 'T's and 'u's to 't's
It is guaranteed that if charSequence instanceof SequenceCharSequence, the returned
value will also be instanceof SequenceCharSequence (but it may not support log-time modifications).
|
static Alignment |
asJeblAlignment(List<SequenceDocument> sequences)
Convert a list of (aligned) Geneious sequences to a jebl alignmnent
|
static Sequence |
asJeblSequence(AnnotatedPluginDocument referenceDocument,
SequenceDocument sequence)
|
static Sequence |
asJeblSequence(SequenceAlignmentDocument.ReferencedSequence referencedSequence,
SequenceDocument sequence)
Convert from a Geneious sequence to a jebl sequence.
|
static Sequence |
asJeblSequence(SequenceDocument sequence)
Convert from a Geneious sequence to a jebl sequence.
|
static List<Sequence> |
asJeblSequences(List<SequenceDocument> sequences)
Convert a set of Geneious sequences to jebl sequences.
|
static List<Sequence> |
asJeblSequences(SequenceDocument... sequences)
Convert a set of Geneious sequences to jebl sequences.
|
static CharSequence |
asRna(CharSequence nucleotideCharSequence)
Views an underlying (nucleotide) CharSequence as RNA by dynamically
translating 'T's to 'U's and 't's to 'u's
It is guaranteed that if charSequence instanceof SequenceCharSequence, the returned
value will also be instanceof SequenceCharSequence (but it may not support log-time modifications).
|
static CharSequence |
asTranslation(CharSequence nucleotideCharSequence,
GeneticCode geneticCode)
Deprecated.
|
static CharSequence |
asTranslation(CharSequence nucleotideCharSequence,
GeneticCode geneticCode,
boolean translateFirstCodonUsingFirstCodonTable)
Views an underlying (nucleotide) CharSequence as its translation.
|
static String |
containsInvalidResidues(CharSequence sequenceResidues,
SequenceDocument.Alphabet alphabet,
boolean allowGaps,
boolean fastIncompleteCheck)
Checks if a sequence contain invalid sequence residues.
|
static String |
containsInvalidResidues(CharSequence sequenceResidues,
SequenceType sequenceType,
boolean allowGaps,
boolean fastIncompleteCheck)
Checks if a sequence contain invalid sequence residues.
|
static String |
containsInvalidResidues(SequenceDocument sequenceDocument,
boolean allowGaps,
boolean fastIncompleteCheck)
Checks if a sequence contain invalid sequence residues.
|
static List<AnnotatedPluginDocument> |
createNewDocumentsByTransformingSequences(List<AnnotatedPluginDocument> sourceDocuments,
SequenceDocument.Transformer transformer,
ProgressListener progressListener,
String newSequenceOrDocumentNamePrefix)
Transforms the sequence(s) in each input document and returns a new document corresponding to each input document.
|
static SequenceDocument |
createSequenceCopy(SequenceDocument original)
Creates a copy of the original sequence if necessary.
|
static SequenceDocument |
createSequenceCopyAdjustedForGapInsertion(SequenceDocument sequenceDocument,
CharSequence gappedSequenceCharacters)
Creates a copy of the given sequence with annotations, sequence residues, and chromatogram values adjusted to account for gap insertion.
|
static DefaultSequenceDocument |
createSequenceCopyEditable(SequenceDocument original)
Creates a copy of the original sequence that is editable.
|
static DefaultSequenceDocument |
createSequenceDocument(SequenceType sequenceType,
String name,
String description,
CharSequence sequenceString,
Date creationDate)
Creates a
DefaultNucleotideSequence
or DefaultAminoAcidSequence
depending on sequenceType. |
static SequenceDocument |
generateConsensus(SequenceAlignmentDocument alignment,
ProgressListener progressListener)
Generates a consensus sequence for an alignment using default consensus settings.
|
static SequenceDocument |
generateConsensusSequence(SequenceAlignmentDocument alignment,
ProgressListener progressListener)
|
static SequenceDocument.Alphabet |
getAlphabet(SequenceDocument sequence)
Get the Alphabet of a sequence.
|
static SequenceDocument.Alphabet |
getAlphabet(SequenceType sequenceType)
Gets a Geneious alphabet type that is equivalent to a jebl library SequenceType.
|
static List<SequenceAnnotation> |
getAnnotationsOfType(List<SequenceAnnotation> annotations,
String type)
Get all annotations in list matching the given type
|
static List<SequenceAnnotation> |
getAnnotationsOfType(SequenceDocument document,
String type)
|
static List<SequenceAnnotation> |
getAnnotationsOfType(SequenceDocument document,
String type,
boolean returnAnnotationsInTracks)
Get all annotations in document matching the given type.
WARNING: this list may not include all SequenceAnnotations represented as annotations in the sequence viewer.
|
static String |
getBlastAlignmentText(SequenceAlignmentDocument alignment,
boolean geneiousFriendly)
Formats the given alignment in BLAST text format
|
static String |
getForwardRegexForSequence(CharSequence querySequence,
SequenceType sequenceType,
boolean interpretAmbiguitiesInQuery)
|
static String |
getForwardRegexForSequence(CharSequence querySequence,
SequenceType sequenceType,
boolean interpretAmbiguitiesInQuery,
boolean interpretAmbiguitiesInTarget)
|
static String |
getForwardRegexForSequence(CharSequence querySequence,
SequenceType sequenceType,
boolean interpretAmbiguitiesInQuery,
boolean interpretAmbiguitiesInTarget,
boolean allowExtraGapsInTarget)
Given a nucleotide or amino acid sequence, returns a regular
expression that matches forward occurrences of this sequence in a larger
sequence, i.e.
|
static Pattern |
getForwardRegexPatternForSequence(CharSequence sequence,
SequenceType sequenceType,
boolean interpretAmbiguitiesInQuery)
|
static Pattern |
getForwardRegexPatternForSequence(CharSequence querySequence,
SequenceType sequenceType,
boolean interpretAmbiguitiesInQuery,
boolean interpretAmbiguitiesInTarget)
Given a nucleotide or amino acid sequence string, returns a regular
expression pattern that matches forward occurrences of this search string in a larger
sequence string,
|
static int |
getLeadingGapsLength(CharSequence charSequence)
Returns the start index of the non-gap regions in the specified charSequence,
i.e.
|
static String |
getMaximalAmbiguitySymbol(SequenceType sequenceType)
get the code for the state in this sequence type which represents a base/residue that is completely unknown
|
static long |
getNumberOfSequences(AnnotatedPluginDocument document,
SequenceDocument.Alphabet alphabet)
Gets the total number of nucleotide or amino acid sequences contained in the given document which may be an individual sequence, sequence list, or alignment/contig.
|
static long |
getNumberOfSequences(List<AnnotatedPluginDocument> documents,
SequenceDocument.Alphabet alphabet)
Gets the total number of nucleotide or amino acid sequences contained in the given documents which may be individual sequences, sequence lists, or alignments/contigs.
|
static Iterable<SequenceAnnotation> |
getSequenceAndTrackAnnotations(SequenceDocument sequence)
A convenience method to get all annotations on the sequence and all annotations on all
SequenceTracks on this sequence. |
static List<SequenceAnnotation> |
getSequenceAnnotationsIncludingImmutableSequencesTrims(SequenceDocument sequence)
Gets all the annotations on the given sequence.
|
static List<? extends SequenceDocument> |
getSequences(AnnotatedPluginDocument[] documents,
SequenceDocument.Alphabet alphabet,
ProgressListener progressListener)
get all the sequences out of a set of AnnotatedPluginDocuments that may wrap SequenceDocuments, SequenceListDocuments or SequenceAlignmentDocuments.
|
static List<? extends SequenceDocument> |
getSequences(List<AnnotatedPluginDocument> documents,
SequenceDocument.Alphabet alphabet,
ProgressListener progressListener)
get all the sequences out of a set of AnnotatedPluginDocuments that may wrap SequenceDocuments, SequenceListDocuments or SequenceAlignmentDocuments.
|
static Collection<? extends SequenceDocument> |
getSequencesWithoutImmediateLoading(AnnotatedPluginDocument[] documents,
SequenceDocument.Alphabet alphabet)
Like
getSequences(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument.Alphabet, jebl.util.ProgressListener)
but doesn't require each plugin document to be in memory as long as this Collection is around. |
static List<SequenceType> |
getSequenceType(AnnotatedPluginDocument document)
Examines a document and determines what the (jebl) sequence type (or types) of the document is (or are), and returns it (or them).
Always returns a List<SequenceType> of size 0, 1 or 2. |
static SequenceType |
getSequenceType(SequenceDocument.Alphabet alphabet)
Gets a jebl library SequenceType that is equivalent to a Geneious alphabet.
|
static SequenceType |
getSequenceType(SequenceDocument sequence)
Get the (jebl) sequence type.
|
static int |
getTrailingGapsLength(CharSequence charSequence)
Get the number of trailing gap ('-') characters in the sequence.
|
static int |
getTrailingGapsStartIndex(CharSequence charSequence)
Returns the end index of the non-gap regions in the specified charSequence.
|
static CharSequence |
getValidSequence(SequenceDocument sequenceDocument,
boolean allowGaps)
Replace any invalid bases/residues in the given sequence document with ambiguity symbols.
|
static CharSequence |
getValidSequence(SequenceDocument sequenceDocument,
boolean allowGaps,
boolean replaceWithGaps)
Replace any invalid bases/residues in the given sequence document with ambiguity symbols or gaps.
|
static boolean |
isPredominantlyRna(CharSequence charSequence,
int maximumNonGapsToLookAt)
Checks whether a sequence is predominantly RNA (rather than DNA).
|
static boolean |
isRna(CharSequence charSequence)
Checks whether a sequence is RNA (rather than DNA) based on whether the sequence contains either a T/t or a U/u first.
|
static boolean |
isStateAssignableFrom(State stateA,
State stateB)
Same as stateA.getCanonicalStates().containsAll(stateB.getCanonicalStates())
except that for NucleotideStates and AminoAcidStates it caches the result.
|
static CharSequence |
removeGaps(CharSequence charSequence)
Constructs a sequence without gaps ('-') from a specified sequence that
potentially has gaps.
|
static CharSequence |
removeInvalidResidues(CharSequence sequence,
SequenceType sequenceType,
boolean allowGaps)
Get a sequence string identical to
sequence
except that any invalid residues are removed. |
static String |
replaceQuestionMarksWithMaximalAmbiguitySymbol(SequenceType sequenceType,
String sequence)
get a version of a sequence string with any question marks replaces with N (for nucleotide sequences) or X (for protein sequences)
|
static CharSequence |
reverseComplement(CharSequence charSequence)
Provides a dynamic reverse complement view onto a nucletoide CharSequence.
|
static void |
setOriginalResidueNumbering(EditableSequenceDocument document,
int startIndex,
boolean isReverse)
set the original residue numbering of a document
the residue index of a document will appear shifted
if the user has "show original residue numbers" selected in the sequence view
|
static String |
toHTMLFragment(SequenceDocument sequence,
String additionalContent)
Generate a HTML fragment that summarises a sequence, including the sequence string.
|
public static String getForwardRegexForSequence(CharSequence querySequence, SequenceType sequenceType, boolean interpretAmbiguitiesInQuery)
@Deprecated public static String getForwardRegexForSequence(CharSequence querySequence, SequenceType sequenceType, boolean interpretAmbiguitiesInQuery, boolean interpretAmbiguitiesInTarget)
getForwardRegexForSequence(CharSequence, jebl.evolution.sequences.SequenceType, boolean, boolean, boolean) insteadgetForwardRegexForSequence(...,true)public static String getForwardRegexForSequence(CharSequence querySequence, SequenceType sequenceType, boolean interpretAmbiguitiesInQuery, boolean interpretAmbiguitiesInTarget, boolean allowExtraGapsInTarget)
querySequence - The nucleotide or amino acid sequence to search for.sequenceType - The type of the sequenceinterpretAmbiguitiesInQuery - If true, then an ambiguous character
(e.g. R for nucleotides) in querySequence will match the
corresponding canonical states (A and G) in the target.interpretAmbiguitiesInTarget - If true, then an ambiguous character
(e.g. R for nucleotides) in the sequence being searched within will match the
corresponding canonical states (A and G) in the querySequence.allowExtraGapsInTarget - If true, then additional gaps will be allowed in the sequence
being search withinpublic static Pattern getForwardRegexPatternForSequence(CharSequence sequence, SequenceType sequenceType, boolean interpretAmbiguitiesInQuery)
public static Pattern getForwardRegexPatternForSequence(CharSequence querySequence, SequenceType sequenceType, boolean interpretAmbiguitiesInQuery, boolean interpretAmbiguitiesInTarget)
querySequence - The nucleotide or amino acid sequence to search for.sequenceType - The type of the sequenceinterpretAmbiguitiesInQuery - If true, then an ambiguous character
(e.g. R for nucleotides) in sequenceString will match the
corresponding canonical states (A and G) in the target.public static boolean isStateAssignableFrom(State stateA, State stateB)
stateA - A state (e.g. a NucleotideState or AminoAcidState)stateB - A state of the same type as stateBpublic static DefaultSequenceDocument createSequenceDocument(SequenceType sequenceType, String name, String description, CharSequence sequenceString, Date creationDate)
DefaultNucleotideSequence
or DefaultAminoAcidSequence
depending on sequenceType.
See the documentation of these classes' constructors for the semantics of the parameters.public static void setOriginalResidueNumbering(EditableSequenceDocument document, int startIndex, boolean isReverse)
document - document to set the residue numbering forstartIndex - start index for the residue numbering. The first original residue is residue 1.isReverse - true if the residue numbering should count down from startIndex, false if it should count up.public static String containsInvalidResidues(SequenceDocument sequenceDocument, boolean allowGaps, boolean fastIncompleteCheck)
sequenceDocument - the sequence to check for validity.allowGaps - true if the sequence is allowed to contain gapsfastIncompleteCheck - This parameter is ignored. It was added when Java 5 was widely used which is 10 times slower than Java 6. Checking enormous sequences is slow (a 2GB sequence takes about 20 seconds in Java 5, 2 seconds in Java 6). Set this parameter to true to check only the first and last 1,000,000 residues which catches almost all invalid cases and is much faster on enormous sequences.public static SequenceType getSequenceType(SequenceDocument.Alphabet alphabet)
alphabet - public static SequenceDocument.Alphabet getAlphabet(SequenceType sequenceType)
sequenceType - public static String containsInvalidResidues(CharSequence sequenceResidues, SequenceDocument.Alphabet alphabet, boolean allowGaps, boolean fastIncompleteCheck)
sequenceResidues - sequence residues to check for validity.alphabet - the alphabet of residues expected to be in sequenceResiduesallowGaps - true if the sequence is allowed to contain gapsfastIncompleteCheck - This parameter is ignored. It was added when Java 5 was widely used which is 10 times slower than Java 6. Checking enormous sequences is slow (a 2GB sequence takes about 20 seconds in Java 5, 2 seconds in Java 6). Set this parameter to true to check only the first and last 1,000,000 residues which catches almost all invalid cases and is much faster on enormous sequences.public static String containsInvalidResidues(CharSequence sequenceResidues, SequenceType sequenceType, boolean allowGaps, boolean fastIncompleteCheck)
sequenceResidues - sequence residues to check for validity.sequenceType - the type of residues expected to be in sequenceResiduesallowGaps - true if the sequence is allowed to contain gapsfastIncompleteCheck - This parameter is ignored. It was added when Java 5 was widely used which is 10 times slower than Java 6. Checking enormous sequences is slow (a 2GB sequence takes about 20 seconds in Java 5, 2 seconds in Java 6). Set this parameter to true to check only the first and last 1,000,000 residues which catches almost all invalid cases and is much faster on enormous sequences.public static CharSequence removeInvalidResidues(CharSequence sequence, SequenceType sequenceType, boolean allowGaps)
sequence
except that any invalid residues are removed. Gaps are only removed if allowGaps is false.
All valid characters remain unchanged (they maintain their original case and there are no U->T replacements for nucleotides.)sequence - a string of residues that may or may not be valid residuessequenceType - the type of residues in sequenceallowGaps - if this is true, then gaps are not removed.sequence
except that any invalid residues are removed. If there are no invalid residues, sequence is returned.OutOfMemoryError - if a sequence comtains invalid residues and a valid version of the sequence cannot fit in memorypublic static CharSequence getValidSequence(SequenceDocument sequenceDocument, boolean allowGaps)
sequenceDocument - sequence document to replace the invalid bases inallowGaps - whether gaps are allowed (if false they will be replaced with ambiguity symbols)public static CharSequence getValidSequence(SequenceDocument sequenceDocument, boolean allowGaps, boolean replaceWithGaps)
sequenceDocument - sequence document to replace the invalid bases inallowGaps - whether gaps are allowed (if false they will be replaced with ambiguity symbols)replaceWithGaps - whether invalid bases/residues should be replaced with gaps - should only be done if sequence is in an alignmentIllegalArgumentException - if allowGaps is false but replaceWithGaps is truepublic static CharSequence asRna(CharSequence nucleotideCharSequence)
nucleotideCharSequence - A nucleotide sequence which may already have some RNA residues; it is
not guaranteed that it is checked whether the sequence contains invalid residues. Must not be null.public static CharSequence asDna(CharSequence nucleotideCharSequence)
nucleotideCharSequence - A nucleotide sequence which may already have some DNA residues; it is
not guaranteed that it is checked whether the sequence contains invalid residues. Must not be null.@Deprecated public static CharSequence asTranslation(CharSequence nucleotideCharSequence, GeneticCode geneticCode)
asTranslation(CharSequence, jebl.evolution.sequences.GeneticCode, boolean) instead.public static CharSequence asTranslation(CharSequence nucleotideCharSequence, GeneticCode geneticCode, boolean translateFirstCodonUsingFirstCodonTable)
nucleotideCharSequence - A nucleotide sequence which may be dna, rna or a mixture. Must not be null and must be immutable. Must not contain gaps.geneticCode - the genetic code to use for the translation. Must not be null.translateFirstCodonUsingFirstCodonTable - each genetic code specifies a set of codons which get translated as M if they are the first codon even though they normally wouldn't translate as an M when occurring elsewhere a coding region. If this parameter is true the first codon will be translated using this alternative translation table for the genetic code.IllegalArgumentException - if nucleotideCharSequence contains gaps.NullPointerException - if nucleotideCharSequence or geneticCode is null.public static CharSequence reverseComplement(CharSequence charSequence)
Provides a dynamic reverse complement view onto a nucletoide CharSequence.
For performance, it is not guaranteed whether the charSequence will be checked
for invalid residues. If an invalid nucleotide CharSequence is passed in,
arbitrary nondeterministic behaviour may occur at any later time, such as
e.g. unchecked exceptions thrown from CharSequence.charAt(int).
It is guaranteed that if charSequence instanceof SequenceCharSequence, the returned value will also be instanceof SequenceCharSequence (but it may not support log-time modifications).
Attention: Unlike Utils.reverseComplement(String),
this method preserves case and doesn't remove gaps. To remove gaps and convert the sequence
to upper case, use removeGaps(CharSequence) and CharSequenceUtilities.asUpperCase(CharSequence).
charSequence - The charSequence for which to construct a reverse complement view.public static boolean isPredominantlyRna(CharSequence charSequence, int maximumNonGapsToLookAt)
Utils.isPredominantlyRNA(CharSequence, int), but more efficient on SequenceCharSequences.charSequence - A charSequence that may contain DNA or RNA characters.maximumNonGapsToLookAt - Maximum number of non-gap residues to look at before making a decision; Pass in Integer.MAX_VALUE to look at all residues#isRna(CharSequencepublic static boolean isRna(CharSequence charSequence)
charSequence - A charSequence that may contain DNA or RNA characters.isPredominantlyRna(CharSequence, int)public static CharSequence removeGaps(CharSequence charSequence)
charSequence - A nucleotide or amino acid sequence, potentially with gaps ('-')public static int getLeadingGapsLength(CharSequence charSequence)
charSequence - A CharSequence that may contain some leading gap characters '-'public static int getTrailingGapsLength(CharSequence charSequence)
charSequence - A CharSequence that may have trailing gap characters.public static int getTrailingGapsStartIndex(CharSequence charSequence)
charSequence - A CharSequence that may contain some leading gap characters '-'public static SequenceDocument.Alphabet getAlphabet(SequenceDocument sequence)
sequence - a SequenceDocument to get the alphabet for.public static SequenceType getSequenceType(SequenceDocument sequence)
sequence - a SequenceDocument to get the sequence type of.IllegalArgumentException - if sequence is not either a NucleotideSequenceDocument or a AminoAcidSequenceDocument.public static List<SequenceType> getSequenceType(AnnotatedPluginDocument document)
SequenceType.AMINO_ACID or SequenceType.NUCLEOTIDE or both, and that document
has no sequences at all, for example an empty SequenceListDocumentNucleotideSequenceDocument or a
SequenceAlignmentDocument.SequenceListDocument with sequences of both types.document - the document to determine the SequenceType ofIllegalArgumentException - if the given document type wasn't a valid type to determine the SequenceType of.public static String toHTMLFragment(SequenceDocument sequence, String additionalContent)
sequence - a SequenceDocumentadditionalContent - additional content to includepublic static Sequence asJeblSequence(SequenceDocument sequence)
sequence - a Geneious sequencepublic static List<Sequence> asJeblSequences(List<SequenceDocument> sequences)
sequences - Geneious sequencespublic static List<Sequence> asJeblSequences(SequenceDocument... sequences)
sequences - Geneious sequencespublic static Alignment asJeblAlignment(List<SequenceDocument> sequences)
sequences - aligned Geneious sequencespublic static SequenceDocument createSequenceCopy(SequenceDocument original)
ImmutableSequence)
then it is not copied and is just returned from this method.original - the original sequencecreateSequenceCopyEditable(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument)public static DefaultSequenceDocument createSequenceCopyEditable(SequenceDocument original)
original - the original sequencecreateSequenceCopy(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument)public static List<SequenceAnnotation> getSequenceAnnotationsIncludingImmutableSequencesTrims(SequenceDocument sequence)
ImmutableSequence with ImmutableSequence.getLeadingTrimLength()
or ImmutableSequence.getTrailingTrimLength()>0 then annotations are created to represent these trims.sequence - the sequence to get annotations frompublic static Sequence asJeblSequence(SequenceAlignmentDocument.ReferencedSequence referencedSequence, SequenceDocument sequence) throws DocumentOperationException
referencedSequence - original referenced sequence to copy additional fields from. May be null.sequence - a Geneious sequenceDocumentOperationException - when the referenced sequence cannot be loadedpublic static Sequence asJeblSequence(AnnotatedPluginDocument referenceDocument, SequenceDocument sequence)
referenceDocument - original AnnotatedPluginDocument to copy additional fields from. May be null.sequence - a Geneious sequencepublic static String replaceQuestionMarksWithMaximalAmbiguitySymbol(SequenceType sequenceType, String sequence)
sequenceType - sequence type of sequencesequence - sequence stringpublic static String getMaximalAmbiguitySymbol(SequenceType sequenceType)
sequenceType - public static List<SequenceAnnotation> getAnnotationsOfType(List<SequenceAnnotation> annotations, String type)
annotations - annotationstype - type of annotations to getpublic static List<SequenceAnnotation> getAnnotationsOfType(SequenceDocument document, String type)
getAnnotationsOfType(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, String, boolean) instead.document - document to get annotations formtype - type of annotations to getpublic static List<SequenceAnnotation> getAnnotationsOfType(SequenceDocument document, String type, boolean returnAnnotationsInTracks)
getSequenceAnnotationsIncludingImmutableSequencesTrims(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument).SequenceAnnotation.TYPE_EXTRACTED_REGION.document - document to get annotations formtype - type of annotations to getreturnAnnotationsInTracks - true iff we want annotations from SequenceTracks as well as those annotated directly on a documentpublic static Iterable<SequenceAnnotation> getSequenceAndTrackAnnotations(SequenceDocument sequence)
SequenceTracks on this sequence.
Most code should instead manually load tracks on demand since they may be too large to fit into memory. To get tracks on a sequence use
SequenceTrack.getTrackManager(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument) followed by
SequenceTrack.Manager.getTracks().
RuntimeException whose
cause is an XMLSerializationException if there is insufficient memory available to load the annotations.
When running DocumentOperations or SequenceAnnotationGenerators
core Geneious will automatic catch such exceptions and display a nice message to the user.sequence - the sequence to get annotations forpublic static SequenceDocument createSequenceCopyAdjustedForGapInsertion(SequenceDocument sequenceDocument, CharSequence gappedSequenceCharacters)
SequenceTracks. Tracks are instead automatically propagated from referenced documents in alignments.sequenceDocument - a sequence to insert gaps into. If the sequence alreayd contains gaps, the gaps are removed firstgappedSequenceCharacters - the sequence characters to appear in the new gapped sequence. The positions of gaps in this character sequence determine how annotations and chromatograms are adjusted.SequenceExtractionUtilities.removeGaps(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, boolean)public static List<? extends SequenceDocument> getSequences(AnnotatedPluginDocument[] documents, SequenceDocument.Alphabet alphabet, ProgressListener progressListener) throws DocumentOperationException
SequenceListOnDisk) and genome sized sequences (those longer than SequenceDocument.GENOME_SEQUENCE_THRESHOLD) in other sequence lists, these are only loaded into memory on demand
to ensure this method doesn't use excessive memory. If this method is potentially called on thousands of documents, then getSequencesWithoutImmediateLoading
should be considered instead.documents - documents to get the sequences out ofalphabet - alphabet the sequences need to be to be includedprogressListener - for notifying the caller about progress of this method and for cancelling.DocumentOperationException - if there is a problem getting the PluginDocument out of an AnnotatedPluginDocument or if the progress listener cancels the request.public static List<? extends SequenceDocument> getSequences(List<AnnotatedPluginDocument> documents, SequenceDocument.Alphabet alphabet, ProgressListener progressListener) throws DocumentOperationException
SequenceListOnDisk) and genome sized sequences (those longer than SequenceDocument.GENOME_SEQUENCE_THRESHOLD) in other sequence lists, these are only loaded into memory on demand
to ensure this method doesn't use excessive memory. If this method is potentially called on thousands of documents, then getSequencesWithoutImmediateLoading
should be considered instead.documents - documents to get the sequences out ofalphabet - alphabet the sequences need to be to be includedprogressListener - for notifying the caller about progress of this method and for cancelling.DocumentOperationException - if there is a problem getting the PluginDocument out of an AnnotatedPluginDocument or if the progress listener cancels the request.public static Collection<? extends SequenceDocument> getSequencesWithoutImmediateLoading(AnnotatedPluginDocument[] documents, SequenceDocument.Alphabet alphabet) throws DocumentOperationException
getSequences(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument.Alphabet, jebl.util.ProgressListener)
but doesn't require each plugin document to be in memory as long as this Collection is around. The trade-off is that the sequences can only be accessed sequentially
(hence the Collection return type of this method). Also the Collection does not support removal.try {... } catch (RuntimeDocumentOperationException e) and then handling the exception from there.
Note that using getSequences(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument.Alphabet, jebl.util.ProgressListener)
is preferable to using getSequencesWithoutImmediateLoading when dealing with under a thousand documents.documents - documents to get the sequences out ofalphabet - alphabet the sequences need to be to be includedDocumentOperationException - if one or more of the documents has more than Integer.MAX_VALUE sequences.RuntimeDocumentOperationExceptionpublic static long getNumberOfSequences(List<AnnotatedPluginDocument> documents, SequenceDocument.Alphabet alphabet)
documents - the documents to get the number of sequences inalphabet - the alphabet (nucleotide or amino acid) of the sequences to count.public static long getNumberOfSequences(AnnotatedPluginDocument document, SequenceDocument.Alphabet alphabet)
document - the document to get the number of sequences inalphabet - the alphabet (nucleotide or amino acid) of the sequences to count.@Deprecated public static SequenceDocument generateConsensusSequence(SequenceAlignmentDocument alignment, ProgressListener progressListener)
generateConsensus(com.biomatters.geneious.publicapi.documents.sequence.SequenceAlignmentDocument, jebl.util.ProgressListener) insteadSequenceExtractionUtilities.removeGaps(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument)
should be used.alignment - the alignment to generate the consensus sequence forprogressListener - for reporting progress can cancelling.public static SequenceDocument generateConsensus(SequenceAlignmentDocument alignment, ProgressListener progressListener) throws DocumentOperationException
SequenceExtractionUtilities.removeGaps(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument)
should be used.alignment - the alignment to generate the consensus sequence forprogressListener - for reporting progress can cancelling.DocumentOperationException - if the consensus can't be generated because there is insufficient free memory.DocumentOperationException.Canceled - if the progressListener requests the consensus generation be cancelled.public static String getBlastAlignmentText(SequenceAlignmentDocument alignment, boolean geneiousFriendly)
alignment - alignment to formatgeneiousFriendly - whether to format the alignment in an html-formatted "Geneious friendly" way
that is useful generally for alignments and not just for BLAST outputpublic static DefaultAlignmentDocument alignmentFromJeblSequences(String name, List<Sequence> jeblSequences)
name - name for alignmentjeblSequences - aligned jebl sequencespublic static List<AnnotatedPluginDocument> createNewDocumentsByTransformingSequences(List<AnnotatedPluginDocument> sourceDocuments, SequenceDocument.Transformer transformer, ProgressListener progressListener, String newSequenceOrDocumentNamePrefix) throws DocumentOperationException
sourceDocuments - the source documents containing sequences to transform. These may be SequenceDocuments or SequenceListDocuments or SequenceAlignmentDocumentstransformer - the transformer for transforming each sequenceprogressListener - for reporting progress and cancelingnewSequenceOrDocumentNamePrefix - an optional prefix to assign to the name of each newly generated document. May be an empty String to leave names unchanged.DocumentOperationException - if documents can't be loaded, or if the input documents are not SequenceDocuments or SequenceListDocuments or SequenceAlignmentDocuments