public class SequenceExtractionUtilities extends Object
SequenceDocument as input,
the extracted region may not include all information that was present on some SequenceDocument sub-classes. For example
MolecularStructureDocument information will not be included in extracted regions. The following information
will be included in extracted regions:
SequenceDocument.getCharSequence()SequenceAnnotationsDocumentFieldsNucleotideGraphsSequenceUtilities| Modifier and Type | Class and Description |
|---|---|
static class |
SequenceExtractionUtilities.ExtractionOptions
Represents options controling how sequence extraction works in
extractIntervals(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, com.biomatters.geneious.publicapi.implementations.SequenceExtractionUtilities.ExtractionOptions). |
| Modifier and Type | Field and Description |
|---|---|
static String |
REVERSED_NAME_SUFFIX
The suffix that is appended to sequence names when they are reversed.
|
| Modifier and Type | Method and Description |
|---|---|
static List<SequenceAnnotation> |
adjustAnnotationsForGapRemoval(CharSequence sequenceWithGaps,
List<SequenceAnnotation> annotations)
Creates a new list of annotations by adjusting their locations
to compensate for removing all the gaps in the sequence.
|
static List<SequenceAnnotation> |
adjustAnnotationsForGaps(CharSequence sequenceWithGaps,
List<SequenceAnnotation> annotations)
Creates a new list of annotations by adjusting their locations
to compensate for adding gaps into the sequence.
|
static void |
copyAllDocumentFields(SequenceDocument source,
DefaultSequenceDocument target)
Copy all document fields (such as organism, taxonomy and common name) from any SequenceDocument to a DefaultSequenceDocument.
|
static void |
copyDocumentFields(SequenceDocument source,
DefaultSequenceDocument target,
boolean isTranslation)
Copy important document fields (such as organism, taxonomy and common name) from any SequenceDocument to any DefaultSequenceDocument
|
static SequenceDocument |
extract(SequenceDocument sourceDocument,
SequenceExtractionUtilities.ExtractionOptions extractionOptions)
Extracts one or more intervals from a sequence as a new sequence document.
|
static DefaultSequenceDocument |
extractIntervals(SequenceDocument sequence,
Interval... intervalsToExtract)
A convenience method for extracting intervals from a sequence.
|
static DefaultSequenceDocument |
extractIntervals(SequenceDocument sequence,
SequenceAnnotationInterval... intervalsToExtract)
A convenience method for extracting intervals from a sequence.
|
static DefaultSequenceDocument |
extractIntervals(SequenceDocument sourceDocument,
SequenceExtractionUtilities.ExtractionOptions extractionOptions)
Extracts one or more intervals from a sequence as a new sequence document.
|
static DefaultSequenceDocument |
extractIntervals(SequenceDocument sourceDocument,
String overrideName,
GeneticCode geneticCode,
int translationFrame,
boolean residuesOnly,
List<SequenceAnnotationInterval> intervals,
boolean allowReverseComplement,
boolean removeGaps)
|
static DefaultSequenceDocument |
extractIntervalsOrThrow(SequenceDocument sourceDocument,
SequenceExtractionUtilities.ExtractionOptions extractionOptions)
Extracts one or more intervals from a sequence as a new sequence document.
|
static SequenceDocument |
extractOrThrow(SequenceDocument sourceDocument,
SequenceExtractionUtilities.ExtractionOptions extractionOptions)
Extracts one or more intervals from a sequence as a new sequence document.
|
static String |
getComplementWithoutReverseSequenceName(String sequenceName)
Appends the " (complement without reverse)" suffix to the sequence name (or removes if it is already there).
|
static String |
getExtractionName(String extractionType,
String annotationName,
String sequenceName,
boolean appendExtractionType)
Create a name for an extracted region
|
static GeneticCode |
getGeneticCode(SequenceAnnotation annotation) |
static String |
getReversedSequenceName(String sequenceName)
Appends the " (reversed)" suffix to the sequence name (or removes if it is already there).
|
static boolean |
isReversedSequence(SequenceDocument sequence)
Determines if a SequenceDocument is reversed or not based on whether its name ends with
REVERSED_NAME_SUFFIX or not. |
static SequenceDocument |
removeGaps(SequenceDocument sequence)
Equivalent to calling
removeGaps(sequence, true) |
static SequenceDocument |
removeGaps(SequenceDocument sequence,
boolean mustGeneratedDefaultSequenceDocument)
creates a sequence the same as the given sequence but with gap characters removed.
|
static SequenceAlignmentDocument |
reverseComplement(SequenceAlignmentDocument alignmentToReverse)
Creates a new alignment that is the reverse complement of the given alignment.
|
static DefaultSequenceDocument |
reverseComplement(SequenceDocument sequenceToReverse)
Convenience method for calling
reverseComplement(sequenceToReverse,true). |
static DefaultSequenceDocument |
reverseComplement(SequenceDocument sequenceToReverse,
boolean appendReversedToName)
Create a sequence that is the reverse complement another sequence.
|
static DefaultNucleotideSequence |
reverseComplement(SequenceDocument sequenceToReverse,
boolean appendReversedToName,
boolean includeOriginalBaseNumbersAnnotation)
Create a sequence that is the reverse complement another sequence.
|
static String |
translate(SequenceDocument sequence,
SequenceAnnotation annotation)
|
public static final String REVERSED_NAME_SUFFIX
public static String getReversedSequenceName(String sequenceName)
getReversedSequenceName("test") returns "test (reversed)"getReversedSequenceName("test (reversed)") returns "test"sequenceName - the sequence index to change the name of.sequenceName with " (reversed)" appended (or removed if it was already there)public static String getComplementWithoutReverseSequenceName(String sequenceName)
sequenceName - the sequence index to change the name of.sequenceName with " (complement without reverse)" appended (or removed if it was already there)public static boolean isReversedSequence(SequenceDocument sequence)
REVERSED_NAME_SUFFIX or not.sequence - the sequence to test.sequence is reversed, false otherwiseREVERSED_NAME_SUFFIX,
getReversedSequenceName(String)@Deprecated public static String translate(SequenceDocument sequence, SequenceAnnotation annotation)
extractIntervals(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, com.biomatters.geneious.publicapi.implementations.SequenceExtractionUtilities.ExtractionOptions) instead.sequence - annotation - public static SequenceDocument removeGaps(SequenceDocument sequence)
removeGaps(sequence, true)sequence - the sequence to remove gaps fromDefaultSequenceDocumentpublic static SequenceDocument removeGaps(SequenceDocument sequence, boolean mustGeneratedDefaultSequenceDocument)
sequence - the sequence to remove gaps frommustGeneratedDefaultSequenceDocument - true to ensure the returned sequence will be an instance of a DefaultSequenceDocument. If this is false, the returned sequence may be any SequenceDocument implementation.SequenceUtilities.createSequenceCopyAdjustedForGapInsertion(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, CharSequence)public static DefaultSequenceDocument extractIntervals(SequenceDocument sequence, SequenceAnnotationInterval... intervalsToExtract)
extractIntervals(sequence,sequence,null,null,0,false, Arrays.asList(intervalsToExtract),true,false)sequence - the sequence to extract intervals fromintervalsToExtract - the intervals to extract.public static DefaultSequenceDocument extractIntervals(SequenceDocument sequence, Interval... intervalsToExtract)
extractIntervals(sequence,sequence,null,null,0,false, Arrays.asList(intervalsToExtract),true,false)sequence - the sequence to extract intervals fromintervalsToExtract - the intervals to extract.public static List<SequenceAnnotation> adjustAnnotationsForGapRemoval(CharSequence sequenceWithGaps, List<SequenceAnnotation> annotations)
adjustAnnotationsForGaps(CharSequence, java.util.List)sequenceWithGaps - sequence that may include gap charactersannotations - the original list of sequence annotationsadjustAnnotationsForGaps(CharSequence, java.util.List),
SequenceGapInformation.adjustAnnotationsForGapRemoval(java.util.List)public static List<SequenceAnnotation> adjustAnnotationsForGaps(CharSequence sequenceWithGaps, List<SequenceAnnotation> annotations)
adjustAnnotationsForGapRemoval(CharSequence, java.util.List)sequenceWithGaps - sequence string with gapsannotations - annotations against the sequence string with gaps removedadjustAnnotationsForGapRemoval(CharSequence, java.util.List),
SequenceGapInformation.adjustAnnotationsForGapInsertion(java.util.List)public static DefaultSequenceDocument reverseComplement(SequenceDocument sequenceToReverse)
reverseComplement(sequenceToReverse,true).sequenceToReverse - the sequence to create the reverse complement of.sequenceToReversepublic static SequenceAlignmentDocument reverseComplement(SequenceAlignmentDocument alignmentToReverse)
alignmentToReverse - the alignment to create the reverse complement of.alignmentToReverseIllegalArgumentException - if any of the sequences in alignmentToReverse are not NucleotideSequenceDocuments.public static DefaultSequenceDocument reverseComplement(SequenceDocument sequenceToReverse, boolean appendReversedToName)
sequenceToReverse - the sequence to create the reverse complement of.appendReversedToName - true to append " (reversed)" to the name of sequenceToReverse to form the name of the returned sequence. false to give the returned sequence the same name as sequenceToReverse.sequenceToReversepublic static DefaultNucleotideSequence reverseComplement(SequenceDocument sequenceToReverse, boolean appendReversedToName, boolean includeOriginalBaseNumbersAnnotation)
sequenceToReverse - the sequence to create the reverse complement of.appendReversedToName - true to append " (reversed)" to the name of sequenceToReverse to form the name of the returned sequence. false to give the returned sequence the same name as sequenceToReverse.includeOriginalBaseNumbersAnnotation - true to include an annotation (which is invisible to end users) indicating the original numbering of this sequence. false to exclude it. Usually this should be true, except in cases where we are dealing with enormous amounts of data (e.g. next gen sequencing) in which case we want to exclude it for performance reasons.sequenceToReversepublic static GeneticCode getGeneticCode(SequenceAnnotation annotation)
annotation - public static void copyAllDocumentFields(SequenceDocument source, DefaultSequenceDocument target)
source - to copy document fields fromtarget - to copy document fields topublic static void copyDocumentFields(SequenceDocument source, DefaultSequenceDocument target, boolean isTranslation)
source - to copy document fields fromtarget - to copy document fields toisTranslation - whether the target is a translation of the source. If it is not a translation, the molecule type field will be copied.@Deprecated public static DefaultSequenceDocument extractIntervals(SequenceDocument sourceDocument, String overrideName, GeneticCode geneticCode, int translationFrame, boolean residuesOnly, List<SequenceAnnotationInterval> intervals, boolean allowReverseComplement, boolean removeGaps)
extractIntervals(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, com.biomatters.geneious.publicapi.implementations.SequenceExtractionUtilities.ExtractionOptions) instead.sourceDocument - To extract fromgeneticCode - translates from nucleotide's to amino acids if specified, or performs no translation if this parameter is nulltranslationFrame - offset for each interval (typically 0, 1 or 2 for DNA). If not translating, this should be 0.residuesOnly - whether to extract only residues or to include the annotations.intervals - to extractallowReverseComplement - if false, automatic reverse complementing will not happen. If true,
intervals of the form (from, to) where from >= to will be reverse complemented.overrideName - name of new sequence. If not given will be derived from seqeunce name and type of
extractionremoveGaps - if true remove any gapspublic static DefaultSequenceDocument extractIntervals(SequenceDocument sourceDocument, SequenceExtractionUtilities.ExtractionOptions extractionOptions)
sourceDocument - The sequence to extract fromextractionOptions - the options to use when extracting.RuntimeException - whose cause is an XMLSerializationException if there is insufficient memory to load the annotations in trackspublic static DefaultSequenceDocument extractIntervalsOrThrow(SequenceDocument sourceDocument, SequenceExtractionUtilities.ExtractionOptions extractionOptions) throws DocumentOperationException
sourceDocument - The sequence to extract fromextractionOptions - the options to use when extracting.DocumentOperationException - if there is insufficient memory to load the annotations in trackspublic static SequenceDocument extractOrThrow(SequenceDocument sourceDocument, SequenceExtractionUtilities.ExtractionOptions extractionOptions) throws DocumentOperationException
extractIntervals(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, com.biomatters.geneious.publicapi.implementations.SequenceExtractionUtilities.ExtractionOptions)
only in that the returned document will not necessarily be a DefaultSequenceDocumentsourceDocument - The sequence to extract fromextractionOptions - the options to use when extracting. The same extractionOptions should be reused for calls
that perform many extractions on the same sequence as this allows caching of sequence properties and therefore improved performance.
Methods like SequenceExtractionUtilities.ExtractionOptions.setIntervals(java.util.List) and SequenceExtractionUtilities.ExtractionOptions.setOverrideName(String)
can be used between each call to this method.SequenceExtractionUtilities.ExtractionOptions.progressListener was canceled.DocumentOperationException - if there is insufficient memory to load the annotations in trackspublic static SequenceDocument extract(SequenceDocument sourceDocument, SequenceExtractionUtilities.ExtractionOptions extractionOptions)
extractIntervals(com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument, com.biomatters.geneious.publicapi.implementations.SequenceExtractionUtilities.ExtractionOptions)
only in that the returned document will not necessarily be a DefaultSequenceDocumentsourceDocument - The sequence to extract fromextractionOptions - the options to use when extracting. The same extractionOptions should be reused for calls
that perform many extractions on the same sequence as this allows caching of sequence properties and therefore improved performance.
Methods like SequenceExtractionUtilities.ExtractionOptions.setIntervals(java.util.List) and SequenceExtractionUtilities.ExtractionOptions.setOverrideName(String)
can be used between each call to this method.SequenceExtractionUtilities.ExtractionOptions.progressListener was canceled.RuntimeException - whose cause is an XMLSerializationException if there is insufficient memory to load the annotations in trackspublic static String getExtractionName(String extractionType, String annotationName, String sequenceName, boolean appendExtractionType)
extractionType - eg. "reverse complement", "translation" or "extraction". Can be others.annotationName - the name of the annotation being extracted, or null if not extracting an annotationsequenceName - the name of the sequence being extracted fromappendExtractionType - true if the extraction type string should be appended. eg. this would be false if the entire sequence is being extracted from an alignment