Skip to content

Commit

Permalink
ability to run multiple things with a csv added
Browse files Browse the repository at this point in the history
  • Loading branch information
arontommi committed Jan 12, 2018
1 parent 0045699 commit b868b3c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
26 changes: 14 additions & 12 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@



##### this is a simple wrapper around samtools to subset bam files to later view in Igv for less command line literate people
##### this is a simple wrapper around samtools to subset bam files to later view in Igv for less command line literate people for visual validation of variants.

additional objects are for the writer to improve software documentasion as well as use click to manage inputs

The idea is to continue to add functionality, ideally being able
25 changes: 20 additions & 5 deletions smallerbam.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import subprocess as sp
import os
import click

import pandas as pd

class StClass():
"""Main class for stuff """
p = os.path.dirname(os.path.realpath(__file__))
bashscript = str(p)+'/samtools_view.sh'

def __init__(self):
self.p = os.path.dirname(os.path.realpath(__file__))
self.bashscript = str(self.p)+'/samtools_view.sh'

def runbams(self, bamfile, region, outputfile):
"""run samtools view"""
sp.call(['{}'.format(self.bashscript),
'{}'.format(bamfile),
'{}'.format(region),
'{}'.format(outputfile)])
def runmultiple(self, csv):
file = pd.read_csv(csv, header=None)
for i, r in file.iterrows():
self.runbams(r[0], r[1], r[2])


@click.command()
Expand All @@ -29,9 +35,18 @@ def runbams(self, bamfile, region, outputfile):
'--outputfile', '-o',
help='outputfile',
)
def main(inputfile, region, outputfile):
@click.option(
'--csv', '-c',
help='if multiple files need to be created use a simple csv, no header, with first column being input file,'
' second for region and third for outputfile '
)

def main(inputfile, region, outputfile, csv ):
sc = StClass()
sc.runbams(inputfile, region, outputfile)
if csv:
sc.runmultiple(csv)
else:
sc.runbams(inputfile, region, outputfile)


if __name__ == '__main__':
Expand Down

0 comments on commit b868b3c

Please sign in to comment.