Skip to content

Commit

Permalink
Merge pull request #245 from openvax/fix-reference-name
Browse files Browse the repository at this point in the history
Fix reference names from CLI
  • Loading branch information
iskandr committed Nov 8, 2019
2 parents 4adb6bf + 9115b08 commit a51a7dd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion varcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
NonsilentCodingMutation,
)

__version__ = '1.0.2'
__version__ = '1.0.3'

__all__ = [
# basic classes
Expand Down
1 change: 0 additions & 1 deletion varcode/cli/effects_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from __future__ import division, absolute_import

import logging
import logging.config
import pkg_resources
import sys
Expand Down
18 changes: 5 additions & 13 deletions varcode/cli/variant_args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016. Mount Sinai School of Medicine
# Copyright (c) 2016-2019. Mount Sinai School of Medicine
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,6 @@
from __future__ import print_function, division, absolute_import
from argparse import ArgumentParser

from pyensembl import genome_for_reference_name

from ..vcf import load_vcf
from ..maf import load_maf
from ..variant_collection import VariantCollection
Expand Down Expand Up @@ -120,21 +118,15 @@ def download_and_install_reference_data(variant_collections):
def variant_collection_from_args(args, required=True):
variant_collections = []

if args.genome:
genome = genome_for_reference_name(args.genome)
else:
# no genome specified, assume it can be inferred from the file(s)
# we're loading
genome = None

for vcf_path in args.vcf:
variant_collections.append(load_vcf(vcf_path, genome=genome))
variant_collections.append(
load_vcf(vcf_path, genome=args.genome))

for maf_path in args.maf:
variant_collections.append(load_maf(maf_path))

if args.variant:
if not genome:
if not args.genome:
raise ValueError(
"--genome must be specified when using --variant")

Expand All @@ -144,7 +136,7 @@ def variant_collection_from_args(args, required=True):
start=position,
ref=ref,
alt=alt,
ensembl=genome)
genome=args.genome)
for (chromosome, position, ref, alt)
in args.variant
]
Expand Down
13 changes: 11 additions & 2 deletions varcode/maf.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def load_maf_dataframe(path, nrows=None, raise_on_error=True, encoding=None):
low_memory=False,
skip_blank_lines=True,
header=0,
nrows=nrows,
encoding=encoding)

if len(df.columns) < n_basic_columns:
Expand Down Expand Up @@ -117,7 +118,8 @@ def load_maf(
sort_key=variant_ascending_position_sort_key,
distinct=True,
raise_on_error=True,
encoding=None):
encoding=None,
nrows=None):
"""
Load reference name and Variant objects from MAF filename.
Expand All @@ -143,10 +145,17 @@ def load_maf(
encoding : str, optional
Encoding to use for UTF when reading MAF file.
nrows : int, optional
Limit to number of rows loaded
"""
# pylint: disable=no-member
# pylint gets confused by read_csv inside load_maf_dataframe
maf_df = load_maf_dataframe(path, raise_on_error=raise_on_error, encoding=encoding)
maf_df = load_maf_dataframe(
path,
nrows=nrows,
raise_on_error=raise_on_error,
encoding=encoding)

if len(maf_df) == 0 and raise_on_error:
raise ValueError("Empty MAF file %s" % path)
Expand Down

0 comments on commit a51a7dd

Please sign in to comment.