Getting Started

(Difference between revisions)
Jump to: navigation, search
(Quick example)
m (Reverted edits by Jennifer M. Lintz (Talk) to last revision by Sbassi)
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Download==
+
==Download and Installation==
  
See [[Download|Getting BioPython]]
+
For Windows we provide click-and-run installers.  Most Linux distributions will include an optional Biopython package (although this may be out of date).  Otherwise you typically download and uncompress the archive, and install from source.  See our [[Download|downloads page]] for details including the prerequisites.
  
==Installation==
+
You can check your installation has worked at the python prompt:
  
See [http://biopython.org/DIST/docs/install/Installation.html Installing BioPython]
+
<python>
 +
>>> import Bio
 +
</python>
 +
 
 +
If that gives no error, you should be done. If you get something like "ImportError: No module named Bio" something has gone wrong.
  
 
==Tutorial==
 
==Tutorial==
Line 13: Line 17:
 
==Quick example==
 
==Quick example==
  
Executing this:
+
Try executing this in python:
 
<python>
 
<python>
from Bio.Seq import Seq,translate
+
from Bio.Seq import Seq
  
#create a sequence object of some DNA
+
#create a sequence object
my_seq = Seq('CATGTAGATAG')
+
my_seq = Seq('CATGTAGACTAG')
  
 
#print out some details about it
 
#print out some details about it
print 'seq is %i bases long' % len(my_seq)
+
print 'seq %s is %i bases long' % (my_seq, len(my_seq))
print 'reverse complement is %s' % my_seq.reverse_complement().tostring()
+
print 'reverse complement is %s' % my_seq.reverse_complement()
 
+
print 'protein translation is %s' % my_seq.translate()
#or see the whole record
+
print 'sequence record:', my_seq
+
 
+
#translate the sequence into a protein
+
my_protein = translate(my_seq)
+
 
+
print 'protein translation is %s' % my_protein.tostring()
+
print 'protein record:', my_protein
+
 
+
 
</python>
 
</python>
  
Produces:
+
You should get the following output:
 
<pre>
 
<pre>
seq is 11 bases long
+
seq CATGTAGACTAG is 12 bases long
reverse complement is CTATCTACATG
+
reverse complement is CTAGTCTACATG
sequence record: Seq('CATGTAGATAG', Alphabet())
+
protein translation is HVD*
protein translation is HVD
+
protein record: Seq('HVD', HasStopCodon(IUPACProtein(), '*'))
+
 
</pre>
 
</pre>
 +
 +
This was a very quick demonstration of Biopython's [[Seq]] (sequence) object and some of its methods.
  
 
==Reading and writing Sequence Files==
 
==Reading and writing Sequence Files==
  
If you are using Biopython 1.43 or later, try out the new [[SeqIO]] module.
+
Use the [[SeqIO]] module for reading or writing sequences as [[SeqRecord]] objects.  For multiple sequence alignment files, you can alternatively use the [[AlignIO]] module.
  
 
==Beginners==
 
==Beginners==
Line 55: Line 50:
 
** [http://rgruet.free.fr/PQR25/PQR2.5.html Python Quick Reference]
 
** [http://rgruet.free.fr/PQR25/PQR2.5.html Python Quick Reference]
 
* Browse the [http://biopython.org/DIST/docs/tutorial/Tutorial.html Biopython Tutorial]
 
* Browse the [http://biopython.org/DIST/docs/tutorial/Tutorial.html Biopython Tutorial]
* Examine the [http://biopython.org/DIST/docs/api/public/trees.html Class Diagram] if you'd like to know more about the relationships between the modules.
+
* Read this paper <biblio>Bassi2007 pmid=18052533</biblio>
 +
* Examine the [http://biopython.org/DIST/docs/api Class Diagram] if you'd like to know more about the relationships between the modules.
  
 
==Further reading==
 
==Further reading==
  
 
* Use the Wiki Search tools to find more information on specific topics.
 
* Use the Wiki Search tools to find more information on specific topics.

Revision as of 12:24, 2 July 2010

Contents

Download and Installation

For Windows we provide click-and-run installers. Most Linux distributions will include an optional Biopython package (although this may be out of date). Otherwise you typically download and uncompress the archive, and install from source. See our downloads page for details including the prerequisites.

You can check your installation has worked at the python prompt:

>>> import Bio

If that gives no error, you should be done. If you get something like "ImportError: No module named Bio" something has gone wrong.

Tutorial

The Biopython Tutorial and Cookbook (HTML, PDF) contains the bulk of our documentation. See Documentation for more links.

Quick example

Try executing this in python:

from Bio.Seq import Seq
 
#create a sequence object
my_seq = Seq('CATGTAGACTAG')
 
#print out some details about it
print 'seq %s is %i bases long' % (my_seq, len(my_seq))
print 'reverse complement is %s' % my_seq.reverse_complement()
print 'protein translation is %s' % my_seq.translate()

You should get the following output:

seq CATGTAGACTAG is 12 bases long
reverse complement is CTAGTCTACATG
protein translation is HVD*

This was a very quick demonstration of Biopython's Seq (sequence) object and some of its methods.

Reading and writing Sequence Files

Use the SeqIO module for reading or writing sequences as SeqRecord objects. For multiple sequence alignment files, you can alternatively use the AlignIO module.

Beginners

  • Examine the Class Diagram if you'd like to know more about the relationships between the modules.

Further reading

  • Use the Wiki Search tools to find more information on specific topics.
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox