Ejemplo n.º 1
0
 def update_synonyms(self, sa):  # SimpleAllele
     if 'OtherNameList' in sa:
         unifylistattribute(sa,
                            "OtherNameList",
                            "Name",
                            renamelistto='otherNames')
         for i, name in enumerate(sa['otherNames']):
             if isinstance(name, string_types):
                 sa['otherNames'][i] = {'#text': name}
Ejemplo n.º 2
0
 def update_entry(self, entry):
     del entry['id']
     num(entry, "protein_count", int)
     if 'abstract' in entry:
         import json
         entry['abstract'] = json.dumps(entry['abstract'])  # , indent=4)
     if 'taxonomy_distribution' in entry:
         unifylistattribute(entry, 'taxonomy_distribution', 'taxon_data')
         for i in entry['taxonomy_distribution']:
             num(i, "proteins_count", int)
Ejemplo n.º 3
0
 def update_simpleallele(self, sa):
     self.update_synonyms(sa)
     self.update_comment(sa)
     unifylistattribute(sa,
                        "MolecularConsequenceList",
                        "MolecularConsequence",
                        renamelistto='molecularConsequence')
     if 'molecularConsequence' in sa:
         self.update_comment(sa['molecularConsequence'])
     if 'FunctionalConsequence' in sa:
         self.update_comment(sa['FunctionalConsequence'])
     num(sa, 'AlleleID')
     num(sa, 'VariationID')
Ejemplo n.º 4
0
    def update_entry(self, entry):  # ClinVar Variation Archive entry
        if 'InterpretedRecord' in entry:
            ir = entry['InterpretedRecord']
            if 'SimpleAllele' in ir:
                self.update_simpleallele(ir['SimpleAllele'])
            if 'RCVList' in ir:
                unifylistattribute(ir,
                                   "RCVList",
                                   "RCVAccession",
                                   renamelistto='rcv')
                for i, rcvacc in enumerate(ir['rcv']):
                    if isinstance(rcvacc, string_types):
                        ir['rcv'][i] = {'#text': rcvacc}
                    else:
                        unifylistattribute(rcvacc,
                                           "InterpretedConditionList",
                                           "InterpretedCondition",
                                           renamelistto='interpretedCondition')
                        for j, ic in enumerate(rcvacc['interpretedCondition']):
                            if isinstance(ic, string_types):
                                rcvacc['interpretedCondition'][j] = {
                                    '#text': ic
                                }
            unifylistattribute(ir,
                               "ClinicalAssertionList",
                               "ClinicalAssertion",
                               renamelistto='clinicalAssertion')
            for ca in ir['clinicalAssertion']:
                num(ca, 'ID')
                if "Interpretation" in ca:
                    self.update_date(ca)
                    self.update_comment(ca['Interpretation'])

                unifylistattribute(ca,
                                   "ObservedInList",
                                   "ObservedIn",
                                   renamelistto='observedIn')
                if 'SimpleAllele' in ca:
                    sa = ca['SimpleAllele']
                    self.update_simpleallele(sa)

                if 'Genotype' in ca:
                    self.update_genotype_haplotype(ca['Genotype'])
                if 'Haplotype' in ca:
                    self.update_genotype_haplotype(ca['Haplotype'])
                if 'TraitSet' in ca:
                    self.update_comment(ca['TraitSet'])

                self.update_comment(ca)
                for o in ca['observedIn']:
                    self.update_comment(o)
                    if not isinstance(o['Sample']['Species'], string_types):
                        o['Sample']['Species'] = o['Sample']['Species'][
                            '#text']
                    if 'TraitSet' in o:
                        self.update_comment(o['TraitSet'])
                    if 'ObservedData' in o:
                        self.update_comment(o['ObservedData'])
                    if 'Method' in o and 'ObsMethodAttribute' in o['Method']:
                        self.update_comment(o['Method']['ObsMethodAttribute'])