Skip to main content

Basic Biological Sequence Manipulations

Project description

Import as usual

>>> import nebseq

Reverse complements

The only note here is that revcomp does not check the input sequence to see if it looks like DNA or RNA.

>>> nebseq.revcomp('ACGT')
'ACGT'
>>> nebseq.revcomp('TTACC')
'GGTAA'

And if we give it garbage it just gives us garbage back.

>>> nebseq.revcomp('ZQ')
'QZ'

Translation

The translation function should allow for full support of sequence translation. This includes things like trimming the first couple bases and using alternate translation tables. There is also support for the more esoteric post translational modifications that can be found in some Genbank files as well as translating partial peptides (for things like fuzzy coordinates).

Basic translation:

>>> nebseq.translate('TTGGCCAAGGAACGA', table=11)
'MAKER'

Showing the effects of a partial peptide translation. By default the first codon should be a start codon according to the selected translation table, if not then its converted to an ‘X’

>>> nebseq.translate('GCCAAG')
'XK'
>>> nebseq.translate('GCCAAG', partial=True)
'AK'

Or we can remove the first couple of bases for fuzzy coordinates.

>>> nebseq.translate('TTGCCAAG', start=2, partial=True)
'AK'

Modifications are specified as an (index, amino_acid) two-tuple. Notice that modification indexes are specified as one-based indexes into the amino acid sequence.

>>> nebseq.translate('ATGAAGGAA', modifications=[(2, 'U')])
'MUE'

Extraction

Sequence extraction is for when you want to slice out part of a larger sequence. This is useful if you use the nebgb module and its definition of locations parsed from strings like join(1..5,9..100).

>>> location = {'type': 'span', 'from': 4, 'to': 10}
>>> nebseq.extract('ACCGTACCATAGTT', location)
('GTACCAT', (False, False))
>>> location = {
...     "type": "complement",
...     "segment": {
...         "type": "join",
...         "segments": [
...             {"type": "span", "from": 3, "to": 8},
...             {"type": "span", "from": 10, "to": 14}
...         ]
...     }
... }
>>> nebseq.extract('ACCGTATTTCGGGGACAT', location)
('CCCCGAATACG', (False, False))

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

nebseq-0.0.1.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file nebseq-0.0.1.tar.gz.

File metadata

  • Download URL: nebseq-0.0.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nebseq-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2bf22bf3c861224e694935fecdffeab0067bef0a75ebc441cf534d84bbc20f14
MD5 4fc143ac6e2d8607ca2b55a4e0d322f0
BLAKE2b-256 6305165b8338107b0416f1bd643d7ae9aba1085604cafb44e48c6330197ef698

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page