This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"binsi": { | |
"target_site": "CCWGG", | |
"name": "BinSI", | |
"suppliers": [], | |
"source": "ATCC 15702", | |
"references": [ | |
"Khosaka, T., Kiwaki, M., Rak, B., (1983) FEBS Lett., vol. 163, pp. 170-174." | |
], | |
"prototype": "EcoRII", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"End": { | |
"TAG": { | |
"frequency": 0.0, | |
"relfreq": 0.0 | |
}, | |
"localfrequency": 2.74, | |
"TGA": { | |
"frequency": 0.98, | |
"relfreq": 0.3576642335766423 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
from sys import argv | |
# Walk through folders recursively, list the full path and number of (extension) files found in each. | |
basefolder = os.path.expanduser(argv[1]) | |
filetype = str(argv[2]).lower() | |
output = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
fixfile = sys.argv[1] | |
with open(fixfile) as InputFile: | |
word_soup = InputFile.read() | |
# Strip off excess whitespace and any trailing ellipsis. | |
word_soup = word_soup.strip().strip(".!?") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time | |
import datetime | |
import os | |
import json | |
timestamp_format = '%a %b %d %H:%M:%S %z %Y' | |
def twitter_timestamp_to_obj(time_string): | |
'Returns a timezone-aware datetime object.' | |
return datetime.datetime.strptime(time_string, timestamp_format) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time | |
import datetime | |
import json | |
import re | |
timestamp_format = '%a %b %d %H:%M:%S %z %Y' | |
def twitter_timestamp_to_obj(time_string): | |
'Returns a timezone-aware datetime object.' | |
return datetime.datetime.strptime(time_string, timestamp_format) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VersionedDict(dict): | |
'''A dictionary sublcass that remembers all or a defined number of prior entries for a key. | |
Allows reversion by number from "head" or by absolute reference in revision list. | |
Allows retrieval of currently retained revision history for a key. | |
Deletion deletes all revisions, not merely the most recent. | |
If instantiated with the "revisions" keyword and an integer argument, only retains that many revisions per entry.''' | |
def __init__(self, *args, **kwargs): | |
revisions = kwargs.pop('revisions', None) | |
self._allowed_revisions = abs(int(revisions)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Bio import SeqIO | |
from Bio.Seq import Seq | |
sequence_generator = SeqIO.parse("br_sequences.fasta", "fasta") | |
all_sequences = list(sequence_generator) | |
# * How many records are in the file? | |
print("Number of records:", len(all_sequences)) | |
# * How many records have a sequence of length 249? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Functions missing from Python's string/list types that are handy for bio-informatics." | |
def codonise(seq): | |
'''Returns a list of codons, not including trailing 1/2n. | |
To get codons starting from letter X, pass seq[X:].''' | |
mylist = [] | |
for i in range(0, len(seq), 3): | |
this_codon = seq[i:i+3] | |
# This bit ensures that only whole codons, | |
# not trailing bits, are added: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from Bio import SeqIO | |
from Bio.Seq import Seq | |
filename = sys.argv[1] | |
usersequence = Seq(sys.argv[2]) | |
usersequence = usersequence.upper() | |
user_reverse = usersequence.reverse_complement() | |
records = SeqIO.parse(filename, "fasta") |
OlderNewer