Skip to content

Commit

Permalink
Prevent index from failing when index already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhil committed Oct 7, 2019
1 parent c5c3f7d commit df254c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/cmo_index
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ args = parser.parse_args()
bam = args.bam
picard = cmo.util.programs['picard'][args.picard_version]
java = cmo.util.programs['java'][args.java_version]
index_path = os.path.basename(bam).replace(".bam",".bai")
# create .bai
command = [java, "-jar", picard, " BuildBamIndex", "I="+bam, "O=", os.path.basename(bam).replace(".bam",".bai")]
cmo.util.call_cmd(" ".join(command), shell=True)
if not os.path.exists(index_path):
command = [java, "-jar", picard, " BuildBamIndex", "I="+bam, "O=", index_path]
cmo.util.call_cmd(" ".join(command), shell=True)
# create .bam.bai
shutil.copy(os.path.basename(bam).replace(".bam", ".bai"), os.path.basename(bam) + ".bai")

0 comments on commit df254c5

Please sign in to comment.