Skip to content

Commit

Permalink
Revert "resolved KwanLab#19, did not add the copyright and liscence i…
Browse files Browse the repository at this point in the history
…nformation"

This reverts commit ca64a2f.
  • Loading branch information
Sidduppal committed Mar 18, 2020
1 parent ca64a2f commit bc390bc
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions autometa/common/external/samtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import subprocess

import pandas as pd
import multiprocessing as mp

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -38,41 +37,32 @@ def run(cmd):
logger.debug(f'cmd: {cmd}')
with open(os.devnull, 'w') as stdout, open(os.devnull, 'w') as stderr:
retcode = subprocess.call(cmd, stdout=stdout, stderr=stderr, shell=True)
if not retcode:
return True
else:
if retcode:
logger.warning(f'args:{cmd} retcode:{retcode}')
return False

def sort(sam, out, nproc=mp.cpu_count()):
"""
Views the sam file and then sorts the alighnments by leftmost coordinates.
Parameters
----------
sam : str
</path/to/alignment.sam>
out : str
</path/to/output/file>
nproc : int, optional
Number of processors to be used, by default uses the number os cpu's in the system.
return True

"""
def sort(sam, out, nproc=0):
cmd = f'samtools view -@{nproc} -bS {sam} | samtools sort -@{nproc} -o {out}'
run(cmd)

def depth(bam, records):
cmds = [f'samtools depth -r {record.id} {bam}' for record in records]
raise NotImplementedError

def main(args):
sort(args.sam, args.out, args.nproc)

sort(args.sam)
depth(args.bam, args.seqs)

if __name__ == '__main__':
import argparse
import logging as logger
logger.basicConfig(
format='%(asctime)s : %(name)s : %(levelname)s : %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')
parser = argparse.ArgumentParser()
parser.add_argument('--sam', help='</path/to/alignment.sam>')
parser.add_argument('--out', help='</path/to/output/file')
parser.add_argument('--nproc', help='Num processors to use.', default=mp.cpu_count(), type=int)
parser.add_argument('--bam')
parser.add_argument('--sam')
parser.add_argument('--seqs')
args = parser.parse_args()
main(args)

0 comments on commit bc390bc

Please sign in to comment.