public final class SequenceTools extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addAllFeatures(Sequence seq,
FeatureHolder fh)
Add features to a sequence that contain the same information as all
those in a feature holder.
|
static Sequence |
createDummy(Alphabet alpha,
int length,
Symbol sym,
String uri,
String name)
Create a new Sequence that contains a single symbol repeated over and over.
|
static Sequence |
createDummy(String uri,
String name)
Create a new Sequence that has no annotation, no features and a zero-length
symbol list.
|
static Sequence |
createSequence(SymbolList syms,
String uri,
String name,
Annotation ann) |
static GappedSequence |
gappedView(Sequence seq)
Create a new gapped sequence for a sequence.
|
static Sequence |
maskSequence(Sequence seq,
RangeLocation loc)
Mask of a sequence.
|
static Sequence |
reverseComplement(Sequence seq)
Reverse-complement a sequence, and flip all of its features.
|
static Sequence |
subSequence(Sequence seq,
int start,
int end)
Extract a sub-sequence from a sequence.
|
static Sequence |
subSequence(Sequence seq,
int start,
int end,
String name)
Extract a sub-sequence from a sequence.
|
static Sequence |
subSequence(Sequence seq,
int start,
int end,
String name,
StrandedFeature.Strand strand)
Extract a sub-sequence from a sequence.
|
static ViewSequence |
view(Sequence seq)
Create a new sequence that has all of the data in the original, but allows
new features and top-level annotations to be added independantly.
|
static ViewSequence |
view(Sequence seq,
FeatureRealizer fr)
Creates a new Sequence with the data of the old but with a different
FeatureRealizer that will be applied to new Features.
|
static ViewSequence |
view(Sequence seq,
String name)
Create a new sequence that has all of the data in the original, but allows
new features and top-level annotations to be added independantly.
|
public static Sequence createSequence(SymbolList syms, String uri, String name, Annotation ann)
public static Sequence subSequence(Sequence seq, int start, int end) throws IndexOutOfBoundsException
The sub-sequence will be indexed from 1 through to (end-start+1). An index of i in the sub-sequence corresponds to (i+start-1) in the original. All features from the original sequence will be projected down into this co-ordinate system. All features overlapping the edges will be given fuzzy locations.
seq
- the sequence to sub-sequencestart
- the first index to include in the sub-sequenceend
- the last index to include in the sub-sequenceIndexOutOfBoundsException
- if start or end are not in seq, or if
end < startpublic static Sequence subSequence(Sequence seq, int start, int end, String name) throws IndexOutOfBoundsException
The sub-sequence will be indexed from 1 through to (end-start+1). An index of i in the sub-sequence corresponds to (i+start-1) in the original. All features from the original sequence will be projected down into this co-ordinate system. All features overlapping the edges will be given fuzzy locations.
seq
- the sequence to sub-sequencestart
- the first index to include in the sub-sequenceend
- the last index to include in the sub-sequencename
- a new name to give to this sub-sequenceIndexOutOfBoundsException
- if start or end are not in seq, or if
end < startpublic static Sequence subSequence(Sequence seq, int start, int end, String name, StrandedFeature.Strand strand) throws IndexOutOfBoundsException, IllegalAlphabetException
The sub-sequence will be indexed from 1 through to (end-start+1). If the strand is NEGATIVE, all features will be flipped in the same manner as the reverseComplement method. If it is UNKNOWN or POSITIVE, then this is identical to the other subSequence methods.
seq
- the sequence to sub-sequencestart
- the first index to include in the sub-sequenceend
- the last index to include in the sub-sequencename
- a new name to give to this sub-sequencestrand
- a StrandedFeature.Strand indicating which strand the
sub-sequence should be onIndexOutOfBoundsException
- if start or end are not in seq, or if
end < startIllegalAlphabetException
public static Sequence reverseComplement(Sequence seq) throws IllegalAlphabetException
seq
- the Sequence to reverse-complementIllegalAlphabetException
- if the symbols in the sequence can not be
complementedpublic static ViewSequence view(Sequence seq)
seq
- the Sequence to viewpublic static ViewSequence view(Sequence seq, String name)
seq
- the Sequence to viewname
- a new name for the sequencepublic static ViewSequence view(Sequence seq, FeatureRealizer fr)
seq
- the Sequence to wrapfr
- the new FeatureRealizerpublic static GappedSequence gappedView(Sequence seq)
The gapped sequence can be used to insert gaps. The features on the underlying sequence will be projected onto the view taking the gaps into account.
seq
- public static Sequence maskSequence(Sequence seq, RangeLocation loc) throws IndexOutOfBoundsException, IllegalArgumentException
This will return a view of a sequence where everything outside loc is dropped. This includes all symbols, which become gaps, and all features, which behave in a similar manner to those produced by subSequence().
seq
- the Sequence to maskloc
- the region to retainIndexOutOfBoundsException
- if loc is not totaly within seqIllegalArgumentException
- fixme: not sure where this comes frompublic static Sequence createDummy(String uri, String name)
uri
- the URI to give the dummy sequencename
- the name of the dummy sequencepublic static Sequence createDummy(Alphabet alpha, int length, Symbol sym, String uri, String name) throws IllegalSymbolException
alpha
- the Alphabet this sequence is overlength
- the length of the sequencesym
- the symbol returned by every call to symbolAturi
- the URI of the sequencename
- the name of the sequenceIllegalSymbolException
- if sym is not in alphapublic static void addAllFeatures(Sequence seq, FeatureHolder fh) throws ChangeVetoException, BioException
seq
- the Sequence to add features tofh
- the features to addChangeVetoException
- if the sequence could not be modifiedBioException
- if there was an error creating the featuresCopyright © 2014 BioJava. All rights reserved.