From f3965287e63c3c234cd00decf778c9b95b55ea91 Mon Sep 17 00:00:00 2001 From: JiguangPeng Date: Wed, 15 Jun 2022 12:00:26 +0800 Subject: [PATCH] [#75] ReadExtractor support absolute path --- circlemap/extract_circle_SV_reads.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/circlemap/extract_circle_SV_reads.py b/circlemap/extract_circle_SV_reads.py index 33707ba..4cbee3c 100644 --- a/circlemap/extract_circle_SV_reads.py +++ b/circlemap/extract_circle_SV_reads.py @@ -61,7 +61,10 @@ def extract_sv_circleReads(self): os.chdir(self.working_dir) #input - raw_bam = ps.AlignmentFile(self.working_dir + "/" + self.sorted_bam, "rb") + if os.path.isabs(self.sorted_bam): + raw_bam = ps.AlignmentFile(self.sorted_bam, "rb") + else: + raw_bam = ps.AlignmentFile(self.working_dir + "/" + self.sorted_bam, "rb") #HD the tag for the header line. SO indicates sorting order of the alignements if 'HD' in raw_bam.header: @@ -85,7 +88,10 @@ def extract_sv_circleReads(self): - circle_sv_reads = ps.AlignmentFile(self.working_dir + "/" + self.output_bam , "wb", template=raw_bam) + if os.path.isabs(self.output_bam): + circle_sv_reads = ps.AlignmentFile(self.output_bam , "wb", template=raw_bam) + else: + circle_sv_reads = ps.AlignmentFile(self.working_dir + "/" + self.output_bam , "wb", template=raw_bam) #modify the tag to unsorted @@ -222,4 +228,4 @@ def extract_sv_circleReads(self): print("finished extracting reads. Elapsed time:", (end - begin) / 60, "mins") - print("Thanks for using Circle-Map") \ No newline at end of file + print("Thanks for using Circle-Map")