MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / startElement

Method startElement

src/openms/source/FORMAT/XTandemXMLFile.cpp:86–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 }
85
86 void XTandemXMLFile::startElement(const XMLCh* const /*uri*/, const XMLCh* const /*local_name*/, const XMLCh* const qname, const Attributes& attributes)
87 {
88 tag_ = String(sm_.convert(qname));
89
90 if (tag_ == "domain")
91 {
92 String id_string = attributeAsString_(attributes, "id");
93 UInt id = id_string.prefix('.').toInt();
94 current_id_ = id;
95
96 PeptideEvidence pe;
97 // get amino acid before
98 String pre = attributeAsString_(attributes, "pre");
99 if (!pre.empty())
100 {
101 pe.setAABefore(pre[pre.size()-1]);
102 }
103 // get amino acid after
104 String post = attributeAsString_(attributes, "post");
105 if (!post.empty())
106 {
107 pe.setAAAfter(post[0]);
108 }
109
110 current_start_ = attributeAsInt_(attributes, "start");
111 pe.setStart(current_start_ - 1);
112 current_stop_ = attributeAsInt_(attributes, "end");
113 pe.setEnd(current_stop_ - 1);
114
115 pe.setProteinAccession(current_protein_);
116
117 String seq = attributeAsString_(attributes, "seq");
118 // is this the same peptide as before, just in a different protein (scores will be the same)?
119 if ((peptide_hits_.find(id) == peptide_hits_.end()) || (seq != previous_seq_))
120 {
121 PeptideHit hit;
122 // can't parse sequences permissively because that would skip characters
123 // that X! Tandem includes when calculating e.g. modification positions,
124 // potentially leading to errors when assigning mods to residues:
125 hit.setSequence(AASequence::fromString(seq, false));
126 hit.setCharge(current_charge_);
127
128 // get scores etc.:
129 hit.setMetaValue("nextscore", attributeAsDouble_(attributes, "nextscore"));
130 hit.setMetaValue("delta", attributeAsDouble_(attributes, "delta"));
131 hit.setMetaValue("mass", attributeAsDouble_(attributes, "mh")); // note the different names
132 hit.setMetaValue("E-Value", attributeAsDouble_(attributes, "expect")); // note the different names
133 double hyperscore = attributeAsDouble_(attributes, "hyperscore");
134 hit.setMetaValue("hyperscore", hyperscore);
135 hit.setScore(hyperscore);
136
137 // try to get a, b, c, x, y, z score (optional)
138 String ions = "abcxyz";
139 String ion_score = " _score";
140 String ion_count = " _ions";
141 for (String::iterator it = ions.begin(); it != ions.end(); ++it)
142 {
143 ion_score[0] = *it;

Callers

nothing calls this directly

Calls 15

attributeAsString_Function · 0.85
attributeAsInt_Function · 0.85
attributeAsDouble_Function · 0.85
optionalAttributeAsUInt_Function · 0.85
getInstanceFunction · 0.85
toIntMethod · 0.80
prefixMethod · 0.80
setAABeforeMethod · 0.80
setAAAfterMethod · 0.80
setStartMethod · 0.80

Tested by

no test coverage detected