Skip to content

Commit

Permalink
Fix liftover by making tabix index an option
Browse files Browse the repository at this point in the history
  • Loading branch information
marghoob committed Jun 11, 2017
1 parent d19dbe8 commit c861782
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions liftover_restricted_vcf_map.py
Expand Up @@ -9,7 +9,7 @@
import copy
from collections import defaultdict, OrderedDict

def lift_vcfs(vcfs, out_vcf, reference):
def lift_vcfs(vcfs, out_vcf, reference, tabix_index=True):
logger = logging.getLogger(lift_vcfs.__name__)

if not vcfs:
Expand Down Expand Up @@ -67,10 +67,11 @@ def lift_vcfs(vcfs, out_vcf, reference):
continue
vcf_writer.write_record(curr_record)
vcf_writer.close()
pysam.tabix_index(out_vcf, force=True, preset='vcf')
if tabix_index:
pysam.tabix_index(out_vcf, force=True, preset='vcf')

logger.info("Finished liftover of VCF to original reference")
return "{}.gz".format(out_vcf)
return "{}.gz".format(out_vcf) if tabix_index else out_vcf


def lift_maps(maps, out_map):
Expand Down
4 changes: 3 additions & 1 deletion varsim.py
Expand Up @@ -12,6 +12,7 @@
import glob
import tempfile
import re
import pysam
from distutils.version import LooseVersion
from liftover_restricted_vcf_map import lift_vcfs, lift_maps
from generate_small_test_ref import gen_restricted_ref_and_vcfs
Expand Down Expand Up @@ -402,9 +403,10 @@ def varsim_main(reference,
makedirs([lifted_dir])
#quick fix for issue of CN
convertCN([merged_truth_vcf], "two2one")
merged_truth_vcf = lift_vcfs([merged_truth_vcf], os.path.join(lifted_dir, "truth.vcf"), None)
merged_truth_vcf = lift_vcfs([merged_truth_vcf], os.path.join(lifted_dir, "truth.vcf"), None, tabix_index=False)
#quick fix for issue of CN
convertCN([merged_truth_vcf], "one2two")
pysam.tabix_index(merged_truth_vcf, force=True, preset='vcf')
merged_map = lift_maps([merged_map], os.path.join(lifted_dir, "truth.map"))

if processes:
Expand Down

0 comments on commit c861782

Please sign in to comment.