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

« back to all changes in this revision

Viewing changes to doc/cookbook/alphabet.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
Alphabets
 
2
---------
 
3
 
 
4
.. authors Gavin Huttley
 
5
 
 
6
``Alphabet`` and ``MolType``
 
7
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
8
 
 
9
``MolType`` instances have an ``Alphabet``.
 
10
 
 
11
.. doctest::
 
12
    
 
13
    >>> from cogent import DNA, PROTEIN
 
14
    >>> print DNA.Alphabet
 
15
    ('T', 'C', 'A', 'G')
 
16
    >>> print PROTEIN.Alphabet
 
17
    ('A', 'C', 'D', 'E', ...
 
18
 
 
19
``Alphabet`` instances have a ``MolType``.
 
20
 
 
21
.. doctest::
 
22
    
 
23
    >>> PROTEIN.Alphabet.MolType == PROTEIN
 
24
    True
 
25
 
 
26
Creating tuple alphabets
 
27
^^^^^^^^^^^^^^^^^^^^^^^^
 
28
 
 
29
You can create a tuple alphabet of, for example, dinucleotides or trinucleotides.
 
30
 
 
31
.. doctest::
 
32
    
 
33
    >>> dinuc_alphabet = DNA.Alphabet.getWordAlphabet(2)
 
34
    >>> print dinuc_alphabet
 
35
    ('TT', 'CT', 'AT', 'GT', ...
 
36
    >>> trinuc_alphabet = DNA.Alphabet.getWordAlphabet(3)
 
37
    >>> print trinuc_alphabet
 
38
    ('TTT', 'CTT', 'ATT', ...
 
39
 
 
40
Convert a sequence into integers
 
41
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
42
 
 
43
.. doctest::
 
44
    
 
45
    >>> seq = 'TAGT'
 
46
    >>> indices = DNA.Alphabet.toIndices(seq)
 
47
    >>> indices
 
48
    [0, 2, 3, 0]
 
49
 
 
50
Convert integers to a sequence
 
51
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
52
 
 
53
.. doctest::
 
54
    
 
55
    >>> seq = DNA.Alphabet.fromIndices([0,2,3,0])
 
56
    >>> seq
 
57
    ['T', 'A', 'G', 'T']
 
58
 
 
59
or
 
60
 
 
61
.. doctest::
 
62
    
 
63
    >>> seq = DNA.Alphabet.fromOrdinalsToSequence([0,2,3,0])
 
64
    >>> seq
 
65
    DnaSequence(TAGT)