-
Notifications
You must be signed in to change notification settings - Fork 86
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
writing_appliance script example: smiting perl from yet one more place #705
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env python2 | ||
import sys | ||
|
||
# usage : python gc_content.py <FASTA file> <output file> | ||
|
||
name = None | ||
with open(sys.argv[1]) as infile: | ||
with open(sys.argv[2], 'w') as outfile: | ||
for line_raw in infile: | ||
line = line_raw.rstrip('\r\n') | ||
if line.startswith('>'): | ||
if name is not None: | ||
outfile.write(name+': '+str(gc/float(total))+'\n') | ||
name = line[1:] | ||
gc = 0 | ||
total = 0 | ||
else: | ||
gc += line.count('G') + line.count('C') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not case insensitive, unlike the perl version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, true. Didn't know if it was more important to be complete or keep it simple. I can make the edit if you guys want. |
||
total += len(line) | ||
outfile.write(name+': '+str(gc/float(total))+'\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python2? why not python3? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, I'd love to, but I figured let's not go crazy here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this made me do some research.. can OS X people confirm whether python2 is on your PATH?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, no. At least only
python
is on the$PATH
on macOS Sierra 10.12.5, notpython2
.