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

Fix globbing bug in splitp #221

Merged
merged 4 commits into from
Jul 24, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
infer compression from first chromosome present
  • Loading branch information
emschorsch authored Jun 19, 2020
commit 9bdd73745eea9d112fa8826b6a8fa2a2f49790ab
9 changes: 5 additions & 4 deletions ldscore/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def ldscore(fh, num=None):
'''Parse .l2.ldscore files, split across num chromosomes. See docs/file_formats_ld.txt.'''
suffix = '.l2.ldscore'
if num is not None: # num files, e.g., one per chromosome
first_fh = sub_chr(fh, 1) + suffix
s, compression = which_compression(first_fh)
chrs = get_present_chrs(fh, num+1)
first_fh = sub_chr(fh, chrs[0]) + suffix
s, compression = which_compression(first_fh)
chr_ld = [l2_parser(sub_chr(fh, i) + suffix + s, compression) for i in chrs]
x = pd.concat(chr_ld) # automatically sorted by chromosome
else: # just one file
Expand Down Expand Up @@ -187,8 +187,9 @@ def annot(fh_list, num=None, frqfile=None):
annot_suffix = ['.annot' for fh in fh_list]
annot_compression = []
if num is not None: # 22 files, one for each chromosome
chrs = get_present_chrs(fh, num+1)
for i, fh in enumerate(fh_list):
first_fh = sub_chr(fh, 1) + annot_suffix[i]
first_fh = sub_chr(fh, chrs[0]) + annot_suffix[i]
annot_s, annot_comp_single = which_compression(first_fh)
annot_suffix[i] += annot_s
annot_compression.append(annot_comp_single)
Expand All @@ -201,7 +202,7 @@ def annot(fh_list, num=None, frqfile=None):

y = []
M_tot = 0
for chrom in get_present_chrs(fh, num+1):
for chrom in chrs:
if frqfile is not None:
df_annot_chr_list = [annot_parser(sub_chr(fh, chrom) + annot_suffix[i], annot_compression[i],
sub_chr(frqfile, chrom) + frq_suffix, frq_compression)
Expand Down