Open ovidp opened 5 years ago
What OS/shell are you using? I don't think the issue is on the python side -- my suspicion is that for whatever reason the shell is not treating the single quotes correctly in the awk part of the pipe. Try replacing the awk bit so that the commands are enclosed by double quotes (& escape the internal double quotes with a backslash):
... | awk "$6 < 0.75 {print $1\"\t\"$2}" >allSites
(also try correction below)
Whoops, you my also need to escape the dollar signs in this case (at least, that's necessary in bash):
... | awk "\$6 < 0.75 {print \$1\"\t\"\$2}" >allSites
Thanks Nate! I was 80% sure it is the damn quote :) I’ll forward it to them!
On Jul 9, 2019, at 10:54 AM, nspope notifications@github.com wrote:
Whoops, you'd also need to escape the dollar signs in this case:
... | awk "\$6 < 0.75 {print \$1\"\t\"\$2}" >allSites
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/z0on/2bRAD_denovo/issues/1?email_source=notifications&email_token=ABZUHGAKRKDERWCWA2CA2Z3P6SRB5A5CNFSM4H7FAHCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZQQWIY#issuecomment-509676323, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZUHGH2PXVVEY7MGMKGKSLP6SRB5ANCNFSM4H7FAHCA.
Hey folks - This is what the author of the HetMajorityProb.py, Nate Pope (cc’d here), thinks:
"Python seems to be complaining because awk closes prematurely while python is trying to write to the pipe. I think the issue is with how their shell treats single quotes in the awk command. Maybe they are using one of the weird Windows pseudo-bash things. If this ends up panning out, then the most portable (but god-awful annoying) strategy is to always use double quotes in one-liners throughout your pipeline, and escape any "internal" double quotes and other funky symbols." ... | awk "\$6 < 0.75 {print \$1\"\t\"\$2}" >allSites
On Jul 9, 2019, at 8:30 AM, ovidp notifications@github.com wrote:
We are having an issue running HetMajorityProb.py. Python version is 2.7.12 Can you please help? Thanks
zcat sfilt.geno.gz | python ~/2bRAD_denovo/HetMajorityProb.py | awk '$6 < 0.75 {print $1"\t"$2}' > allSites awk: cmd. line:1: $6 < 0.75 {print $1"\t"$2} awk: cmd. line:1: ^ backslash not last character on line Traceback (most recent call last): File "/home/2bRAD_denovo/HetMajorityProb.py", line 28, in stdout.write("\t".join([chrom, pos, str(len(pr_heteroz)), str(num_heteroz), str(h_expected), str(utail_prob)]) + "\n") IOError: [Errno 32] Broken pipe
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/z0on/2bRAD_denovo/issues/1?email_source=notifications&email_token=ABZUHGAYEWROTWRIJYXDU7DP6SAIHA5CNFSM4H7FAHCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G6C24BA, or mute the thread https://github.com/notifications/unsubscribe-auth/ABZUHGH5YH5DKFB6NEWCEOLP6SAIHANCNFSM4H7FAHCA.
Hi
Thank you very much for your fast answer. I use Linux and GNU bash v 4.3.48
The quote was the problem - after replacing ‘ with “ it works like a charmJ
All the best
Ovidiu
From: nspope [mailto:notifications@github.com] Sent: Dienstag, 9. Juli 2019 16:54 To: z0on/2bRAD_denovo Cc: ovidp; Author Subject: Re: [z0on/2bRAD_denovo] error running HetMajorityProb.py (#1)
Whoops, you'd also need to escape the dollar signs in this case:
... | awk "\$6 < 0.75 {print \$1\"\t\"\$2}" >allSites
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/z0on/2bRAD_denovo/issues/1?email_source=notifications&email_token=AI6QKHFLVLCI3QBNFAEFFG3P6SRB5A5CNFSM4H7FAHCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZQQWIY#issuecomment-509676323 , or mute the thread https://github.com/notifications/unsubscribe-auth/AI6QKHC36BE5ISXWGVN2LLTP6SRB5ANCNFSM4H7FAHCA . https://github.com/notifications/beacon/AI6QKHBTX7XHGFKBPJLE4V3P6SRB5A5CNFSM4H7FAHCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZQQWIY.gif
We are having an issue running HetMajorityProb.py. Python version is 2.7.12 Can you please help? Thanks
zcat sfilt.geno.gz | python ~/2bRAD_denovo/HetMajorityProb.py | awk '\$6 < 0.75 {print \$1\"\t\"\$2}' > allSites awk: cmd. line:1: \$6 < 0.75 {print \$1\"\t\"\$2} awk: cmd. line:1: ^ backslash not last character on line Traceback (most recent call last): File "/home/2bRAD_denovo/HetMajorityProb.py", line 28, in
stdout.write("\t".join([chrom, pos, str(len(pr_heteroz)), str(num_heteroz), str(h_expected), str(utail_prob)]) + "\n")
IOError: [Errno 32] Broken pipe