Skip to content

Commit 7026b81

Browse files
authored
Merge pull request #135 from jbelyeu/master
allow csi index for annotation files
2 parents 1256097 + 4304312 commit 7026b81

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

samplot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env python
2-
__version__ = "1.1.5"
2+
__version__ = "1.1.6"

samplot/samplot.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ def get_tabix_iter(chrm, start, end, datafile):
182182
Used to avoid chrX vs. X notation issues when extracting data from
183183
annotation files
184184
"""
185-
tbx = pysam.TabixFile(datafile)
185+
try:
186+
tbx = pysam.TabixFile(datafile)
187+
except:
188+
tbx = pysam.TabixFile(datafile, index=datafile+".csi")
189+
190+
186191
itr = None
187192
try:
188193
itr = tbx.fetch(chrm, max(0, start - 1000), end + 1000)
@@ -2212,7 +2217,9 @@ def gff_file(transcript_file):
22122217

22132218
idx_file = transcript_file + ".tbi"
22142219
if not os.path.isfile(idx_file):
2215-
parser.error("transcript file {} is missing .tbi index file".format(transcript_file))
2220+
idx_file = transcript_file + ".csi"
2221+
if not os.path.isfile(idx_file):
2222+
parser.error("transcript file {} is missing .tbi/.csi index file".format(transcript_file))
22162223
return transcript_file
22172224

22182225
parser.add_argument(
@@ -2250,7 +2257,9 @@ def bed_file(annotation_file):
22502257

22512258
idx_file = annotation_file + ".tbi"
22522259
if not os.path.isfile(idx_file):
2253-
parser.error("annotation file {} is missing .tbi index file".format(annotation_file))
2260+
idx_file = annotation_file + ".csi"
2261+
if not os.path.isfile(idx_file):
2262+
parser.error("annotation file {} is missing .tbi index file".format(annotation_file))
22542263
return annotation_file
22552264

22562265
parser.add_argument(

test/data/Alu.2_X.csionly.bed.gz

977 KB
Binary file not shown.
103 KB
Binary file not shown.
3.78 MB
Binary file not shown.
21.7 KB
Binary file not shown.

test/func/samplot_test.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,4 +541,25 @@ if [ $translocation ]; then
541541
assert_no_stderr
542542
fi
543543

544+
545+
out_file_name=$func_path"csi-annotation.png"
546+
bam=$data_path"2_59305747-59505747_X_151018513-151218513.BND.bam"
547+
run translocation \
548+
samplot plot\
549+
-c $sv_chrm_1 -s $sv_start_1 -e $sv_end_1 \
550+
-c $sv_chrm_2 -s $sv_start_2 -e $sv_end_2 \
551+
-b $bam \
552+
-o $out_file_name \
553+
-t $sv_type \
554+
-A $data_path"Alu.2_X.csionly.bed.gz" \
555+
-T $data_path"Homo_sapiens.GRCh37.csionly.2_X.gff3.gz" \
556+
--zoom 10000
557+
if [ $translocation ]; then
558+
assert_exit_code 0
559+
assert_equal $out_file_name $( ls $out_file_name )
560+
assert_no_stdout
561+
assert_no_stderr
562+
fi
563+
564+
544565
rm -rf $func_path"img/" ssshtest

0 commit comments

Comments
 (0)