Python library for making and tracking mutated copies of DNA components
Project description
Co
Co is a Python library for altering annotated DNA sequences. It keeps track of components and lifts over feature annotations when a component is “mutated” by applying a series of mutations. With co you can build new consensus sequences for cloned organisms and trace changes to features within a lineage.
For more information, check out the Documentation.
Hello Co!
>>> from co import Component >>> from co.mutation import * >>> hello = Component('Hello X!') >>> hello.seq Seq('Hello X!', Alphabet()) >>> hello_world = hello.mutate([Mutation(6, 1, 'world')]) >>> hello_world.seq Seq('Hello world!', Alphabet())
Working with Feature Annotations
Components are modeled after BioPython’s SeqRecord – they have both a sequence, and features:
>>> from Bio.SeqFeature import *
>>> slogan = Component('CoPy is for DNA components', features=[
... SeqFeature(FeatureLocation(0, 4), type='name'),
... SeqFeature(FeatureLocation(12, 15), id='DNA')])
>>>
>>> # features are bound to components -- and you can always access their DNA sequence
...
>>> slogan.features.add(FeatureLocation(16, 26)).seq
Seq('components', Alphabet())
>>> [f.seq for f in slogan.features]
[Seq('CoPy', Alphabet()), Seq('DNA', Alphabet()), Seq('components', Alphabet())]
>>>
>>> # New Components are made through series of mutations
... # You not only get the new sequence but a mutated component: Features are translated to the
... # new sequence as well.
...
>>> new_slogan = slogan.mutate([DEL(2, 2), DEL(12, 4)])
>>> new_slogan.seq
Seq('Co is for components', Alphabet())
>>> new_slogan.features
ComponentFeatureSet([Feature(FeatureLocation(ExactPosition(0), ExactPosition(2)), type='name'),
Feature(FeatureLocation(ExactPosition(10), ExactPosition(20)))])
>>> [f.seq for f in new_slogan.features]
[Seq('Co', Alphabet()), Seq('components', Alphabet())]
>>> list(new_slogan.features.find(type='name')) # features can be filtered by type, id, strand, position, and qualifiers
[Feature(FeatureLocation(ExactPosition(0), ExactPosition(2)), type='name')]
>>>
>>> # Using Component.fdiff you can get a summary of what features where affected by mutation. (Unchanged features
... # that have a new coordinate -- e.g. the 'components' feature in this example -- are not included).
...
>>> slogan.fdiff(new_slogan)
Diff(added=(Feature(FeatureLocation(ExactPosition(12), ExactPosition(15)), id='DNA'),
Feature(FeatureLocation(ExactPosition(0), ExactPosition(4)), type='name')),
removed=(Feature(FeatureLocation(ExactPosition(0), ExactPosition(2)), type='name'),))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
co-0.2.0.tar.gz
(17.2 kB
view details)
File details
Details for the file co-0.2.0.tar.gz
.
File metadata
- Download URL: co-0.2.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec9095b71f096b0c2fbf00d2be237746863d1fc644f070b894ab7acc95e76e94 |
|
MD5 | c2215c60ae22e026b48f97e5847c3038 |
|
BLAKE2b-256 | b313a18b01f8e530f44841a8537ac91e5f47493a4e5f661dfbb8dcca65a951de |