MCPcopy Create free account
hub / github.com/BirolLab/abyss / toSAM

Function toSAM

Map/map.cc:206–242  ·  view source on GitHub ↗

Return a SAM record of the specified match. */

Source from the content-addressed store, hash-verified

204
205/** Return a SAM record of the specified match. */
206static SAMRecord toSAM(const FastaIndex& faIndex,
207 const FMIndex& fmIndex, const Match& m, bool rc,
208 unsigned qlength)
209{
210 SAMRecord a;
211 if (m.size() == 0) {
212 // No hit.
213 a.rname = "*";
214 a.pos = -1;
215 a.flag = SAMAlignment::FUNMAP;
216 a.mapq = 0;
217 a.cigar = "*";
218 } else {
219 FastaIndex::SeqPos seqPos = faIndex[fmIndex[m.l]];
220 a.rname = seqPos.get<0>().id;
221 a.pos = seqPos.get<1>();
222 a.flag = rc ? SAMAlignment::FREVERSE : 0;
223
224 // Set the mapq to the alignment score.
225 assert(m.qstart < m.qend);
226 unsigned matches = m.qend - m.qstart;
227 assert (m.num != 0);
228 a.mapq = m.size() > 1 || m.num > 1 ? 0 : min(matches, 254U);
229
230 ostringstream ss;
231 if (m.qstart > 0)
232 ss << m.qstart << 'S';
233 ss << matches << 'M';
234 if (m.qend < qlength)
235 ss << qlength - m.qend << 'S';
236 a.cigar = ss.str();
237 }
238 a.mrnm = "*";
239 a.mpos = -1;
240 a.isize = 0;
241 return a;
242}
243
244/** Return the position of the current contig. */
245static size_t getMyPos(const Match& m, const FastaIndex& faIndex,

Callers 1

findFunction · 0.85

Calls 2

sizeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected