mirror of
https://github.com/lh3/minimap2.git
synced 2026-10-05 01:08:11 +08:00
reverted to the previous paftools.js
This commit is contained in:
+15
-11
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env k8
|
#!/usr/bin/env k8
|
||||||
|
|
||||||
var paftools_version = '2.26-r1180-dirty';
|
var paftools_version = '2.26-r1175';
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
***** Library functions *****
|
***** Library functions *****
|
||||||
@@ -133,35 +133,38 @@ Interval.find_ovlp = function(a, st, en)
|
|||||||
|
|
||||||
function fasta_read(fn)
|
function fasta_read(fn)
|
||||||
{
|
{
|
||||||
var h = {};
|
var h = {}, gt = '>'.charCodeAt(0);
|
||||||
var file = fn == '-'? new File() : new File(fn);
|
var file = fn == '-'? new File() : new File(fn);
|
||||||
var buf = new Bytes(), seq = null, name = null, seqlen = [];
|
var buf = new Bytes(), seq = null, name = null, seqlen = [];
|
||||||
while (file.readline(buf) >= 0) {
|
while (file.readline(buf) >= 0) {
|
||||||
var line = buf.toString();
|
if (buf[0] == gt) {
|
||||||
if (line[0] == '>') {
|
|
||||||
if (seq != null && name != null) {
|
if (seq != null && name != null) {
|
||||||
seqlen.push([name, seq.length]);
|
seqlen.push([name, seq.length]);
|
||||||
h[name] = seq.toString();
|
h[name] = seq;
|
||||||
seq.destroy();
|
|
||||||
name = seq = null;
|
name = seq = null;
|
||||||
}
|
}
|
||||||
var m;
|
var m, line = buf.toString();
|
||||||
if ((m = /^>(\S+)/.exec(line)) != null) {
|
if ((m = /^>(\S+)/.exec(line)) != null) {
|
||||||
name = m[1];
|
name = m[1];
|
||||||
seq = new Bytes();
|
seq = new Bytes();
|
||||||
}
|
}
|
||||||
} else seq.set(line);
|
} else seq.set(buf);
|
||||||
}
|
}
|
||||||
if (seq != null && name != null) {
|
if (seq != null && name != null) {
|
||||||
seqlen.push([name, seq.length]);
|
seqlen.push([name, seq.length]);
|
||||||
h[name] = seq.toString();
|
h[name] = seq;
|
||||||
seq.destroy();
|
|
||||||
}
|
}
|
||||||
buf.destroy();
|
buf.destroy();
|
||||||
file.close();
|
file.close();
|
||||||
return [h, seqlen];
|
return [h, seqlen];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fasta_free(fa)
|
||||||
|
{
|
||||||
|
for (var name in fa)
|
||||||
|
fa[name].destroy();
|
||||||
|
}
|
||||||
|
|
||||||
Bytes.prototype.reverse = function()
|
Bytes.prototype.reverse = function()
|
||||||
{
|
{
|
||||||
for (var i = 0; i < this.length>>1; ++i) {
|
for (var i = 0; i < this.length>>1; ++i) {
|
||||||
@@ -376,7 +379,7 @@ function paf_call(args)
|
|||||||
} else if (o[1] > 0) { // shouldn't happen in theory
|
} else if (o[1] > 0) { // shouldn't happen in theory
|
||||||
if (fa[o[0]] == null) throw Error('sequence "' + o[0] + '" is absent from the reference FASTA');
|
if (fa[o[0]] == null) throw Error('sequence "' + o[0] + '" is absent from the reference FASTA');
|
||||||
if (o[1] >= fa[o[0]].length) throw Error('position ' + o[1] + ' exceeds the length of sequence "' + o[0] + '"');
|
if (o[1] >= fa[o[0]].length) throw Error('position ' + o[1] + ' exceeds the length of sequence "' + o[0] + '"');
|
||||||
var ref = fa[o[0]][o[1]-1].toUpperCase();
|
var ref = String.fromCharCode(fa[o[0]][o[1]-1]).toUpperCase();
|
||||||
if (o[5] == '-') // insertion
|
if (o[5] == '-') // insertion
|
||||||
v = [o[0], o[1], '.', ref, ref + o[6].toUpperCase()];
|
v = [o[0], o[1], '.', ref, ref + o[6].toUpperCase()];
|
||||||
else // deletion
|
else // deletion
|
||||||
@@ -557,6 +560,7 @@ function paf_call(args)
|
|||||||
|
|
||||||
buf.destroy();
|
buf.destroy();
|
||||||
file.close();
|
file.close();
|
||||||
|
if (fa != null) fasta_free(fa);
|
||||||
}
|
}
|
||||||
|
|
||||||
function paf_asmstat(args)
|
function paf_asmstat(args)
|
||||||
|
|||||||
Reference in New Issue
Block a user