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

« back to all changes in this revision

Viewing changes to cogent/core/entity.py

  • 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:
12
12
but are temporary and are outside the parent-children axes.
13
13
"""
14
14
 
15
 
 
 
15
import cogent
 
16
from cogent.core.annotation import SimpleVariable
16
17
from numpy import (sqrt, arctan2, power, array, mean, sum)
17
18
from cogent.data.protein_properties import AA_NAMES, AA_ATOM_BACKBONE_ORDER, \
18
19
                                   AA_ATOM_REMOTE_ORDER, AREAIMOL_VDW_RADII, \
19
 
                                   DEFAULT_AREAIMOL_VDW_RADIUS
 
20
                                   DEFAULT_AREAIMOL_VDW_RADIUS, AA_NAMES_3to1
20
21
from cogent.data.ligand_properties import HOH_NAMES, LIGAND_AREAIMOL_VDW_RADII
21
22
from operator import itemgetter, gt, ge, lt, le, eq, ne, or_, and_, contains, \
22
23
                                                                 is_, is_not
28
29
__copyright__ = "Copyright 2009, The Cogent Project"
29
30
__credits__ = ["Marcin Cieslik"]
30
31
__license__ = "GPL"
31
 
__version__ = "1.4.1"
 
32
__version__ = "1.5.0"
32
33
__maintainer__ = "Marcin Cieslik"
33
34
__email__ = "mpc4p@virginia.edu"
34
35
__status__ = "Development"
587
588
            for child in self.itervalues():
588
589
                child.propagateData(function, level, attr, **kwargs)
589
590
        datas = self.getData(attr, **kwargs)
 
591
        if isinstance(function, basestring):
 
592
             function = eval(function)        
590
593
        transformed_datas = function(datas)
591
594
        if kwargs.get('xtra'):
592
595
            self.xtra[attr] = transformed_datas
803
806
        """Calculate residue frequency (based on ``name``)."""
804
807
        return self.freqChildren('name')
805
808
 
 
809
    def getSeq(self, moltype ='PROTEIN'):
 
810
        """Returns a Sequence object from the ordered residues.
 
811
        The "seq_type" determines allowed residue names."""
 
812
        if moltype == 'PROTEIN':
 
813
            valid_names = AA_NAMES
 
814
            moltype = cogent.PROTEIN
 
815
        elif moltype == 'DNA':
 
816
            raise NotImplementedError('The sequence type: %s is not implemented' % moltype)
 
817
        elif moltype == 'RNA':
 
818
            raise NotImplementedError('The sequence type: %s is not implemented' % moltype)
 
819
        else:
 
820
            raise ValueError('The \'seq_type\' is not supported.')
 
821
        aa = ResidueHolder('aa', self.selectChildren(valid_names, contains, 'name'))
 
822
        aa_noic = ResidueHolder('noic', aa.selectChildren(' ', eq, 'res_ic'))
 
823
        
 
824
        raw_seq = []
 
825
        full_ids = []
 
826
        for res in aa_noic.sortedvalues():
 
827
            raw_seq.append(AA_NAMES_3to1[res.name])
 
828
            full_ids.append(res.getFull_id()[1:]) 
 
829
        raw_seq = "".join(raw_seq)
 
830
        
 
831
        seq = cogent.Sequence(moltype, raw_seq, self.getName())
 
832
        seq.addAnnotation(SimpleVariable, 'entity_id', 'S_id', full_ids)
 
833
        return seq
 
834
 
806
835
    def getDict(self):
807
836
        """See: ``Entity.getDict``."""
808
837
        from_parent = self.parent.getDict()