Package libModelSimilarity :: Module fake_annotations
[hide private]
[frames] | no frames]

Source Code for Module libModelSimilarity.fake_annotations

 1  #!/usr/bin/env python 
 2   
3 -class ModelElementsAnnotations:
4 ''' 5 Represents all L{ElementAnnotations}s (each contains a list of L{Annotation}s) 6 functions that operate on multiple L{ElementAnnotations}s 7 '''
8 - def __init__(self,list_of_annotations):
9 ''' 10 Read the SBML file elements that could be annoated. 11 Elements are stored as L{ElementAnnotations}s 12 @param suppress_errors: 13 @type suppress_errors: bool 14 ''' 15 self._annotationElements = [ElementAnnotations(x) for x in list_of_annotations] 16 self.libsbml_model = None 17 self.libsbml_document = None
18
19 - def getElementAnnotations(self):
20 ''' 21 return a list of L{ElementAnnotations} that can contain MIRIAM annotations 22 @return: return all annotatable elements of the model 23 @rtype: [L{ElementAnnotations}] 24 ''' 25 return self._annotationElements
26
27 -class ElementAnnotations:
28 - def __init__(self, annotations):
29 self._annotations = annotations 30 self.libsbml_element = FakeLibsbmlElement(annotations[0].id) 31 self.type = 'species'
32 - def getAnnotations(self):
33 return self._annotations
34
35 -class FakeLibsbmlElement:
36 - def __init__(self,id,name=""):
37 self.id = id 38 self.name = name or id
39 - def getId(self):
40 return self.id
41 - def getName(self):
42 return self.name
43 - def getElementName(self):
44 return 'species'
45
46 -class Annotation:
47 - def __init__(self, db, id, qualifier):
48 self.db = db 49 self.id = id 50 self.qualifier = qualifier
51 52 if __name__ == "__main__": 53 import cluster 54 cluster.similarity_measure_version = 4 55 cluster.apply_caching = False 56 da=cluster.DatabaseAnnotation() 57 da.load_from_path("curated/") 58 ma = cluster.ModelAnnotation(ModelElementsAnnotations([[Annotation("ChEBI","CHEBI:17234","is")], 59 [Annotation("ChEBI","CHEBI:4170","is")], 60 [Annotation("ChEBI","CHEBI:28013","is")], 61 [Annotation("ChEBI","CHEBI:16108","is")], 62 [Annotation("KEGG Compound","C00197","is")], 63 [Annotation("KEGG Compound","C00031","is")] 64 ]),"current query") 65 ma = cluster.ModelAnnotation(ModelElementsAnnotations([[Annotation("KEGG Compound","C00002","is") 66 ]]),"current query") 67 print da.compare_model_annotation_object(ma) 68 #print da.compare_to_file("bmtest/BIOMD0000000211.xml") 69