def find_proteins(self, glycopeptide):
     out = []
     seq = strip_modifications(glycopeptide)
     for case in self.sequence_to_model:
         if seq in case:
             out.append(self.sequence_to_model[case])
     return out
Beispiel #2
0
 def _guess_sites_from_sequence(self, sequence):
     prot_seq = str(self.protein)
     query_seq = strip_modifications(sequence)
     try:
         start = prot_seq.index(query_seq)
         end = start + len(query_seq)
         return PeptideProteinRelation(start, end, self.protein.id,
                                       self.protein.hypothesis_id)
     except ValueError:
         return None
 def get_models(self, glycopeptide):
     out = []
     seq = strip_modifications(glycopeptide)
     if seq in self.peptide_to_protein:
         return list(self.peptide_to_protein[seq])
     pattern = re.compile(seq)
     for case in self.sequence_to_model:
         if seq in case:
             bounds = pattern.finditer(case)
             for match in bounds:
                 protein_model = self.sequence_to_model[case]
                 site_models = protein_model.find_sites_in(
                     match.start(), match.end())
                 out.append(site_models)
     self.peptide_to_protein[seq] = tuple(out)
     return out
Beispiel #4
0
def convert_to_peptide_dict(glycopeptide, id_tracker):
    data = {
        "id": glycopeptide.id,
        "peptide_sequence": parser.strip_modifications(glycopeptide),
        "modifications": []
    }

    i = 0
    # TODO: handle N-terminal and C-terminal modifications
    for pos, mods in glycopeptide:
        i += 1
        if not mods:
            continue
        else:
            mod = mods[0]
        if mod.rule.is_a("glycosylation"):
            mod_dict = {
                "monoisotopic_mass_delta":
                glycopeptide.glycan_composition.mass(),
                "location":
                i,
                "name":
                "unknown modification",
                "params": [
                    components.UserParam(name='GlycosylationType',
                                         value=str(mod)),
                    components.UserParam(name='GlycanComposition',
                                         value=str(
                                             glycopeptide.glycan_composition)),
                    components.UserParam(
                        name='Formula',
                        value=formula(glycopeptide.glycan_composition.
                                      total_composition()))
                ]
            }
            data['modifications'].append(mod_dict)
        else:
            mod_dict = {
                "monoisotopic_mass_delta": mod.mass,
                "location": i,
                "name": mod.name,
            }
            data['modifications'].append(mod_dict)
    return data
Beispiel #5
0
def convert_to_peptide_dict(glycopeptide, id_tracker):
    data = {
        "id": glycopeptide.id,
        "peptide_sequence": parser.strip_modifications(glycopeptide),
        "modifications": [

        ]
    }

    i = 0
    # TODO: handle N-terminal and C-terminal modifications
    for pos, mods in glycopeptide:
        i += 1
        if not mods:
            continue
        else:
            mod = mods[0]
        if mod.rule.is_a("glycosylation"):
            mod_dict = {
                "monoisotopic_mass_delta": glycopeptide.glycan_composition.mass(),
                "location": i,
                "name": "unknown modification",
                "params": [
                    components.UserParam(
                        name='GlycosylationType', value=str(mod)),
                    components.UserParam(name='GlycanComposition', value=str(
                        glycopeptide.glycan_composition)),
                    components.UserParam(name='Formula', value=formula(
                        glycopeptide.glycan_composition.total_composition()))
                ]
            }
            data['modifications'].append(mod_dict)
        else:
            mod_dict = {
                "monoisotopic_mass_delta": mod.mass,
                "location": i,
                "name": mod.name,
            }
            data['modifications'].append(mod_dict)
    return data
Beispiel #6
0
    def convert_to_peptide_dict(self, glycopeptide, id_tracker):
        data = {
            "id": glycopeptide.id,
            "peptide_sequence": parser.strip_modifications(glycopeptide),
            "modifications": []
        }

        i = 0
        # TODO: handle N-terminal and C-terminal modifications
        glycosylation_event_count = len(glycopeptide.convert().glycosylation_manager)
        glycosylation_events_handled = 0
        for _pos, mods in glycopeptide:
            i += 1
            if not mods:
                continue
            else:
                mod = mods[0]
            if mod.rule.is_a("glycosylation"):
                glycosylation_events_handled += 1
                is_aggregate_stub = False
                mod_params = [
                    glycosylation_type_to_term(
                        str(mod.rule.glycosylation_type))
                ]
                if mod.rule.is_core:

                    mod_params.extend(
                        self.gnome_resolver.glycan_composition_to_terms(glycopeptide.glycan_composition.clone()))

                    mass = glycopeptide.glycan_composition.mass()
                    if glycosylation_event_count == 1:
                        mod_params.append({
                            "name": "glycan composition",
                            "cvRef": "PSI-MS",
                            "accession": "MS:XXXX14"
                        })
                    else:
                        mod_params.append({
                            "name": "glycan aggregate",
                            "cvRef": "PSI-MS",
                            "accession": "MS:XXXX15"
                        })
                        if glycosylation_events_handled > 1:
                            mass = 0
                            is_aggregate_stub = True

                    if not is_aggregate_stub:
                        mod_params.append({
                            "accession": 'MS:1000864',
                            "cvRef": "PSI-MS",
                            "name": "chemical formula",
                            "value": formula(glycopeptide.glycan_composition.total_composition()),
                        })

                else:
                    mod_params.append({
                        "accession": 'MS:1000864',
                        "cvRef": "PSI-MS",
                        "name": "chemical formula",
                        "value": formula(mod.rule.composition),
                    })
                    if mod.rule.is_composition:
                        mod_params.extend(self.gnome_resolver.glycan_composition_to_terms(mod.rule.glycan.clone()))
                        mod_params.append({
                            "name": "glycan composition",
                            "cvRef": "PSI-MS",
                            "accession": "MS:XXXX14"
                        })
                    else:
                        mod_params.append({
                            "name": "glycan structure",
                            "cvRef": "PSI-MS",
                            "accession": "MS:XXXXXXX"
                        })
                    mass = mod.mass

                mod_dict = {
                    "monoisotopic_mass_delta": mass,
                    "location": i,
                    # "name": "unknown modification",
                    "name": "glycosylation modification",
                    "params": [components.CVParam(**x) for x in mod_params]
                }
                data['modifications'].append(mod_dict)
            else:
                mod_dict = {
                    "monoisotopic_mass_delta": mod.mass,
                    "location": i,
                    "name": mod.name,
                }
                data['modifications'].append(mod_dict)
        return data