Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3.5 can run this method #193

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ hisat2_test/kim_example*.malignment.gcsa
hisat2_test/genome*
hisat2_test/2*
hisat2_test/snp142*
hisat2_test/testset*
hisat2_test/testset*

.idea/
9 changes: 5 additions & 4 deletions hisat2_extract_snps_haplotypes_UCSC.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import sys, subprocess
import re
from argparse import ArgumentParser, FileType

from functools import cmp_to_key

"""
"""
Expand Down Expand Up @@ -129,7 +129,7 @@ def generate_haplotypes(snp_file,
assert len(vars) > 0

# Sort variants and remove redundant variants
vars = sorted(vars, cmp=compare_vars)
vars = sorted(vars, key=cmp_to_key(compare_vars))
tmp_vars = []
v = 0
while v < len(vars):
Expand Down Expand Up @@ -289,7 +289,7 @@ def cmp_haplotype(a, b):
return a_begin - b_begin
return a_end - b_end

haplotypes = sorted(list(haplotypes2), cmp=cmp_haplotype)
haplotypes = sorted(list(haplotypes2), key=cmp_to_key(cmp_haplotype))

# Write haplotypes
for h_i in range(len(haplotypes)):
Expand Down Expand Up @@ -353,7 +353,8 @@ def main(genome_file,
snp_cmd = ["cat", snp_fname]
snp_proc = subprocess.Popen(snp_cmd,
stdout=subprocess.PIPE,
stderr=open("/dev/null", 'w'))
stderr=open("/dev/null", 'w'),
universal_newlines=True)
ids_seen = set()
for line in snp_proc.stdout:
if not line or line.startswith('#'):
Expand Down