Esempio n. 1
0
 def test_structure_normalization(self):
     gen = read('mzid_snippet.xml').iterfind("SpectraData")
     datum = next(gen)
     index = aux.cvquery(datum)
     assert index['MS:1000768'] == 'Thermo nativeID format'
     datum = next(gen)
     index = aux.cvquery(datum)
     assert index['MS:1000774'] == 'multiple peak list nativeID format'
Esempio n. 2
0
    def test_cv_query(self):
        with MzML(self.path) as handle:
            scan = next(handle)
            index = aux.cvquery(scan)
            self.assertEqual(index['MS:1000511'], 1)
            self.assertEqual(aux.cvquery(scan, "MS:1000511"), 1)

            # test deep traversal
            self.assertEqual(index['MS:1000016'], 0.004935)
            self.assertEqual(aux.cvquery(scan, 'MS:1000016'), 0.004935)
Esempio n. 3
0
 def format_tolerance(self, tol, tp):
     if not tol:
         return None
     term_dict = cvquery(tol)
     value = term_dict.get('MS:1001413')
     low = {
         "accession": 'MS:1001413',
         "value": value,
         'unit_name': getattr(value, 'unit_info', None)
     }
     value = term_dict.get('MS:1001412')
     high = {
         "accession": 'MS:1001412',
         "value": value,
         'unit_name': getattr(value, 'unit_info', None)
     }
     return tp(low, high)
Esempio n. 4
0
    def format_search_modification(self, mod):
        temp = dict(mod)
        d = dict()
        d['fixed'] = temp.pop("fixedMod", False)
        d['mass_delta'] = temp.pop("massDelta")
        d['specificity'] = temp.pop('SpecificityRules', [])
        d['residues'] = temp.pop("residues")
        term_dict = cvquery(temp)
        crosslinking_donor_or_receiver = None
        has_identity = False
        params = []
        d['params'] = params

        for key, value in list(term_dict.items()):
            term = self.writer.term(key)
            if term.is_of_type('UNIMOD:0'):
                d['name'] = term.name
                has_identity = True
                term_dict.pop(key)
            elif term.is_of_type("MS:1001460"):
                d['name'] = value
                d['accession'] = "MS:1001460"
                term_dict.pop(key)
                has_identity = True
            # crosslinking donor
            elif term.is_of_type("MS:1002508"):
                crosslinking_donor_or_receiver = {
                    "name": term.name,
                    'accession': term.id,
                    'value': int(value)
                }
                term_dict.pop(key)
            elif term.is_of_type("XLMOD:00001") or term.is_of_type(
                    "XLMOD:00002"):
                d['name'] = term.name
                has_identity = True
                term_dict.pop(key)

        if not has_identity and crosslinking_donor_or_receiver:
            d.update(crosslinking_donor_or_receiver)
        elif crosslinking_donor_or_receiver:
            params.append(crosslinking_donor_or_receiver)
        # return d
        return self.writer.SearchModification.ensure(d)
Esempio n. 5
0
    def format_modification(self, mod):
        temp = dict(mod)
        d = dict()
        d['location'] = temp.pop("location", None)
        d['monoisotopic_mass_delta'] = temp.pop("monoisotopicMassDelta", None)
        d['avg_mass_delta'] = temp.pop("avgMassDelta", None)
        d['residues'] = temp.pop("residues", None)
        term_dict = cvquery(temp)
        crosslinking_donor_or_receiver = None
        has_identity = False
        params = []
        d['params'] = params

        for key, value in list(term_dict.items()):
            term = self.writer.term(key)
            if term.is_of_type('UNIMOD:0'):
                d['name'] = term.name
                has_identity = True
                term_dict.pop(key)
            elif term.is_of_type("MS:1001460"):
                d['name'] = value
                d['accession'] = "MS:1001460"
                term_dict.pop(key)
                has_identity = True
            # crosslinking donor
            elif term.is_of_type("MS:1002508"):
                crosslinking_donor_or_receiver = {
                    "name": term.name,
                    'accession': term.id,
                    'value': int(value)
                }
                term_dict.pop(key)
            elif term.is_of_type("XLMOD:00001") or term.is_of_type(
                    "XLMOD:00002"):
                d['name'] = term.name
                has_identity = True
                term_dict.pop(key)

        if not has_identity and crosslinking_donor_or_receiver:
            d.update(crosslinking_donor_or_receiver)
        elif crosslinking_donor_or_receiver:
            params.append(crosslinking_donor_or_receiver)
        return self.writer.Modification.ensure(d)