Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.

Commit

Permalink
Updated per-read report.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipos committed Nov 14, 2019
1 parent 86b1e1d commit f998fe4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions scripts/cdna_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,21 @@ def _update_stats(st, d_fh, segments, hits, usable_len, read):
st["Classification"]["Unclassified"] += 1
st["UnclassHitNr"][len(hits)] += 1
if d_fh is not None:
d_fh.write("{}\t{}\t{}\t{}\t{}\n".format(read.Id, ".", ".", ".", "."))
d_fh.write("{}\t{}\t0\t{}\t{}\t{}\n".format(read.Id, len(read.Seq), -1, -1, "."))
elif len(segments) == 1:
st["Classification"]["Classified"] += 1
st["Strand"][segments[0].Strand] += 1
st["Unusable"][int(segments[0].Len / len(read.Seq) * 100)] += 1
if d_fh is not None:
rs = segments[0]
sr_id = "{}:{}|{}".format(rs.Start, rs.End, read.Id)
d_fh.write("{}\t{}\t{}\t{}\t{}\n".format(read.Id, sr_id, rs.Start, rs.End, rs.Strand))
d_fh.write("{}\t{}\t1\t{}\t{}\t{}\n".format(read.Id, len(read.Seq), rs.Start, rs.End, rs.Strand))
else:
for rs in segments:
st["Classification"]["Rescue"] += 1
st["RescueStrand"][rs.Strand] += 1
st["RescueHitNr"][len(hits)] += 1
if d_fh is not None:
sr_id = "{}:{}|{}".format(rs.Start, rs.End, read.Id)
d_fh.write("{}\t{}\t{}\t{}\t{}\n".format(read.Id, sr_id, rs.Start, rs.End, rs.Strand))
d_fh.write("{}\t{}\t{}\t{}\t{}\t{}\n".format(read.Id, len(read.Seq), len(segments), rs.Start, rs.End, rs.Strand))
st["Unusable"][len(read.Seq) - int(sum([s.Len for s in segments]))] += 1
st["RescueSegmentNr"][len(segments)] += 1

Expand Down Expand Up @@ -228,7 +226,7 @@ def _plot_stats(st, pdf):
d_fh = None
if args.D is not None:
d_fh = open(args.D, "w")
d_fh.write("Read\tSegment\tStart\tEnd\tStrand\n")
d_fh.write("Read\tLength\tClassified\tStart\tEnd\tStrand\n")

st = _new_stats()
input_size = None
Expand Down

0 comments on commit f998fe4

Please sign in to comment.