from numpy import array
a = array([1,2,3])
a.dtype # dtype('int32')
a.dtype.kind # 'i', for 'integer'
s = array(['a','b','c'])
s.dtype # dtype('|S1')
s.dtype.kind # 'S' for 'string'
f = array([1., 2., 3.])
f.dtype # dtype('float64')
f.dtype.kind # 'f' for 'float'
Archive for the 'BioPython' Category
There are no built-in functions (that I know of) for returning a list of codons from a sequence, but making your own is quite simple. This function is from Solution A.5 from the Python Course in Bioinformatics
def codons(s, frame=0):
"""Return a list of codons from a string, s, giving an optional frameshift."""
codons=[]
end=len(s[frame:]) - (len(s[frame:]) % 3) - 1
for i in range(frame,end,3):
codons.append(s[i:i+3])
return codons
Sometimes it’s nice to be able to have a codon table handy. Rather than typing out one by hand, theTranslate module contains the codon table of your choice in dictionary form: Continue reading ‘A quick codon table’
Here are several ways to parse a FASTA file into BioPython Seq objects.
Getting a FASTA file into Python is as simple as importing the necessary functions from BioPython, opening the file, and calling a parser on the file. Then you have sequences in BioPython that can be readily used. There are a couple of different ways to parse the file, depending on your preference. Choices are: Continue reading ‘Read FASTA files with BioPython’
Much of BioPython uses Seq objects for dealing with sequences of all kinds. Here’s how to create, get the complement, transcribe, and translate sequences, either from scratch or from a FASTA or GenBank file. Continue reading ‘Working with BioPython Sequences’
BioPython can send sequences directly to NCBI and will download the results when they’re ready. Once you have the output, you can parse it to, say, just pull out the hits with the top 10 lowest E values. Or generate a list of the species most frequently found in the results . . . or other useful things. Continue reading ‘Run BLAST from BioPython’
BioPython handles GenBank files nicely. Here are a couple of ways of getting them into Python and working with them. Continue reading ‘Parse GenBank files with BioPython’