From 0ffbe38fc3b35f7823c80dc3b6a73ba70c0a0dc0 Mon Sep 17 00:00:00 2001 From: Kelly Vincent Date: Mon, 5 Oct 2009 10:35:39 -0400 Subject: [PATCH] Several small changes to Samtools pileup tool to get it to work with user-supplied reference genome --- tools/samtools/sam_pileup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/samtools/sam_pileup.py b/tools/samtools/sam_pileup.py index 4e11f48d61d..a03487ff2a4 100644 --- a/tools/samtools/sam_pileup.py +++ b/tools/samtools/sam_pileup.py @@ -68,14 +68,16 @@ def __main__(): stop_err( "No sequences are available for '%s', request them by reporting this error." % options.dbkey ) cmd3 = cmd3 % (opts, seq_path, tmpf0bam, options.output1) elif options.ref == 'history': - cmd1 = 'cp %s %s; cp %s.fai %s' % (options.ownFile, tmpf1.name, options.ownFile, tmpf1fai) + cmd1 = 'cp %s %s; samtools faidx %s' % (options.ownFile, tmpf1.name, tmpf1.name) cmd3 = cmd3 % (opts, tmpf1.name, tmpf0bam, options.output1) # index reference if necessary if cmd1: try: os.system(cmd1) + if options.ref == 'history' and not os.path.exists( tmpf1fai ): + stop_err( "Problem creating index file from history item." ) except Exception, eq: - stop_err('Error moving reference sequence\n' + str(eq)) + stop_err('Error handling reference sequence\n' + str(eq)) # copy bam index to working directory try: os.system(cmd2) @@ -85,7 +87,7 @@ def __main__(): try: os.system(cmd3) except Exception, eq: - stop_err('Error running SAMtools merge tool\n' + str(eq)) + stop_err('Error running SAMtools pileup tool\n' + str(eq)) # clean up temp files tmpf1.close() tmpf0.close() @@ -94,6 +96,6 @@ def __main__(): if os.path.exists(tmpf0bambai): os.remove(tmpf0bambai) if os.path.exists(tmpf1fai): - os.remove(tmpf0bambai) + os.remove(tmpf1fai) if __name__ == "__main__" : __main__()