pub struct Seq {Show 17 fields
pub name: Option<String>,
pub topology: Topology,
pub date: Option<Date>,
pub len: Option<usize>,
pub molecule_type: Option<String>,
pub division: String,
pub definition: Option<String>,
pub accession: Option<String>,
pub version: Option<String>,
pub source: Option<Source>,
pub dblink: Option<String>,
pub keywords: Option<String>,
pub references: Vec<Reference>,
pub comments: Vec<String>,
pub seq: Vec<u8>,
pub contig: Option<Location>,
pub features: Vec<Feature>,
}
Fields
name: Option<String>
Name as specified in the LOCUS line
topology: Topology
Whether this molecule is linear or circular
date: Option<Date>
The date specified in the LOCUS line
len: Option<usize>
Length as specified in the LOCUS line. Note that this may differ from
seq.len()
, especially if contig
is Some
and seq
is empty. When
parsing a file, if sequence data is provided we check that this value is
equal to seq.len()
molecule_type: Option<String>
division: String
definition: Option<String>
accession: Option<String>
version: Option<String>
source: Option<Source>
dblink: Option<String>
keywords: Option<String>
references: Vec<Reference>
comments: Vec<String>
seq: Vec<u8>
contig: Option<Location>
features: Vec<Feature>
Implementations
sourceimpl Seq
impl Seq
pub fn is_circular(&self) -> bool
sourcepub fn len(&self) -> i64
pub fn len(&self) -> i64
Returns the “actual” length of the sequence. Note that this may not be equal to self.seq.len(), in the following circumstances:
self.seq
is empty andself.contig
is not, and the corresponding file’s LOCUS line specified a length. The returned value is i64 to simplifiy arithmetic with coords fromLocation
sourcepub fn unwrap_range(&self, start: i64, end: i64) -> (i64, i64)
pub fn unwrap_range(&self, start: i64, end: i64) -> (i64, i64)
“Normalises” an exclusive range on the chromosome, to make handling circular
sequences simpler. For linear sequences, it doesn’t do anything except
panic unless start
and end
are both within the sequence, or if end <= start
. For circular sequences, all values, including negative values,
are allowed.
If end
<= start
, the range is assumed to wrap around. The returned
values will satisfy the following conditions:
0 <= first < len
first < last
This means that in the case of a range which wraps around,last
>=len
.
sourcepub fn range_to_location(&self, start: i64, end: i64) -> Location
pub fn range_to_location(&self, start: i64, end: i64) -> Location
Given a range on this sequence, returns a corresponding Location
Note: this is a rust-style, exclusive range
sourcepub fn wrap_location(&self, p: Location) -> Result<Location, LocationError>
pub fn wrap_location(&self, p: Location) -> Result<Location, LocationError>
“Wraps” a location on a circular sequence, so that coordinates that extend beyond the end of the sequence are are wrapped to the origin.
sourcepub fn relocate_feature(
&self,
f: Feature,
shift: i64
) -> Result<Feature, LocationError>
pub fn relocate_feature(
&self,
f: Feature,
shift: i64
) -> Result<Feature, LocationError>
“Shifts” a feature forwards by shift
NTs (can be negative)
Note: If this fails you won’t get the original Feature
back. If this is important, you should clone first
sourcepub fn relocate_location(
&self,
p: Location,
shift: i64
) -> Result<Location, LocationError>
pub fn relocate_location(
&self,
p: Location,
shift: i64
) -> Result<Location, LocationError>
“Shifts” a location forwards by shift
NTs (can be negative)
Note: If this fails you won’t get the original Location
back. If this is important, you should clone first
sourcepub fn revcomp_feature(&self, f: Feature) -> Result<Feature, LocationError>
pub fn revcomp_feature(&self, f: Feature) -> Result<Feature, LocationError>
Note: If this fails you won’t get the original Feature
back. If this is important, you should clone first
sourcepub fn revcomp(&self) -> Seq
pub fn revcomp(&self) -> Seq
Returns the reverse complement of a Seq
, skipping any features
which can’t be processed with a warning
sourcepub fn extract_range_seq(&self, start: i64, end: i64) -> Cow<'_, [u8]>
pub fn extract_range_seq(&self, start: i64, end: i64) -> Cow<'_, [u8]>
Extracts just the sequence from start
to end
, taking into
account circularity. Note that end
is exclusive. Use
this instead of extract_range
if you don’t need the
features.
sourcepub fn extract_range(&self, start: i64, end: i64) -> Seq
pub fn extract_range(&self, start: i64, end: i64) -> Seq
Extracts from start
to end
, truncating features that
extend beyond this range. Note that end
is not
inclusive. Skips ambiguous features with a warning.
sourcepub fn extract_location(&self, l: &Location) -> Result<Vec<u8>, LocationError>
pub fn extract_location(&self, l: &Location) -> Result<Vec<u8>, LocationError>
Extract the sequence specified by l
. This version returns
Err(LocationError::External(_, NoFetcherError))
if it
encounters a reference to an external sequence.
See extract_location_with_fetcher
for details
sourcepub fn extract_location_with_fetcher<'a, F, S>(
&self,
l: &Location,
ext_fetcher: F
) -> Result<Vec<u8>, LocationError> where
F: FnMut(&str) -> Result<S, Box<dyn Error>> + 'a,
S: Borrow<Seq> + 'a,
pub fn extract_location_with_fetcher<'a, F, S>(
&self,
l: &Location,
ext_fetcher: F
) -> Result<Vec<u8>, LocationError> where
F: FnMut(&str) -> Result<S, Box<dyn Error>> + 'a,
S: Borrow<Seq> + 'a,
Extract the sequence specified by l
. If the location
references an external sequence, ext_fetcher
will be called
with the name of this sequence to retrieve it. Since an external
feature may be referenced multiple times, it might be best to
return &Seq
or similar from ext_fetcher
.
sourcepub fn set_origin(&self, origin: i64) -> Seq
pub fn set_origin(&self, origin: i64) -> Seq
Returns a new Seq
, rotated so that origin
is at the start
pub fn write<T: Write>(&self, file: T) -> Result<()>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Seq
impl<'de> Deserialize<'de> for Seq
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Seq
Auto Trait Implementations
impl RefUnwindSafe for Seq
impl Send for Seq
impl Sync for Seq
impl Unpin for Seq
impl UnwindSafe for Seq
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more