pyEnsemblRest
 All Classes Namespaces Files Functions Variables Properties
compara.py
Go to the documentation of this file.
1 
2 def _tax_parent(self):
3  if '_parent' not in self.__dict__:
4  if not hasattr(self, '_id'):
5  print("'id' is not defined, cannot fetch the parent node")
6  return None
7  copy = self.server.getTaxonomyEntryByID(self.id)
8  self.__dict__['_parent'] = copy.__dict__['_parent']
9  return self.__dict__['_parent']
10 
11 def _tax_children(self):
12  if self.leaf:
13  return []
14  if '_children' not in self.__dict__:
15  if not hasattr(self, '_id'):
16  print("'id' is not defined, cannot fetch the parent node")
17  return []
18  copy = self.server.getTaxonomyEntryByID(self.id)
19  self.__dict__['_children'] = copy.__dict__['_children']
20  return self.__dict__['_children']
21 
22 
23 
24 from . import genome
25 from . import _pyrest_core
26 
28  """A node in the NCBI taxonomy"""
29 
30  parent = property(_tax_parent, None, None, """Parent node in the taxonomy""")
31 
32  children = property(_tax_children, None, None, """Child nodes in the taxonomy""")
33 
34  tags = property(_pyrest_core.fget("_tags"), None, None, """Additionnal tags""")
35 
36 NCBITaxon._construction_rules = {"children":NCBITaxon, "parent":NCBITaxon, "tags":None}
37 
39  """A leaf of a gene-tree, i.e. a protein / gene"""
40 
41  id = property(_pyrest_core.fget("_id"), None, None, """Protein / transcript identifier""")
42 
43  mol_seq = property(_pyrest_core.fget("_mol_seq"), None, None, """DNA / protein sequence""")
44 
45 GeneTreeMember._construction_rules = {"id":genome.Identifier, "mol_seq":genome.Sequence}
46 
48  """The evolutionary event that took place at this node of the tree"""
49 
50 class GeneTreeNode(_pyrest_core.BaseObject):
51  """Node in a gene-tree"""
52 
53  taxonomy = property(_pyrest_core.fget("_taxonomy"), None, None, """Taxonomy annotation of this node""")
54 
55  children = property(_pyrest_core.fget("_children"), None, None, """Child nodes in the gene-tree""")
56 
57  confidence = property(_pyrest_core.fget("_confidence"), None, None, """The confidence tags attached to a given gene-tree node""")
58 
59  id = property(_pyrest_core.fget("_id"), None, None, """Gene identifier (only for leaves)""")
60 
61  events = property(_pyrest_core.fget("_events"), None, None, """The evolutionary event that took place at this node""")
62 
63  sequence = property(_pyrest_core.fget("_sequence"), None, None, """GeneTreeMember (only for leaves)""")
64 
65 GeneTreeNode._construction_rules = {"children":GeneTreeNode, "confidence":None, "events":GeneTreeEvent, "id":genome.Identifier, "sequence":GeneTreeMember, "taxonomy":NCBITaxon}
66 
68  """Global object for gene-trees"""
69 
70  tree = property(_pyrest_core.fget("_tree"), None, None, """root node""")
71 
72  id = property(_pyrest_core.fget("_id"), None, None, """GeneTree stable identifier""")
73 
74 GeneTree._construction_rules = {"tree":GeneTreeNode}
75 
77  """"""
78 
79 class Homolog(_pyrest_core.BaseObject):
80  """"""
81 
82 class HomologyPair(_pyrest_core.BaseObject):
83  """Homology pair"""
84 
85  target = property(_pyrest_core.fget("_target"), None, None, """Paralog of the query gene / Ortholog in the other species""")
86 
87  source = property(_pyrest_core.fget("_source"), None, None, """Query gene""")
88 
89 HomologyPair._construction_rules = {"source":Homolog, "target":Homolog}
90 
92  """Group of multiple homology-pairs"""
93 
94  homologies = property(_pyrest_core.fget("_homologies"), None, None, """All the homology pairs""")
95 
96 HomologyGroup._construction_rules = {"homologies":HomologyPair}
97 
99  """"""
100 
101 class GenomicAlignment(_pyrest_core.BaseObject):
102  """"""
104  alignments = property(_pyrest_core.fget("_alignments"), None, None, """All the alignment-bloks for this query region""")
105 
106 GenomicAlignment._construction_rules = {"alignments":GenomicAlignmentEntry}
107 
108 
110  """
111  Get all the leaves under this node
112  """
113  if '_children' not in self.__dict__:
114  return [self]
115  l = []
116  for n in self.children:
117  l.extend(n.get_all_leaves())
118  return l
119 
120 setattr(GeneTreeNode, 'get_all_leaves', _gtn_get_all_leaves)
121 
122 def _gtn_get_all_nodes(self):
123  """
124  Get all the nodes in this sub-tree, including the root
125  """
126  if '_children' not in self.__dict__:
127  return [self]
128  l = [self]
129  for n in self.children:
130  l.extend(n.get_all_nodes())
131  return l
132 
133 setattr(GeneTreeNode, 'get_all_nodes', _gtn_get_all_nodes)
134 
135 def _gt_get_all_leaves(self):
136  """
137  Get all the leaves in this tree
138  """
139  return self.tree.get_all_leaves()
140 
141 setattr(GeneTree, 'get_all_leaves', _gt_get_all_leaves)
142 
143 def _gt_get_all_nodes(self):
144  """
145  Get all the nodes in this tree
146  """
147  return self.tree.get_all_nodes()
148 
149 setattr(GeneTree, 'get_all_nodes', _gt_get_all_nodes)
150 
151 
Group of multiple homology-pairs.
Definition: compara.py:101
def _gtn_get_all_nodes
Get all the nodes in this sub-tree, including the root.
Definition: compara.py:138
def _gtn_get_all_leaves
Get all the leaves under this node.
Definition: compara.py:124
A node in the NCBI taxonomy.
Definition: compara.py:29
def _gt_get_all_leaves
Get all the leaves in this tree.
Definition: compara.py:152
def _tax_children
Definition: compara.py:11
def _tax_parent
Definition: compara.py:2
def _gt_get_all_nodes
Get all the nodes in this tree.
Definition: compara.py:161
Global object for gene-trees.
Definition: compara.py:73
The evolutionary event that took place at this node of the tree.
Definition: compara.py:51
A leaf of a gene-tree, i.e.
Definition: compara.py:41