Skip to content
Open
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
5 changes: 2 additions & 3 deletions make_annot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def make_annot_files(args, bed_for_annot):
print('making annot file')
df_bim = pd.read_csv(args.bimfile,
delim_whitespace=True, usecols = [0,1,2,3], names = ['CHR','SNP','CM','BP'])
iter_bim = [['chr'+str(x1), x2, x2] for (x1, x2) in np.array(df_bim[['CHR', 'BP']])]
iter_bim = [['chr'+str(x1), int(x2), int(x2)] for (x1, x2) in np.array(df_bim[['CHR', 'BP']])]
bimbed = BedTool(iter_bim)
annotbed = bimbed.intersect(bed_for_annot)
bp = [x.start for x in annotbed]
Expand All @@ -29,8 +29,7 @@ def make_annot_files(args, bed_for_annot):
df_annot.fillna(0, inplace=True)
df_annot = df_annot[['ANNOT']].astype(int)
if args.annot_file.endswith('.gz'):
with gzip.open(args.annot_file, 'wb') as f:
df_annot.to_csv(f, sep = "\t", index = False)
df_annot.to_csv(args.annot_file, sep = "\t", index = False, compression='\gzip')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of the backslash on \gzip?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, pandas 0.24 can infer compression based on extension, but not in 0.20 which we're pinned to (bummer)

else:
df_annot.to_csv(args.annot_file, sep="\t", index=False)

Expand Down