\chapter{Introduction}
\label{chapter:introduction}

\section{What is Biopython?}

Biopython is a collection of freely available Python (\url{https://www.python.org}) modules for computational molecular biology.
Python is an object oriented, interpreted, flexible language that is widely used for scientific computing. Python is easy to learn, has a very clear syntax and can easily be extended with modules written in C, C++ or FORTRAN.
Since its inception in 2000~\cite{chapman2000}, Biopython has been continuously developed and maintained by a large group of volunteers worldwide.

The Biopython web site (\url{http://www.biopython.org}) provides
an online resource for modules, scripts, and web links for developers
of Python-based software for bioinformatics use and research.
Biopython includes parsers for various bioinformatics file formats
(BLAST, Clustalw, FASTA, Genbank,...), access to online services
(NCBI, Expasy,...), a standard sequence class, sequence alignment and
motif analysis tools, clustering algorithms, a module for structural biology,
and a module for phylogenetics analysis.

\section{What can I find in the Biopython package}

The main Biopython releases have lots of functionality, including:

\begin{itemize}
  \item The ability to parse bioinformatics files into Python utilizable data structures, including support for the following formats:

  \begin{itemize}
    \item Blast output -- both from standalone and WWW Blast
    \item Clustalw
    \item FASTA
    \item GenBank
    \item PubMed and Medline
    \item ExPASy files, like Enzyme and Prosite
    \item SCOP, including `dom' and `lin' files
    \item UniGene
    \item SwissProt
  \end{itemize}

  \item Files in the supported formats can be iterated over record by record or indexed and accessed via a Dictionary interface.

  \item Code to deal with popular on-line bioinformatics destinations such as:

  \begin{itemize}
    \item NCBI -- Blast, Entrez and PubMed services
    \item ExPASy -- Swiss-Prot and Prosite entries, as well as Prosite searches
  \end{itemize}

  \item Interfaces to common bioinformatics programs such as:

  \begin{itemize}
    \item Standalone Blast from NCBI
    \item Clustalw alignment program
    \item EMBOSS command line tools
  \end{itemize}

  \item A standard sequence class that deals with sequences, ids on sequences, and sequence features.

  \item Tools for performing common operations on sequences, such as translation, transcription and weight calculations.

  \item Code to perform classification of data using k Nearest Neighbors, Naive Bayes or Support Vector Machines.

  \item Code for dealing with alignments, including a standard way to create and deal with substitution matrices.

  \item Code making it easy to split up parallelizable tasks into separate processes.

  \item GUI-based programs to do basic sequence manipulations, translations, BLASTing, etc.

  \item Extensive documentation and help with using the modules, including this file, on-line wiki documentation, the web site, and the mailing list.

  \item Integration with BioSQL, a sequence database schema also supported by the BioPerl and BioJava projects.

\end{itemize}

We hope this gives you plenty of reasons to download and start using Biopython!

\section{Installing Biopython}

All of the installation information for Biopython was separated from
this document to make it easier to keep updated.

The short version is use \verb|pip install biopython|, see the
\href{https://github.com/biopython/biopython/blob/master/README.rst}{main README}
file for other options.

\section{Frequently Asked Questions (FAQ)}

\begin{enumerate}

  \item \emph{How do I cite Biopython in a scientific publication?} \\
  Please cite our application note \cite[Cock \textit{et al.}, 2009]{cock2009}
  as the main Biopython reference.
  In addition, please cite any publications from the following list if appropriate, in particular as a reference for specific modules within Biopython (more information can be found on our website):
  \begin{itemize}
    \item For the official project announcement: \cite[Chapman and Chang, 2000]{chapman2000};
    \item For \verb+Bio.PDB+: \cite[Hamelryck and Manderick, 2003]{hamelryck2003a};
    \item For \verb+Bio.Cluster+: \cite[De Hoon \textit{et al.}, 2004]{dehoon2004};
    \item For \verb+Bio.Graphics.GenomeDiagram+: \cite[Pritchard \textit{et al.}, 2006]{pritchard2006};
    \item For \verb+Bio.Phylo+ and \verb+Bio.Phylo.PAML+: \cite[Talevich \textit{et al.}, 2012]{talevich2012};
    \item For the FASTQ file format as supported in Biopython, BioPerl, BioRuby, BioJava, and EMBOSS: \cite[Cock \textit{et al.}, 2010]{cock2010}.
  \end{itemize}

  \item \emph{How should I capitalize ``Biopython''?  Is ``BioPython'' OK?} \\
  The correct capitalization is ``Biopython'', not ``BioPython'' (even though
  that would have matched BioPerl, BioJava and BioRuby).

  \item \emph{How is the Biopython software licensed?} \\
  Biopython is distributed under the \emph{Biopython License Agreement}.
  However, since the release of Biopython 1.69, some files are explicitly
  dual licensed under your choice of the \emph{Biopython License Agreement}
  or the \emph{BSD 3-Clause License}. This is with the intention of later
  offering all of Biopython under this dual licensing approach.

  \item \emph{What is the Biopython logo and how is it licensed?} \\
  As of July 2017 and the Biopython 1.70 release, the Biopython logo is a
  yellow and blue snake forming a double helix above the word ``biopython''
  in lower case. It was designed by Patrick Kunzmann and this logo is dual
  licensed under your choice of the \emph{Biopython License Agreement} or
  the \emph{BSD 3-Clause License}.

\begin{latexonly}
  \includegraphics[width=6cm]{images/biopython_logo.pdf}\\
\end{latexonly}
\begin{rawhtml}
  <IMG ALIGN="center" SRC="images/biopython_logo.svg" TITLE="Biopython Logo (2017 onwards)" ALT="[New Biopython Logo]" width="300" height="200" />
  <IMG ALIGN="center" SRC="images/biopython_logo_old.jpg" TITLE="Old Biopython Logo (2003-2017)" ALT="[Old Biopython Logo]" width="512" height="144" />
\end{rawhtml}

  Prior to this, the Biopython logo was two yellow snakes forming a double
  helix around the word ``BIOPYTHON'', designed by Henrik Vestergaard and
  Thomas Hamelryck in 2003 as part of an open competition.

\begin{latexonly}
  \includegraphics[width=7cm]{images/biopython_logo_old.jpg}\\
\end{latexonly}

  \item \emph{Do you have a change-log listing what's new in each release?} \\
  See the file \verb|NEWS.rst| included with the source code (originally called
  just \verb|NEWS|), or read the
  \href{https://github.com/biopython/biopython/blob/master/NEWS.rst}{latest NEWS file on GitHub}.

  \item \emph{What is going wrong with my print commands?} \\
  As of Biopython 1.77, we only support Python 3, so this tutorial
  uses the Python 3 style print \emph{function}.

  \item \emph{How do I find out what version of Biopython I have installed?} \\
  Use this:
\begin{minted}{pycon}
>>> import Bio
>>> print(Bio.__version__)
\end{minted}
  If the ``\verb|import Bio|'' line fails, Biopython is not installed.
  Note that those are double underscores before and after version.
  If the second line fails, your version is \emph{very} out of date.

  If the version string ends with a plus like ``\verb|1.66+|'', you
  don't have an official release, but an old snapshot of the in
  development code \emph{after} that version was released. This naming
  was used until June 2016 in the run-up to Biopython 1.68.

  If the version string ends with ``\verb|.dev<number>|'' like
  ``\verb|1.68.dev0|'', again you don't have an official release,
  but instead a snapshot of the in development code \emph{before}
  that version was released.

  \item \emph{Where is the latest version of this document?}\\
  If you download a Biopython source code archive, it will include the
  relevant version in both HTML and PDF formats.  The latest published
  version of this document (updated at each release) is online:
  \begin{itemize}
  \item \url{http://biopython.org/DIST/docs/tutorial/Tutorial.html}
  \item \url{http://biopython.org/DIST/docs/tutorial/Tutorial.pdf}
  \end{itemize}

  \item \emph{What is wrong with my sequence comparisons?} \\
  There was a major change in Biopython 1.65 making the \verb|Seq| and
  \verb|MutableSeq| classes (and subclasses) use simple string-based
  comparison which you can do explicitly with \verb|str(seq1) == str(seq2)|.

  Older versions of Biopython would use instance-based comparison
  for \verb|Seq| objects which you can do explicitly with
  \verb|id(seq1) == id(seq2)|.

  If you still need to support old versions of Biopython, use these
  explicit forms to avoid problems. See Section~\ref{sec:seq-comparison}.

  \item \emph{What file formats do} \verb|Bio.SeqIO| \emph{and} \verb|Bio.AlignIO| \emph{read and write?} \\
  Check the built in docstrings (\texttt{from Bio import SeqIO}, then \texttt{help(SeqIO)}), or see \url{http://biopython.org/wiki/SeqIO} and \url{http://biopython.org/wiki/AlignIO} on the wiki for the latest listing.

  \item \emph{Why won't the } \verb|Bio.SeqIO| \emph{and} \verb|Bio.AlignIO| \emph{functions} \verb|parse|\emph{,} \verb|read| \emph{and} \verb|write| \emph{take filenames? They insist on handles!} \\
  You need Biopython 1.54 or later, or just use handles explicitly (see Section~\ref{sec:appendix-handles}).
  It is especially important to remember to close output handles explicitly after writing your data.

  \item \emph{Why won't the } \verb|Bio.SeqIO.write()| \emph{and} \verb|Bio.AlignIO.write()| \emph{functions accept a single record or alignment? They insist on a list or iterator!} \\
  You need Biopython 1.54 or later, or just wrap the item with \verb|[...]| to create a list of one element.

  \item \emph{Why doesn't} \verb|str(...)| \emph{give me the full sequence of a} \verb|Seq| \emph{object?} \\
  You need Biopython 1.45 or later.

  \item \emph{Why doesn't} \verb|Bio.Blast| \emph{work with the latest plain text NCBI blast output?} \\
  The NCBI keep tweaking the plain text output from the BLAST tools, and keeping our parser up to date is/was an ongoing struggle.
  If you aren't using the latest version of Biopython, you could try upgrading.
  However, we (and the NCBI) recommend you use the XML output instead, which is designed to be read by a computer program.

  \item \emph{Why has my script using} \verb|Bio.Entrez.efetch()| \emph{stopped working?} \\
  This could be due to NCBI changes in February 2012 introducing EFetch 2.0.
  First, they changed the default return modes - you probably want to add \verb|retmode="text"| to
  your call.
  Second, they are now stricter about how to provide a list of IDs -- Biopython 1.59 onwards
  turns a list into a comma separated string automatically.

  \item \emph{Why doesn't} \verb|Bio.Blast.NCBIWWW.qblast()| \emph{give the same results as the NCBI BLAST website?} \\
  You need to specify the same options -- the NCBI often adjust the default settings on the website,
  and they do not match the QBLAST defaults anymore. Check things like the gap penalties and expectation threshold.

  \item \emph{Why can't I add} \verb|SeqRecord| \emph{objects together?} \\
  You need Biopython 1.53 or later.

  \item \emph{Why doesn't} \verb|Bio.SeqIO.index_db()| \emph{work? The module imports fine but there is no \texttt{index\_db} function!} \\
  You need Biopython 1.57 or later (and a Python with SQLite3 support).

  \item \emph{Where is the} \verb|MultipleSeqAlignment| \emph{object? The} \verb|Bio.Align| \emph{module imports fine but this class isn't there!} \\
  You need Biopython 1.54 or later. Alternatively, the older \verb|Bio.Align.Generic.Alignment| class supports some of its functionality, but using this is now discouraged.

  \item \emph{Why can't I run command line tools directly from the application wrappers?} \\
  You need Biopython 1.55 or later, but these were deprecated in Biopython 1.78. Consider using the Python \verb|subprocess| module directly.

  \item \emph{I looked in a directory for code, but I couldn't find the code that does something. Where's it hidden?} \\
  One thing to know is that we put code in \verb|__init__.py| files. If you are not used to looking for code in this file this can be confusing. The reason we do this is to make the imports easier for users. For instance, instead of having to do a ``repetitive'' import like \verb|from Bio.GenBank import GenBank|, you can just use \verb|from Bio import GenBank|.

  \item \emph{Why doesn't} \verb|Bio.Fasta| \emph{work?} \\
  We deprecated the \verb|Bio.Fasta| module in Biopython 1.51 (August 2009) and removed it in Biopython 1.55 (August 2010). There is a brief example showing how to convert old code to use \verb|Bio.SeqIO| instead in the \href{https://github.com/biopython/biopython/blob/master/DEPRECATED.rst}{DEPRECATED.rst} file.

\end{enumerate}

\noindent For more general questions, the Python FAQ pages \url{https://docs.python.org/3/faq/index.html} may be useful.
