API Documentation¶
-
autosnapgene.
parse
(path, block_classes=None)[source]¶ Parse the given file and return a
SnapGene
object.This is an alias for
Snapgene(path)
.
-
autosnapgene.
write
(path, dna)[source]¶ Write the given
SnapGene
object (dna) to the given path.This is an alias for
dna.write(path)
.
-
class
autosnapgene.
SnapGene
(path=None)[source]¶ -
-
accession_number
¶
-
add_feature
(feature, seq=None)[source]¶ Add the given feature to the sequence.
The argument should be a Feature instance. Colors and positions are specified as segments, which you can provide by filling in the segments attribute of the Feature instance with FeatureSegments instances.
If you specify the optional seq argument, the position of the feature will automatically be set to the position of that subsequence in the full sequence. If the given subsequence appears multiple times, multiple features will be created. If the subsequence doesn’t appear, a
SequenceNotFound
exception will be raised. The given feature must have either 0 or 1 segments, otherwise it isn’t clear how the position should be set.
-
add_trace
(path, name=None)[source]¶ Add the given trace to the sequence, if the sequence doesn’t already have a trace of the same name (or the given name).
The trace is always added after any existing traces.
-
append_trace
(path, name=None)[source]¶ Add the given trace to this sequence after any existing traces.
Unlike add_trace(), this function adds the trace unconditionally, which may result in duplicates.
The creator of this sequence.
-
code_number
¶
-
comments
¶ Miscellaneous comments on this sequence.
-
custom_map_label
¶
-
date_created
¶ The date the sequence was created.
-
date_last_modified
¶ The date the sequence was last modified.
-
description
¶ A description of the sequence.
-
dna_sequence
¶
-
export_version
¶
-
extract_traces
(dir)[source]¶ Save any traces associated with this sequence as separate files in the given directory.
The traces will be saved in the ZTR format, which is the format used internally by SnapGene.
-
features
¶ Return a list of all the features in this sequence.
-
file_type
¶
The creator of this sequence.
-
get_feature
(name)[source]¶ Return the feature with the given name.
If multiple features have the given name, only the first one encountered will be returned. A
FeatureNotFound
exception will be raised if no feature with the given name can be found.
-
get_sequence
()[source]¶ Get the DNA or protein sequence stored in this file.
This method will not indicate whether it returned a protein or DNA sequence, so if that is not clear from the context, use
get_dna_sequence()
orget_protein_sequence()
to be sure. If the file doesn’t contain either type of sequence, aBlockNotFound
exception will be raised.
-
get_traces
(name=None)[source]¶ Return information about all of the alignments/traces associated with the sequence.
If a name is provided, only traces with that name will be returned. If a
pathlib.Path
is given as the name, the stem of that path will be taken as the name.
-
get_transformed_into
()[source]¶ The organism/strain being used to propagate this sequence in the lab.
-
has_trace
(name)[source]¶ Return True is the sequence contains a trace with the given name.
If a
pathlib.Path
is given as the name, the stem of that path will be taken as the name.
-
import_version
¶
-
insert_trace
(i, path, name=None)[source]¶ Add the given trace to this sequence at the given index.
Unlike add_trace(), this function adds the trace unconditionally, which may result in duplicates.
-
is_confirmed_experimentally
¶ True if this sequence has been experimentally confirmed.
-
is_dam_methylated
¶
-
is_dcm_methylated
¶
-
is_ecoki_methylated
¶
-
organism
¶ The organism this sequence derives from.
-
plasmid_type
¶ “Natural” or “Synthetic”.
-
prepend_trace
(path, name=None)[source]¶ Add the given trace to this sequence before any existing traces.
Unlike add_trace(), this function adds the trace unconditionally, which may result in duplicates.
-
protein_sequence
¶
-
references
¶
-
remove_feature
(name)[source]¶ Remove the feature with the given name from this sequence.
Only the feature annotation is removed; the sequence corresponding to the feature remains. If no feature with the given name can be found, a
FeatureNotFound
exception is raised.
-
remove_trace
(name)[source]¶ Remove the trace with the given name.
If a
pathlib.Path
is given as the name, the stem of that path will be taken as the name. If there are multiple traces with the same name, all will be removed. If there are no traces with the given name, a ValueError will be raised.
-
rename_trace
(old_name, new_name)[source]¶ Rename the given trace.
If multiple traces have the same name, they will all be renamed.
-
replace_trace
(old_name, path, new_name=None)[source]¶ Replace the trace with the given name with the given path.
If there are multiple traces with the given name, the first will be replaced and the rest will be removed.
-
sequence
¶ Get the DNA or protein sequence stored in this file.
This method will not indicate whether it returned a protein or DNA sequence, so if that is not clear from the context, use
get_dna_sequence()
orget_protein_sequence()
to be sure. If the file doesn’t contain either type of sequence, aBlockNotFound
exception will be raised.
-
sequence_class
¶
-
set_sequence
(value)[source]¶ Set the DNA or protein sequence stored in this file.
If the file does not yet contain a sequence, the DNA sequence will be set.
-
sort_traces
(key=<function SnapGene.<lambda>>, reverse=False)[source]¶ Rearrange the traces according to the given key function.
If no key function is given, the traces will be sorted alphabetically. The argument to the key function will be an AlignmentMetadata object.
-
strandedness
¶
-
topology
¶
-
trace_names
¶
-
traces
¶ Return information about all of the alignments/traces associated with the sequence.
If a name is provided, only traces with that name will be returned. If a
pathlib.Path
is given as the name, the stem of that path will be taken as the name.
-
transformed_into
¶ The organism/strain being used to propagate this sequence in the lab.
-
use_custom_map_label
¶
-
-
class
autosnapgene.
Feature
(**kwargs)[source]¶ -
-
class
DirectionalityAttrib
[source]¶ -
str_from_value
= {'backward': '2', 'bidirectional': '3', 'forward': '1', 'none': '0'}¶
-
value_from_str
= {'0': 'none', '1': 'forward', '2': 'backward', '3': 'bidirectional'}¶
-
-
class
QualifierTag
[source]¶ -
data_formats
= {<class 'int'>: 'int', <class 'str'>: 'text'}¶
-
data_types
= {'int': <class 'int'>, 'text': <class 'str'>}¶
-
-
classmethod
from_segment
(**kwargs)[source]¶ Instantiate a feature with a single segment.
Keyword arguments corresponding to any attribute of either the Feature or FeatureSegment classes are accepted.
-
get_segment
()[source]¶ If this feature has only one segment, return it. Otherwise, raise an exception.
-
repr_attrs
= ('name', 'type')¶
-
segment
¶ If this feature has only one segment, return it. Otherwise, raise an exception.
-
set_segment
(segment)[source]¶ Remove any segments associated with this feature, and replace them with the given segment.
After calling this setter (or assigning to this attribute), the feature will have exactly one segment. It will still be possible to add or remove segments later, though.
-
xml_attrib_defs
= [('id', 'recentID', <class 'autosnapgene.parser.Xml.IntAttrib'>), ('name', 'name', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('type', 'type', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('directionality', 'directionality', <class 'autosnapgene.blocks.features.Feature.DirectionalityAttrib'>), ('reading_frame', 'readingFrame', <class 'autosnapgene.parser.Xml.IntAttrib'>), ('cleavage_arrows', 'cleavageArrows', <class 'autosnapgene.blocks.features.Feature.CleavageArrowsAttrib'>), ('allow_segment_overlaps', 'allowSegmentOverlaps', <class 'autosnapgene.parser.Xml.BoolAttrib'>), ('swapped_segment_numbering', 'swappedSegmentNumbering', <class 'autosnapgene.parser.Xml.BoolAttrib'>), ('max_run_on', 'maxRunOn', <class 'autosnapgene.parser.Xml.IntAttrib'>), ('max_fused_run_on', 'maxFusedRunOn', <class 'autosnapgene.parser.Xml.IntAttrib'>), ('detection_mode', 'detectionMode', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('genetic_code_id', 'geneticCode', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('first_codon_met', 'translateFirstCodonAsMet', <class 'autosnapgene.parser.Xml.BoolAttrib'>), ('consecutive_translation_numbering', 'consecutiveTranslationNumbering', <class 'autosnapgene.parser.Xml.BoolAttrib'>), ('consecutive_numbering_start', 'consecutiveNumberingStartsFrom', <class 'autosnapgene.parser.Xml.IntAttrib'>), ('translated_mw', 'translationMW', <class 'autosnapgene.parser.Xml.FloatAttrib'>), ('hits_stop_codon', 'hitsStopCodon', <class 'autosnapgene.parser.Xml.BoolAttrib'>)]¶
-
xml_subtag_defs
= [('segments', 'Segment', <class 'autosnapgene.blocks.features.Feature.SegmentTag'>, []), ('qualifiers', 'Q', <class 'autosnapgene.blocks.features.Feature.QualifierTag'>, {})]¶
-
xml_tag
= 'Feature'¶
-
class
-
class
autosnapgene.
FeatureSegment
(**kwargs)[source]¶ -
-
begin
¶
-
end
¶
-
repr_attrs
= ('type', 'color', 'range')¶
-
xml_attrib_defs
= [('name', 'name', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('range', 'range', <class 'autosnapgene.blocks.features.FeatureSegment.RangeAttrib'>), ('display', 'type', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('color', 'color', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('is_translated', 'translated', <class 'autosnapgene.parser.Xml.BoolAttrib'>), ('translation_start_number', 'translationNumberingStartsFrom', <class 'autosnapgene.parser.Xml.IntAttrib'>)]¶
-
xml_tag
= 'Segment'¶
-
-
class
autosnapgene.
Reference
(**kwargs)[source]¶ -
repr_attrs
= ('pubmed_id',)¶
-
xml_attrib_defs
= [('title', 'title', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('pubmed_id', 'pubMedID', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('journal', 'journal', <class 'autosnapgene.parser.Xml.TextAttrib'>), ('authors', 'authors', <class 'autosnapgene.parser.Xml.TextAttrib'>)]¶
-
xml_tag
= 'Reference'¶
-