bionode-sam
Advanced tools
Comparing version 0.0.3 to 0.0.4
35
cli.js
@@ -10,3 +10,2 @@ #!/usr/bin/env node | ||
console.log(command) | ||
// if (args.length === 0) { throw Error('Please specify command and files') } | ||
@@ -20,10 +19,30 @@ // else if (args.length === 1) { throw Error('Please provide a SRA file') } | ||
var samStream = sam(args) | ||
process.stdin.setEncoding('utf8'); | ||
samStream.on('data', function(data) { | ||
process.stdout.write(data[0]+' -> '+data[1]+'\n') | ||
}) | ||
if (!process.stdin.isTTY) { | ||
process.stdin.on('data', function(data) { | ||
var data = data.trim() | ||
if (data === '') { return } | ||
args.push(data.trim()) | ||
var samStream = sam(args) | ||
samStream.pipe(JSONstringify()).pipe(process.stdout) | ||
samStream.on('error', console.log) | ||
}) | ||
} | ||
samStream.on('error', function(error) { | ||
console.error(error) | ||
}) | ||
else { | ||
var samStream = sam(args) | ||
samStream.pipe(JSONstringify()).pipe(process.stdout) | ||
samStream.on('error', console.log) | ||
} | ||
function JSONstringify() { | ||
var stream = through.obj(transform) | ||
return stream | ||
function transform(obj, enc, next) { | ||
try { obj = JSON.stringify(obj) } | ||
catch(e) {} | ||
if (obj !== '') { this.push(obj + '\n') } | ||
next() | ||
} | ||
} |
@@ -37,6 +37,6 @@ var path = require('path') | ||
if (Arg1Ext === 'sam' && Arg2Ext === 'bam') { | ||
if (Arg1Ext === 'sam') { | ||
// sam to bam conversion | ||
// samtools view -bS -o aln.bam aln.sam | ||
console.log('sam -> bam') | ||
obj[1] = obj[1] || obj[0].replace('.sam', '.bam') | ||
multi = true | ||
@@ -58,2 +58,8 @@ var samToBam = spawn(samPath, [ 'view', '-bS', '-o', obj[1].replace('.bam', '.unsorted.bam'), obj[0] ]) | ||
else { | ||
var output = { | ||
sam: obj[0], | ||
bam: obj[1], | ||
operation: "sam -> bam" | ||
} | ||
self.push(output) | ||
next() | ||
@@ -102,3 +108,3 @@ } | ||
else if (obj[0].indexOf('.fa') !== -1 && Arg2Ext === 'bam' && Arg3Ext === 'bcf') { | ||
else if (obj[0].indexOf('.fna') !== -1 && Arg2Ext === 'bam' && Arg3Ext === 'bcf') { | ||
// bam to bcf conversion with reference | ||
@@ -105,0 +111,0 @@ // samtools mpileup -C50 -uf ref.fa aln.bam > aln.bcf |
{ | ||
"name": "bionode-sam", | ||
"description": "Node.js wrapper for samtools.", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"homepage": "http://github.com/bionode/bionode-sam", | ||
@@ -6,0 +6,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12713
188