~ubuntu-branches/ubuntu/natty/python-cogent/natty

« back to all changes in this revision

Viewing changes to doc/cookbook/genetic_code.rst

  • Committer: Bazaar Package Importer
  • Author(s): Steffen Moeller
  • Date: 2010-12-04 22:30:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101204223035-j11kinhcrrdgg2p2
Tags: 1.5-1
* Bumped standard to 3.9.1, no changes required.
* New upstream version.
  - major additions to Cookbook
  - added AlleleFreqs attribute to ensembl Variation objects.
  - added getGeneByStableId method to genome objects.
  - added Introns attribute to Transcript objects and an Intron class.
  - added Mann-Whitney test and a Monte-Carlo version
  - exploratory and confirmatory period estimation techniques (suitable for
    symbolic and continuous data)
  - Information theoretic measures (AIC and BIC) added
  - drawing of trees with collapsed nodes
  - progress display indicator support for terminal and GUI apps
  - added parser for illumina HiSeq2000 and GAiix sequence files as 
    cogent.parse.illumina_sequence.MinimalIlluminaSequenceParser.
  - added parser to FASTQ files, one of the output options for illumina's
    workflow, also added cookbook demo.
  - added functionality for parsing of SFF files without the Roche tools in
    cogent.parse.binary_sff
  - thousand fold performance improvement to nmds
  - >10-fold performance improvements to some Table operations

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Getting a genetic code
 
2
----------------------
 
3
 
 
4
The standard genetic code.
 
5
 
 
6
.. doctest::
 
7
    
 
8
    >>> from cogent.core.genetic_code import GeneticCodes
 
9
    >>> standard_code = GeneticCodes[1]
 
10
 
 
11
The vertebrate mt genetic code.
 
12
 
 
13
.. doctest::
 
14
    
 
15
    >>> from cogent.core.genetic_code import GeneticCodes
 
16
    >>> mt_gc = GeneticCodes[2]
 
17
    >>> print mt_gc.Name
 
18
    Vertebrate Mitochondrial
 
19
 
 
20
To see the key -> genetic code mapping, use a loop.
 
21
 
 
22
.. doctest::
 
23
    
 
24
    >>> for key, code in GeneticCodes.items():
 
25
    ...     print key, code.Name
 
26
    1 Standard Nuclear
 
27
    2 Vertebrate Mitochondrial
 
28
    3 Yeast Mitochondrial...
 
29
 
1
30
Translate DNA sequences
2
31
-----------------------
3
32
 
7
36
    >>> standard_code.translate('TTTGCAAAC')
8
37
    'FAN'
9
38
 
10
 
Conversion to a ``ProteinSequence`` from a ``DnaSequence`` is shown here :ref:`translation`.
 
39
Conversion to a ``ProteinSequence`` from a ``DnaSequence`` is shown in :ref:`translation`.
11
40
 
12
41
Translate a codon
13
42
-----------------
70
99
Obtaining the codons from a ``DnaSequence`` object
71
100
--------------------------------------------------
72
101
 
73
 
Use the method ``getInMotifSize()``
 
102
Use the method ``getInMotifSize``
74
103
 
75
104
.. doctest::
76
105
 
77
106
    >>> from cogent import LoadSeqs,DNA
78
 
    >>> from cogent.core.alphabet import AlphabetError
79
107
    >>> my_seq = DNA.makeSequence('ATGCACTGGTAA','my_gene')
80
108
    >>> codons = my_seq.getInMotifSize(3)
81
109
    >>> print codons
82
110
    ['ATG', 'CAC', 'TGG', 'TAA']
83
 
    >>> try:
84
 
    ...     pep = my_seq.getTranslation()
85
 
    ... except AlphabetError as e:
86
 
    ...     print 'AlphabetError', e
87
 
    ...
88
 
    AlphabetError TAA
 
111
 
 
112
You can't translate a sequence that contains a stop codon.
 
113
 
 
114
.. doctest::
 
115
    
 
116
    >>> pep = my_seq.getTranslation()
 
117
    Traceback (most recent call last):
 
118
    AlphabetError: TAA
89
119
 
90
120
Remove the stop codon first
91
121
^^^^^^^^^^^^^^^^^^^^^^^^^^^
108
138
.. doctest::
109
139
 
110
140
    >>> from cogent import LoadSeqs,DNA
111
 
    >>> from cogent.core.alphabet import AlphabetError
112
 
    >>> my_seq = DNA.makeSequence('ATGCACTGGTAA','my_gene')
 
141
    >>> my_seq = DNA.makeSequence('CAAATGTATTAA','my_gene')
113
142
    >>> pep = my_seq[:-3].getTranslation().toFasta()
114
143
    >>> print pep
115
144
    >my_gene
116
 
    MHW
 
145
    QMY
117
146