Skip to content

Commit

Permalink
Fix index file syntax and fix linting problems
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Dec 8, 2017
1 parent 0ac77ad commit 6ca896f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/galaxy/datatypes/tabular.py
Expand Up @@ -27,7 +27,6 @@
)
from galaxy.util import compression_utils
from galaxy.util.checkers import is_gzip

from . import dataproviders

if sys.version_info > (3,):
Expand Down Expand Up @@ -764,7 +763,7 @@ def set_meta(self, dataset, **kwd):
index_file = dataset.metadata.spec['tabix_index'].param.new_file(dataset=dataset)

try:
pysam.tabix_index(dataset.file_name, index=index_file, preset='vcf')
pysam.tabix_index(dataset.file_name, index=index_file.file_name, preset='vcf')
except Exception as e:
raise Exception('Error setting VCF.gz metadata: %s' % (str(e)))
dataset.metadata.tabix_index = index_file
Expand Down
1 change: 0 additions & 1 deletion test/unit/datatypes/test_bcf.py
Expand Up @@ -2,7 +2,6 @@
Bcf,
BcfUncompressed
)

from .util import (
get_dataset,
get_input_files,
Expand Down
7 changes: 6 additions & 1 deletion test/unit/datatypes/test_cram.py
@@ -1,5 +1,6 @@
import os
import pysam
from galaxy.datatypes.binary import CRAM

from .util import (
get_dataset,
get_input_files,
Expand All @@ -9,5 +10,9 @@
def test_cram():
c = CRAM()
with get_input_files('2.cram') as input_files, get_dataset(input_files[0], index_attr='cram_index') as dataset:
assert os.path.exists(dataset.metadata.cram_index.file_name) is False
c.set_index_file(dataset=dataset, index_file=dataset.metadata.cram_index)
assert os.path.exists(dataset.metadata.cram_index.file_name) is True
c.set_meta(dataset)
pysam.AlignmentFile(dataset.file_name, index_filename=dataset.metadata.cram_index.file_name)
assert dataset.metadata.cram_version == '3.0'
2 changes: 1 addition & 1 deletion test/unit/datatypes/test_vcf.py
Expand Up @@ -25,5 +25,5 @@ def test_vcf_gz_set_meta():
vcf_gz = VcfGz()
with get_input_files('1.vcf.gz') as input_files, get_dataset(input_files[0], index_attr='tabix_index') as dataset:
vcf_gz.set_meta(dataset)
f = pysam.VariantFile(dataset.file_name, index_filename=dataset.metadata.tabix_index)
f = pysam.VariantFile(dataset.file_name, index_filename=dataset.metadata.tabix_index.file_name)
assert isinstance(f.index, pysam.libcbcf.TabixIndex) is True
4 changes: 3 additions & 1 deletion test/unit/datatypes/util.py
Expand Up @@ -15,7 +15,9 @@ def get_dataset(file, index_attr='bam_index', dataset_id=1, has_data=True):
dataset.metadata = Bunch()
with get_input_files(file) as input_files, get_tmp_path() as index_path:
dataset.file_name = input_files[0]
setattr(dataset.metadata, index_attr, index_path)
index = Bunch()
index.file_name = index_path
setattr(dataset.metadata, index_attr, index)
yield dataset


Expand Down

0 comments on commit 6ca896f

Please sign in to comment.