Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions misc/paftools.js
Original file line number Diff line number Diff line change
Expand Up @@ -2405,6 +2405,52 @@ function paf_pbsim2fq(args)
buf2.destroy();
}

function paf_badread2fa(args)
{
if (args.length < 2) {
print("Usage: paftools.js badread2fa <ref.fa.fai> <badread.fq>");
exit(1);
}

var len = {}, file, buf = new Bytes();
file = new File(args[0]);
while (file.readline(buf) >= 0) {
var t = buf.toString().split("\t");
len[t[0]] = parseInt(t[1]);
}
file.close();

var id = 0, n_discard = 0;
file = new File(args[1]);
while (file.readline(buf) >= 0) {
var line = buf.toString();
var m, a = null, is_fq = line[0] == '@'? true : false;
if (!/\schimera\s/.test(line) && (m = /\s(\S+),([+-])strand,(\d+)-(\d+)/.exec(line)) != null) {
if (len[m[1]] == null) throw Error("failed to find the contig length of " + m[1]);
m[3] = parseInt(m[3]);
m[4] = parseInt(m[4]);
if (m[2] == '+')
a = [ "S" + (id+1), m[1], m[3], m[4], m[2] ];
else
a = [ "S" + (id+1), m[1], len[m[1]] - m[4], len[m[1]] - m[3], m[2] ];
}
file.readline(buf);
var seq = buf.toString();
if (is_fq) {
file.readline(buf);
file.readline(buf);
}
if (a != null) {
print(">" + a.join("!"));
print(seq);
} else ++n_discard;
++id;
}
file.close();
buf.destroy();
warn("WARNING: discarded " + n_discard + " reads");
}

function paf_junceval(args)
{
var c, l_fuzzy = 0, print_ovlp = false, print_err_only = false, first_only = false, chr_only = false, aa = false, is_bed = false;
Expand Down Expand Up @@ -3704,6 +3750,7 @@ function main(args)
print(" pafcmp compare two PAF files");
print(" mason2fq convert mason2-simulated SAM to FASTQ");
print(" pbsim2fq convert PBSIM-simulated MAF to FASTQ");
print(" badread2fa convert Baderead FASTQ to FASTA");
print(" junceval evaluate splice junction consistency with known annotations");
print(" exoneval evaluate exon-level consistency with known annotations");
print(" ov-eval evaluate read overlap sensitivity using read-to-ref mapping");
Expand All @@ -3729,6 +3776,7 @@ function main(args)
else if (cmd == 'bedcov') paf_bedcov(args);
else if (cmd == 'mason2fq') paf_mason2fq(args);
else if (cmd == 'pbsim2fq') paf_pbsim2fq(args);
else if (cmd == 'badread2fa') paf_badread2fa(args);
else if (cmd == 'junceval') paf_junceval(args);
else if (cmd == 'exoneval') paf_exoneval(args);
else if (cmd == 'ov-eval') paf_ov_eval(args);
Expand Down
Loading