-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from daviortega/f-get-fasta-from-stable-id
getFasta
- Loading branch information
Showing
5 changed files
with
812 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env node | ||
'use strict' | ||
const shell = require('shelljs') | ||
const path = require('path') | ||
const figlet = require('figlet') | ||
const chalk = require('chalk') | ||
|
||
const args = process.argv.slice(2).join(' ') | ||
const script = path.resolve(__dirname, '../cli-scripts/getFasta.js') | ||
const path2bunyan = path.resolve(__dirname, '..', 'node_modules/.bin/bunyan') | ||
|
||
const splash = figlet.textSync('bitkJS-getFasta', {horizontalLayout: 'fitted'}) | ||
console.log(chalk.cyan(splash)) | ||
console.log(chalk.red('\t\t\t\t\t\t\t by Davi Ortega')) | ||
|
||
shell.exec('node ' + script + ' ' + args + ' | ' + path2bunyan + ' --color') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env node | ||
'use strict' | ||
|
||
let path = require('path'), | ||
ArgumentParser = require('argparse').ArgumentParser, | ||
getFasta = require('../src/getFastaFromStableIds'), | ||
fs = require('fs') | ||
|
||
let parser = new ArgumentParser({ | ||
addHelp: true, | ||
description: 'Makes FASTA file from MiST3 stableID' | ||
}) | ||
|
||
parser.addArgument( | ||
'input', | ||
{ | ||
help: 'Text file with stable IDs. One per line' | ||
} | ||
) | ||
parser.addArgument( | ||
['-o', '--output'], | ||
{ | ||
help: 'name of the output file', | ||
defaultValue: 'bitk3.fa' | ||
} | ||
) | ||
|
||
parser.addArgument( | ||
['--skipBad'], | ||
{ | ||
help: 'Skip bad stable Ids', | ||
defaultValue: false, | ||
nargs: 0 | ||
} | ||
) | ||
|
||
let args = parser.parseArgs() | ||
|
||
if (args.output === 'bitk3.fa') | ||
args.output = args.input.replace(/\.([a-z]|[A-Z]){2,4}$/, '.bitk3.fa') | ||
|
||
const options = (args.skipBad) ? {keepGoing: true} : {keepGoing: false} | ||
|
||
console.log(args) | ||
const rawData = fs.readFileSync(path.resolve(args.input)).toString() | ||
const stableIds = rawData.split('\n') | ||
|
||
while (stableIds.indexOf('') !== -1) { | ||
const index = stableIds.indexOf('') | ||
stableIds.splice(index, 1) | ||
} | ||
console.log(options) | ||
getFasta(stableIds, args.output, options) |
Oops, something went wrong.