Skip to content

Commit df254c5

Browse files
committed
Prevent index from failing when index already exists
1 parent c5c3f7d commit df254c5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bin/cmo_index

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ args = parser.parse_args()
1919
bam = args.bam
2020
picard = cmo.util.programs['picard'][args.picard_version]
2121
java = cmo.util.programs['java'][args.java_version]
22+
index_path = os.path.basename(bam).replace(".bam",".bai")
2223
# create .bai
23-
command = [java, "-jar", picard, " BuildBamIndex", "I="+bam, "O=", os.path.basename(bam).replace(".bam",".bai")]
24-
cmo.util.call_cmd(" ".join(command), shell=True)
24+
if not os.path.exists(index_path):
25+
command = [java, "-jar", picard, " BuildBamIndex", "I="+bam, "O=", index_path]
26+
cmo.util.call_cmd(" ".join(command), shell=True)
2527
# create .bam.bai
2628
shutil.copy(os.path.basename(bam).replace(".bam", ".bai"), os.path.basename(bam) + ".bai")

0 commit comments

Comments
 (0)