Skip to content

Commit

Permalink
Merge pull request #1 from daviortega/f-get-fasta-from-stable-id
Browse files Browse the repository at this point in the history
getFasta
  • Loading branch information
daviortega committed Oct 25, 2018
2 parents f781cc7 + 58cfaa0 commit 7dd2166
Show file tree
Hide file tree
Showing 5 changed files with 812 additions and 462 deletions.
16 changes: 16 additions & 0 deletions bin/getFastaFromStableIds-cli.js
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')
53 changes: 53 additions & 0 deletions cli-scripts/getFasta.js
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)

0 comments on commit 7dd2166

Please sign in to comment.