Repository 'codonlogo'
hg clone https://toolshed.g2.bx.psu.edu/repos/davidmurphy/codonlogo

Changeset 4:4d47ab2b7bcc (2012-01-13)
Previous changeset 3:09d2dac9ef73 (2012-01-13) Next changeset 5:b89bb51eba83 (2012-01-16)
Commit message:
Uploaded
added:
Codonlogo.xml
LICENSE.txt
PKG-INFO
README.txt
build_test.sh
cap.fa
capu.fa
codonlogo
corebio/__init__.py
corebio/_future/__init__.py
corebio/_future/_string.py
corebio/_future/subprocess.py
corebio/_version.py
corebio/data.py
corebio/data/blosum100.mat
corebio/data/blosum35.mat
corebio/data/blosum40.mat
corebio/data/blosum45.mat
corebio/data/blosum50.mat
corebio/data/blosum62.mat
corebio/data/blosum80.mat
corebio/data/dist20_comp.mat
corebio/data/pam120.mat
corebio/data/pam250.mat
corebio/moremath.py
corebio/resource/__init__.py
corebio/resource/astral.py
corebio/resource/scop.py
corebio/resource/stride.py
corebio/seq.py
corebio/seq_io/__init__.py
corebio/seq_io/_nexus/Nodes.py
corebio/seq_io/_nexus/Trees.py
corebio/seq_io/_nexus/__init__.py
corebio/seq_io/array_io.py
corebio/seq_io/clustal_io.py
corebio/seq_io/fasta_io.py
corebio/seq_io/genbank_io.py
corebio/seq_io/intelligenetics_io.py
corebio/seq_io/msf_io.py
corebio/seq_io/nbrf_io.py
corebio/seq_io/nexus_io.py
corebio/seq_io/null_io.py
corebio/seq_io/phylip_io.py
corebio/seq_io/plain_io.py
corebio/seq_io/stockholm_io.py
corebio/seq_io/table_io.py
corebio/ssearch_io/__init__.py
corebio/ssearch_io/blastxml.py
corebio/ssearch_io/fasta.py
corebio/transform.py
corebio/utils/__init__.py
corebio/utils/_which.py
corebio/utils/deoptparse.py
examplepriorfile.txt
inter.py
setup.py
test_weblogo.py
tests/data/Rv3829c.fasta
tests/data/cap.fa
tests/data/capu.fa
tests/data/cox2.msf
weblogolib/.___init__.py
weblogolib/__init__.py
weblogolib/_cgi.py
weblogolib/color.py
weblogolib/colorscheme.py
weblogolib/htdocs/create.cgi
weblogolib/htdocs/create_html_template.html
weblogolib/htdocs/examples.html
weblogolib/htdocs/img/example.png
weblogolib/htdocs/img/feed-icon-16x16.png
weblogolib/htdocs/img/weblogo-fig1.png
weblogolib/htdocs/img/weblogo_create.png
weblogolib/htdocs/index.html
weblogolib/htdocs/logo.css
weblogolib/htdocs/manual.html
weblogolib/htdocs/test.html
weblogolib/template.eps
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc Codonlogo.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Codonlogo.xml Fri Jan 13 07:18:19 2012 -0500
b
b'@@ -0,0 +1,557 @@\n+<tool id="codonlogo" name="Codon Logo" version="3">\n+  <description>generator for fasta (eg Clustal alignments)</description>\n+  <command interpreter="python -W ignore::DeprecationWarning"> \n+    codonlogo -F $outformat -s $size -f $input -o $output -t "$logoname" -m $frame -n $stacks -X $showxaxis --show-yaxis $showyaxis --errorbars $errorbars \n+\n+    #if str($ylabel) != \'\'\n+    -x $xlabel \n+    #end if\n+    \n+    #if str( $ylabel) != \'\'\n+    -y $ylabel \n+    #end if\n+    #if $range.mode == \'part\'\n+    -l "$range.seqstart" -u "$range.seqend" \n+    #end if\n+    #if $comp.mode == \'equiprobable\'\n+    --composition \'equiprobable\' \n+    #end if\n+    #if $comp.mode == \'none\'\n+    --composition \'none\' \n+    #end if\n+    #if $comp.mode == \'file\'\n+    -R $compfile \n+    #end if\n+    \n+    #if $colours.colour == \'part\'\n+    \n+      #if str( $colours.colorAAA) != \'\' \n+      -C $colours.colorAAA AAA "" \n+      #end if\n+      \n+      #if str( $colours.colorAAC) != \'\' \n+      -C $colours.colorAAC AAC "" \n+      #end if\n+      \n+      #if str( $colours.colorAAG) != \'\' \n+      -C  $colours.colorAAG AAG "" \n+      #end if\n+      \n+      #if str( $colours.colorAAU) != \'\' \n+      -C  $colours.colorAAU AAU "" \n+      -C  $colours.colorAAU AAT "" \n+      #end if\n+      \n+      #if str( $colours.colorACA) != \'\' \n+      -C $colours.colorACA ACA "" \n+      #end if\n+      \n+      #if str( $colours.colorACC) != \'\' \n+      -C  $colours.colorACC  ACC "" \n+      #end if\n+      \n+      #if str( $colours.colorACG) != \'\' \n+      -C  $colours.colorACG ACG "" \n+      #end if\n+      \n+      #if str( $colours.colorACU) != \'\' \n+      -C  $colours.colorACU ACU "" \n+      -C  $colours.colorACU ACT "" \n+      #end if\n+      \n+      #if str( $colours.colorAGA) != \'\' \n+      -C  $colours.colorAGA AGA "" \n+      #end if\n+      \n+      #if str( $colours.colorAGC) != \'\' \n+      -C  $colours.colorAGC AGC "" \n+      #end if\n+      \n+      #if str( $colours.colorAGG) != \'\' \n+      -C  $colours.colorAGG AGG "" \n+      #end if\n+      \n+      #if str( $colours.colorAGU) != \'\' \n+      -C  $colours.colorAGU AGU "" \n+      -C  $colours.colorAGU AGT "" \n+      #end if\n+      \n+      #if str( $colours.colorAUA) != \'\' \n+      -C  $colours.colorAUA AUA "" \n+      -C  $colours.colorAUA ATA "" \n+      #end if\n+      \n+      #if str( $colours.colorAUC) != \'\' \n+      -C  $colours.colorAUC AUC  "" \n+      -C  $colours.colorAUC ATC "" \n+      #end if\n+      \n+      #if str( $colours.colorAUG) != \'\' \n+      -C  $colours.colorAUG AUG "" \n+      -C  $colours.colorAUG ATG "" \n+      #end if\n+      \n+      #if str( $colours.colorAUU) != \'\' \n+      -C  $colours.colorAUU AUU "" \n+      -C  $colours.colorAUU ATT "" \n+      #end if\n+      \n+      #if str( $colours.colorCAA) != \'\' \n+      -C  $colours.colorCAA CAA "" \n+      #end if\n+      \n+      #if str( $colours.colorCAC) != \'\' \n+      -C  $colours.colorCAC CAC "" \n+      #end if\n+      \n+      #if str( $colours.colorCAG) != \'\' \n+      -C  $colours.colorCAG CAG "" \n+      #end if\n+      \n+      #if str( $colours.colorCAU) != \'\' \n+      -C  $colours.colorCAU CAU "" \n+      -C  $colours.colorCAU CAT "" \n+      #end if\n+      \n+      #if str( $colours.colorCCA) != \'\' \n+      -C  $colours.colorCCA CCA "" \n+      #end if\n+      \n+      #if str( $colours.colorCCC) != \'\' \n+      -C  $colours.colorCCC CCC "" \n+      #end if\n+      \n+      #if str( $colours.colorCCG) != \'\' \n+      -C  $colours.colorCCG CCG "" \n+      #end if\n+      \n+      #if str( $colours.colorCCU) != \'\' \n+      -C  $colours.colorCCU CCU "" \n+      -C  $colours.colorCCU CCT "" \n+      #end if\n+      \n+      #if str( $colours.colorCGA) != \'\' \n+      -C  $colours.colorCGA CGA "" \n+      #end if\n+      \n+      #if str( $colours.colorCGC) != \'\' \n+      -C  $colours.colorCGC CGC "" \n+      #end if\n+      \n+      #if str( $colours.colorCGG) != \'\' \n+      -C  $colours.colorCGG CGG "" \n+      #end if\n+      \n+      #if str( $colours.colorCGU) != \'\' \n+      -C  $colours.colo'..b'value="" label="GUA" />\n+        <param name="colorGUC" size="10" type="text" value="" label="GUC" />\n+        <param name="colorGUG" size="10" type="text" value="" label="GUG" />\n+        <param name="colorGUU" size="10" type="text" value="" label="GUU" />\n+        <param name="colorUAA" size="10" type="text" value="" label="UAA" />\n+        <param name="colorUAC" size="10" type="text" value="" label="UAC" />\n+        <param name="colorUAG" size="10" type="text" value="" label="UAG" />\n+        <param name="colorUAU" size="10" type="text" value="" label="UAU" />\n+        <param name="colorUCA" size="10" type="text" value="" label="UCA" />\n+        <param name="colorUCC" size="10" type="text" value="" label="UCC" />\n+        <param name="colorUCG" size="10" type="text" value="" label="UCG" />\n+        <param name="colorUCU" size="10" type="text" value="" label="UCU" />\n+        <param name="colorUGA" size="10" type="text" value="" label="UGA" />\n+        <param name="colorUGC" size="10" type="text" value="" label="UGC" />\n+        <param name="colorUGG" size="10" type="text" value="" label="UGG" />\n+        <param name="colorUGU" size="10" type="text" value="" label="UGU" />\n+        <param name="colorUUA" size="10" type="text" value="" label="UUA" />\n+        <param name="colorUUC" size="10" type="text" value="" label="UUC" />\n+        <param name="colorUUG" size="10" type="text" value="" label="UUG" />\n+        <param name="colorUUU" size="10" type="text" value="" label="UUU" />\n+        \n+\n+        \n+      </when>\n+      \n+    </conditional>\n+    <param name="size" type="select" label="Output CodonLogo size" >\n+      <option value="large" selected="True">Large</option>\n+      <option value="medium">Medium</option>\n+      <option value="small">Small</option>\n+    </param>\n+    \n+   </page>\n+  </inputs>\n+  <outputs>\n+    <data format="pdf" name="output"  label="${logoname}_output.${outformat}">\n+       <change_format>\n+           <when input="outformat" value="png_print" format="png" />\n+           <when input="outformat" value="png" format="png" />\n+           <when input="outformat" value="jpeg" format="jpg" />\n+           <when input="outformat" value="eps" format="eps" />\n+           <when input="outformat" value="txt" format="txt" />\n+       </change_format>\n+    </data>\n+  </outputs>\n+  <help>\n+\n+**Note**\n+\n+This tool uses CodonLogo in Galaxy to generate a sequence logo from a provided alignment. \n+The input file must be an alignment in your current history.\n+The tool will attempt to read a provided file and if it is unable to it will generate an error.\n+\n+A typical output looks like this\n+\n+.. image:: ./static/images/CodonLogoExample.png\n+\n+----\n+\n+**Warning about input files**\n+\n+The  program used by this tool will fail if your alignment files are not all the same length.\n+\n+Fasta alignments from ClustalW Galaxy tool will work but many other fasta files may cause this tool to produce an error and fail - please do not file \n+a Galaxy bug report - this is a feature of the tool and a problem with your source data - not a tool error - please make certain all your fasta \n+sequences are the same length!\n+\n+Files must first be converted to fasta format in order to be used with this tool.\n+\n+----\n+\n+The default colour scheme is based on associated amino acid types:\n+\n+Polar positive \n+H, K, R  -Light Blue\n+\n+Polar negative  \n+D, E    -Red\n+\n+Polar neutral   \n+S, T, N, Q      -Green\n+\n+Non-polar aliphatic     \n+A, V, L, I, M   -Blue\n+\n+Non-polar aromatic      \n+F, W, Y         -Magenta\n+P, G    -Brown\n+C       -Yellow\n+\n+Stop codons     -Black\n+\n+\n+**Attribution**\n+\n+\n+This Galaxy wrapper was modified for CodonLogo by David Murphy and is based on the wrapper written by Ross Lazarus for the rgenetics project and the source code is licensed under the LGPL_ \n+\n+.. _Weblogo3: http://weblogo.berkeley.edu/\n+.. _LGPL: http://www.gnu.org/copyleft/lesser.html\n+.. _CodonLogo: http://recode.ucc.ie/CodonLogo \n+\n+  </help>\n+\n+</tool>\n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc LICENSE.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE.txt Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,136 @@
+===============================================================================
+
+ CoreBio Weblogo and Codonlogo : Copyrights and Licenses
+
+===============================================================================
+
+This package is distributed under the new BSD Open Source License. Much 
+of the code was written by Gavin E. Crooks, Gary Hon, Steven Brenner, John-Marc
+Chandonia, Liana Lareau, David Ding, Clare Gollnick,David Murphy and other contributers.
+
+
+
+Copyright Notice 
+================
+Copyright (c) 2006, The Regents of the University of California, through
+Lawrence Berkeley National Laboratory (subject to receipt of any required 
+approvals from the U.S. Dept. of Energy).  All rights reserved.
+
+Parts of this software package are covered by the individual copyrights of the
+contributers. Please refer to individual source code files for further details.
+
+NOTICE.  This software was developed under funding from the U.S. Department of 
+Energy.  As such, the U.S. Government has been granted for itself and others 
+acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in 
+the Software to reproduce, prepare derivative works, and perform publicly and 
+display publicly.  Beginning five (5) years after the date permission to assert 
+copyright is obtained from the U.S. Department of Energy, and subject to any 
+subsequent five (5) year renewals, the U.S. Government is granted for itself 
+and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide 
+license in the Software to reproduce, prepare derivative works, distribute 
+copies to the public, perform publicly and display publicly, and to permit 
+others to do so.
+
+
+The new BSD Open Source License 
+===============================
+
+#  Copyright (c) 2006, The Regents of the University of California, through 
+#  Lawrence Berkeley National Laboratory (subject to receipt of any required
+#  approvals from the U.S. Dept. of Energy).  All rights reserved.
+
+#  This software is distributed under the new BSD Open Source License.
+#  <http://www.opensource.org/licenses/bsd-license.html>
+#
+#  Redistribution and use in source and binary forms, with or without 
+#  modification, are permitted provided that the following conditions are met: 
+#
+#  (1) Redistributions of source code must retain the above copyright notice, 
+#  this list of conditions and the following disclaimer. 
+#
+#  (2) Redistributions in binary form must reproduce the above copyright 
+#  notice, this list of conditions and the following disclaimer in the 
+#  documentation and or other materials provided with the distribution. 
+#
+#  (3) Neither the name of the University of California, Lawrence Berkeley 
+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors 
+#  may be used to endorse or promote products derived from this software 
+#  without specific prior written permission. 
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#  POSSIBILITY OF SUCH DAMAGE. 
+
+
+
+The MIT Open Source License 
+===========================
+
+Parts of the code are covered by the MIT license, which is equivalent to the
+BSD license apart from the third, no promotion clause. Please refer to
+individual source code files for further details.
+
+#  Copyright (c) 2003-2004 The Regents of the University of California.
+#  Copyright (c) 2005 Gavin E. Crooks
+#  Copyright (c) 2006 David Ding
+#  Copyright (c) 2006 Clare Gollnick
+#  Copyright (c) 2002-2005 ActiveState Corp.
+
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
+#  IN THE SOFTWARE.
+
+
+
+The Biopython License (biopython.org)
+=====================================
+Parts of the code are covered by the biopython license, which is functionally
+equivalent to the BSD license.
+
+   
+#                Biopython License Agreement
+# 
+# Permission to use, copy, modify, and distribute this software and its
+# documentation with or without modifications and for any purpose and
+# without fee is hereby granted, provided that any copyright notices
+# appear in all copies and that both those copyright notices and this
+# permission notice appear in supporting documentation, and that the
+# names of the contributors or copyright holders not be used in
+# advertising or publicity pertaining to distribution of the software
+# without specific prior permission.
+
+# THE CONTRIBUTORS AND COPYRIGHT HOLDERS OF THIS SOFTWARE DISCLAIM ALL
+# WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
+# CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT
+# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+# OR PERFORMANCE OF THIS SOFTWARE.
+   
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc PKG-INFO
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PKG-INFO Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,62 @@
+Metadata-Version: 1.0
+Name: weblogo
+Version: 3.0
+Summary: WebLogo3 : Sequence Logos Redrawn
+Home-page: http://code.google.com/p/weblogo/
+Author: Gavin Crooks
+Author-email: gec@threeplusone.com
+License: UNKNOWN
+Download-URL: http://weblogo.googlecode.com/svn/dist/weblogo-3.0.tar.gz
+Description: 
+        WebLogo (http://code.google.com/p/weblogo/) is a tool for creating sequence
+        logos from biological sequence alignments.  It can be run on the command line,
+        as a standalone webserver, as a CGI webapp, or as a python library.
+        
+        The main WebLogo webserver is located at http://bespoke.lbl.gov/weblogo/
+        
+        Please consult the manual for installation instructions and more information:
+        (Also located in the weblogolib/htdocs subdirectory.)
+        
+        http://bespoke.lbl.gov/weblogo/manual.html
+        
+        For help on the command line interface run
+        ./weblogo --help
+        
+        To build a simple logo run
+        ./weblogo  < cap.fa > logo0.eps
+        
+        To run as a standalone webserver at localhost:8080
+        ./weblogo --server
+        
+        To create a logo in python code:
+        >>> from weblogolib import *
+        >>> fin = open('cap.fa')
+        >>> seqs = read_seq_data(fin)
+        >>> data = LogoData.from_seqs(seqs)
+        >>> options = LogoOptions()
+        >>> options.title = "A Logo Title"
+        >>> format = LogoFormat(data, options)
+        >>> fout = open('cap.eps', 'w')
+        >>> eps_formatter( data, format, fout)
+        
+        
+        -- Distribution and Modification --
+        This package is distributed under the new BSD Open Source License.
+        Please see the LICENSE.txt file for details on copyright and licensing.
+        The WebLogo source code can be downloaded from
+        http://code.google.com/p/weblogo/
+        
+        WebLogo requires Python 2.3, 2.4 or 2.5, the corebio python toolkit for
+        computational biology (http://code.google.com/p/corebio), and the python
+        array package 'numpy' (http://www.scipy.org/Download)
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Science/Research
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
+Classifier: Programming Language :: Python
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc README.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README.txt Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,38 @@
+
+CodonLogo (http://recode.ucc.ie/CodonLogo) is a tool for creating sequence 
+logos from biological sequence alignments.  It can be run on the command line,
+as a standalone webserver or as a CGI webapp.
+
+
+For help on the command line interface run
+    ./codonlogo --help
+
+To build a simple logo run
+    ./codonlogo  < cap.fa > logo.eps
+
+
+To run as a standalone webserver at localhost:8080 
+    ./codonlogo --server
+
+
+An example file of probabilities is included, examplepriorfile.txt
+It can be used with the following command.
+
+    ./codonlogo --prior examplepriorfile.txt < cap.fa > logo.eps
+
+
+There is a known issue with GPL Ghostscript 9.04 which affects some users which may cause ghostscript to segfault. 
+This is not believed to be a problem with CodonLogo.
+This is being investigated. if you encounter this problem it's recommended to downgrade to version 9.01 or earlier of ghostscript.
+
+
+
+-- Distribution and Modification --
+This package is distributed under the new BSD Open Source License. 
+Please see the LICENSE.txt file for details on copyright and licensing.
+The CodonLogo source code can be downloaded from 
+http://recode.ucc.ie/CodonLogo
+
+CodonLogo requires Python 2.6 or 2.7, the corebio python toolkit for
+computational biology (http://code.google.com/p/corebio), and the python
+array package 'numpy' (http://www.scipy.org/Download)
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc build_test.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/build_test.sh Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,148 @@
+
+mkdir -p tmp
+
+echo "# Test weblogo by building logos with many different options."
+
+echo -ne '.'
+./weblogo  < cap.fa > tmp/logo0.eps ||exit
+
+echo -ne '.'
+./weblogo --title "Default Logo with Title" < cap.fa > tmp/logo1.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "Default Logo with this fineprint and debug on" < cap.fa > tmp/logo2.eps ||exit
+
+echo -ne '.'
+./weblogo --debug no  --fineprint "--debug no"   --debug no < cap.fa > tmp/logo3.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "" --title "No fine print" --debug yes < cap.fa > tmp/logo4.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "No title" --title "" < cap.fa > tmp/logo5.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "--first-index -10" --first-index -10 < cap.fa > tmp/logo6.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint " --first-index -10 --stacks-per-line 11 " --first-index -10 --stacks-per-line 11 < cap.fa > tmp/logo7a.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint " --first-index -10 --stacks-per-line 8 " --first-index -10 --stacks-per-line 8 < cap.fa > tmp/logo7b.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint " --first-index -10 --stacks-per-line 7 " --first-index -10 --stacks-per-line 7 < cap.fa > tmp/logo7c.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "Test fin and fout" --fin cap.fa  --fout logo8.eps ||exit
+
+# Test Y Axis
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "Custom yaxis label " --ylabel 'yaxis label' < cap.fa > tmp/logo9a.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "Custom units" --units 'nats' < cap.fa > tmp/logo9b.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "Override custom units with custom yaxis label."  --ylabel 'yaxis label' --units nats < cap.fa > tmp/logo9c.eps ||exit
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "Empty ylabel"  --ylabel '' < cap.fa > tmp/logo9d.eps
+
+echo -ne '.'
+./weblogo --debug yes --fineprint "No Yaxis"  --show-yaxis no  < cap.fa > tmp/logo9e.eps ||exit
+
+# Test X Axis
+
+echo -ne '.'
+./weblogo --debug yes --format pdf --fineprint "Custom xaxis label " --xlabel 'xaxis label' < cap.fa > tmp/logo10a.pdf ||exit
+
+echo -ne '.'
+./weblogo --debug yes --format pdf --fineprint "Empty xlabel"  --xlabel '' < cap.fa > tmp/logo10b.pdf ||exit
+
+echo -ne '.'
+./weblogo --debug yes --format pdf --fineprint "No Xaxis"  --show-xaxis no  < cap.fa > tmp/logo10c.pdf ||exit
+
+echo -ne '.'
+./weblogo --debug yes --format pdf --fineprint "No Xaxis, custom label"  --xlabel "Custom xlabel" --show-xaxis no  < cap.fa > tmp/logo10d.pdf ||exit
+
+# Test Formats
+
+echo -ne '.'
+./weblogo --debug no  --fineprint "Format: eps" --format eps < cap.fa > tmp/logo11a.eps ||exit
+
+echo -ne '.'
+./weblogo --debug no  --fineprint "Format: png" --size large --format png < cap.fa > tmp/logo11b.png ||exit
+
+echo -ne '.'
+./weblogo --debug no  --fineprint "Format: png high res" --format png_print < cap.fa > tmp/logo11c.png ||exit
+
+echo -ne '.'
+./weblogo --debug no  --fineprint "Format: pdf" --format pdf < cap.fa > tmp/logo11d.pdf ||exit
+
+echo -ne '.'
+./weblogo --debug no  --fineprint "Format: jpeg" --size large --format jpeg < cap.fa > tmp/logo11e.jpeg ||exit
+
+echo -ne '.'
+./weblogo --debug no  --fineprint "Format: EPS" --format EPS < cap.fa > tmp/logo11f.eps ||exit
+
+# Test Sizes
+
+echo -ne '.'
+./weblogo --debug no  --format png_print --fineprint "default size" < cap.fa > tmp/logo12_default.png ||exit
+
+echo -ne '.'
+./weblogo --debug no  --format png_print --fineprint "--size large" --size large < cap.fa > tmp/logo12_large.png ||exit
+
+echo -ne '.'
+./weblogo --debug no  --format png_print --fineprint "--size medium" --size medium < cap.fa > tmp/logo12_medium.png ||exit
+
+echo -ne '.'
+./weblogo --debug no  --format png_print --fineprint "--size small" --size small < cap.fa > tmp/logo12_small.png ||exit
+
+
+
+echo -ne '.'
+./weblogo --format pdf --fineprint ""  > tmp/logo13.pdf << LimitString
+>
+GTTGTTGTTGTT
+>
+GTCGTCGTCGTC
+>
+GGGGGGGGGGGG
+>
+GGAGGAGGAGGA
+LimitString
+
+
+
+
+# Test unit options
+echo -ne '.'
+./weblogo --format pdf --fineprint "probability" --unit probability  > tmp/logo14a.pdf < cap.fa ||exit
+
+echo -ne '.'
+./weblogo --format pdf --fineprint "bits" --unit bits  > tmp/logo14b.pdf < cap.fa ||exit
+
+echo -ne '.'
+./weblogo --format pdf --fineprint "nats" --unit nats  > tmp/logo14c.pdf < cap.fa ||exit
+
+echo -ne '.'
+./weblogo --format pdf --fineprint "kJ/mol" --unit kJ/mol \
+     > tmp/logo14d.pdf < cap.fa ||exit
+
+echo -ne '.'
+./weblogo --format pdf --fineprint "kT" --unit kT  \
+    > tmp/logo14e.pdf < cap.fa ||exit
+
+echo -ne '.'
+./weblogo --format pdf --fineprint "kcal/mol" --unit kcal/mol \
+    > tmp/logo14f.pdf < cap.fa || exit
+
+
+
+
+
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc cap.fa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cap.fa Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,98 @@
+>aldB -18->4
+attcgtgatagctgtcgtaaag
+>ansB 103->125
+ttttgttacctgcctctaactt
+>araB1 109->131
+aagtgtgacgccgtgcaaataa
+>araB2 147->169 
+tgccgtgattatagacactttt
+>cdd 1 107->129
+atttgcgatgcgtcgcgcattt
+>cdd 2 57->79
+taatgagattcagatcacatat
+>crp 1 115->137
+taatgtgacgtcctttgcatac
+>crp 2
+gaaggcgacctgggtcatgctg
+>cya 151->173 
+aggtgttaaattgatcacgttt
+>cytR 1 125->147
+cgatgcgaggcggatcgaaaaa
+>cytR 2 106->128
+aaattcaatattcatcacactt
+>dadAX 1 95->117
+agatgtgagccagctcaccata
+>dadAX 2 32->54
+agatgtgattagattattattc
+>deoP2 1 75->97
+aattgtgatgtgtatcgaagtg
+>deoP2 2 128->150 
+ttatttgaaccagatcgcatta
+>fur 136->158
+aaatgtaagctgtgccacgttt
+>gal 56->78
+aagtgtgacatggaataaatta
+>glpACB (glpTQ) 1 54->76  
+ttgtttgatttcgcgcatattc
+>glpACB (glpTQ) 2 94->116
+aaacgtgatttcatgcgtcatt
+>glpACB (glpTQ) 144->166 
+atgtgtgcggcaattcacattt
+>glpD (glpE) 95->117 
+taatgttatacatatcactcta
+>glpFK 1 120->142
+ttttatgacgaggcacacacat
+>glpFK 2 95->117
+aagttcgatatttctcgttttt
+>gut (srlA) 72->94
+ttttgcgatcaaaataacactt
+>ilvB 87->109
+aaacgtgatcaacccctcaatt
+>lac 1 (lacZ) 88->110
+taatgtgagttagctcactcat
+>lac 2 (lacZ) 16->38 
+aattgtgagcggataacaattt
+>malEpKp1 110->132
+ttgtgtgatctctgttacagaa
+>malEpKp2 139->161
+TAAtgtggagatgcgcacaTAA
+>malEpKp3 173->195
+TTTtgcaagcaacatcacgAAA
+>malEpKp4 205->227
+GACctcggtttagttcacaGAA
+>malT 121->143
+aattgtgacacagtgcaaattc
+>melR 52->74
+aaccgtgctcccactcgcagtc
+>mtl 302->324
+TCTTGTGATTCAGATCACAAAG
+>nag 156->178
+ttttgtgagttttgtcaccaaa
+>nupG2 97->119
+aaatgttatccacatcacaatt
+>nupG1 47->69
+ttatttgccacaggtaacaaaa
+>ompA 166->188
+atgcctgacggagttcacactt
+>ompR 161->183
+taacgtgatcatatcaacagaa
+>ptsH A 316->338
+Ttttgtggcctgcttcaaactt
+>ptsH B 188->210
+ttttatgatttggttcaattct
+>rhaS (rhaB) 161->183 
+aattgtgaacatcatcacgttc
+>rot 1 (ppiA) 182->204 
+ttttgtgatctgtttaaatgtt
+>rot 2 (ppiA) 129->151
+agaggtgattttgatcacggaa
+>tdcA 60->82
+atttgtgagtggtcgcacatat
+>tnaL 73->95
+gattgtgattcgattcacattt
+>tsx 2 146->168
+gtgtgtaaacgtgaacgcaatc
+>tsx 1 107->129
+aactgtgaaacgaaacatattt
+>uxuAB 165->187
+TCTTGTGATGTGGTTAACCAAT
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc capu.fa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/capu.fa Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,98 @@
+>aldB -18->4
+auucgugauagcugucguaaag
+>ansB 103->125
+uuuuguuaccugccucuaacuu
+>araB1 109->131
+aagugugacgccgugcaaauaa
+>araB2 147->169 
+ugccgugauuauagacacuuuu
+>cdd 1 107->129
+auuugcgaugcgucgcgcauuu
+>cdd 2 57->79
+uaaugagauucagaucacauau
+>crp 1 115->137
+uaaugugacguccuuugcauac
+>crp 2
+gaaggcgaccugggucaugcug
+>cya 151->173 
+agguguuaaauugaucacguuu
+>cyuR 1 125->147
+cgaugcgaggcggaucgaaaaa
+>cyuR 2 106->128
+aaauucaauauucaucacacuu
+>dadAX 1 95->117
+agaugugagccagcucaccaua
+>dadAX 2 32->54
+agaugugauuagauuauuauuc
+>deoP2 1 75->97
+aauugugauguguaucgaagug
+>deoP2 2 128->150 
+uuauuugaaccagaucgcauua
+>fur 136->158
+aaauguaagcugugccacguuu
+>gal 56->78
+aagugugacauggaauaaauua
+>glpACB (glpUQ) 1 54->76  
+uuguuugauuucgcgcauauuc
+>glpACB (glpUQ) 2 94->116
+aaacgugauuucaugcgucauu
+>glpACB (glpUQ) 144->166 
+augugugcggcaauucacauuu
+>glpD (glpE) 95->117 
+uaauguuauacauaucacucua
+>glpFK 1 120->142
+uuuuaugacgaggcacacacau
+>glpFK 2 95->117
+aaguucgauauuucucguuuuu
+>guu (srlA) 72->94
+uuuugcgaucaaaauaacacuu
+>ilvB 87->109
+aaacgugaucaaccccucaauu
+>lac 1 (lacZ) 88->110
+uaaugugaguuagcucacucau
+>lac 2 (lacZ) 16->38 
+aauugugagcggauaacaauuu
+>malEpKp1 110->132
+uugugugaucucuguuacagaa
+>malEpKp2 139->161
+UAAuguggagaugcgcacaUAA
+>malEpKp3 173->195
+UUUugcaagcaacaucacgAAA
+>malEpKp4 205->227
+GACcucgguuuaguucacaGAA
+>malU 121->143
+aauugugacacagugcaaauuc
+>melR 52->74
+aaccgugcucccacucgcaguc
+>mul 302->324
+UCUUGUGAUUCAGAUCACAAAG
+>nag 156->178
+uuuugugaguuuugucaccaaa
+>nupG2 97->119
+aaauguuauccacaucacaauu
+>nupG1 47->69
+uuauuugccacagguaacaaaa
+>ompA 166->188
+augccugacggaguucacacuu
+>ompR 161->183
+uaacgugaucauaucaacagaa
+>pusH A 316->338
+Uuuuguggccugcuucaaacuu
+>pusH B 188->210
+uuuuaugauuugguucaauucu
+>rhaS (rhaB) 161->183 
+aauugugaacaucaucacguuc
+>rou 1 (ppiA) 182->204 
+uuuugugaucuguuuaaauguu
+>rou 2 (ppiA) 129->151
+agaggugauuuugaucacggaa
+>udcA 60->82
+auuugugaguggucgcacauau
+>unaL 73->95
+gauugugauucgauucacauuu
+>usx 2 146->168
+guguguaaacgugaacgcaauc
+>usx 1 107->129
+aacugugaaacgaaacauauuu
+>uxuAB 165->187
+UCUUGUGAUGUGGUUAACCAAU
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc codonlogo
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/codonlogo Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+
+
+
+
+# -------------------------------- WebLogo --------------------------------
+
+#  Copyright (c) 2003-2004 The Regents of the University of California.
+#  Copyright (c) 2005 Gavin E. Crooks
+#  Copyright (c) 2006, The Regents of the University of California, through 
+#  Lawrence Berkeley National Laboratory (subject to receipt of any required
+#  approvals from the U.S. Dept. of Energy).  All rights reserved.
+
+#  This software is distributed under the new BSD Open Source License.
+#  <http://www.opensource.org/licenses/bsd-license.html>
+#
+#  Redistribution and use in source and binary forms, with or without 
+#  modification, are permitted provided that the following conditions are met: 
+#
+#  (1) Redistributions of source code must retain the above copyright notice, 
+#  this list of conditions and the following disclaimer. 
+#
+#  (2) Redistributions in binary form must reproduce the above copyright 
+#  notice, this list of conditions and the following disclaimer in the 
+#  documentation and or other materials provided with the distribution. 
+#
+#  (3) Neither the name of the University of California, Lawrence Berkeley 
+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors 
+#  may be used to endorse or promote products derived from this software 
+#  without specific prior written permission. 
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#  POSSIBILITY OF SUCH DAMAGE. 
+
+""" WebLogo is a tool for creating sequence logos from biological sequence
+alignments.  It can be run on the command line, as a standalone webserver, as a
+CGI webapp, or as a python library.
+
+For help on the command line interface run
+    ./codonlogo --help
+
+To build a simple logo run
+    ./codonlogo  < cap.fa > logo0.eps
+    
+To run as a standalone webserver at localhost:8080 
+    ./codonlogo --serve
+
+
+"""
+import weblogolib
+
+# Standard python voodoo for CLI
+if __name__ == "__main__":
+    ## Code Profiling. Uncomment these lines
+    #import hotshot, hotshot.stats
+    #prof = hotshot.Profile("stones.prof")
+    #prof.runcall(main)
+    #prof.close()
+    #stats = hotshot.stats.load("stones.prof")
+    #stats.strip_dirs()
+    #stats.sort_stats('cumulative', 'calls')
+    #stats.print_stats(40)
+    #sys.exit()
+
+    weblogolib.main()
+    
+
+
+
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/__init__.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,62 @@
+
+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
+#  Copyright (c) 2006, The Regents of the University of California, through 
+#  Lawrence Berkeley National Laboratory (subject to receipt of any required
+#  approvals from the U.S. Dept. of Energy).  All rights reserved.
+
+#  This software is distributed under the new BSD Open Source License.
+#  <http://www.opensource.org/licenses/bsd-license.html>
+#
+#  Redistribution and use in source and binary forms, with or without 
+#  modification, are permitted provided that the following conditions are met: 
+#
+#  (1) Redistributions of source code must retain the above copyright notice, 
+#  this list of conditions and the following disclaimer. 
+#
+#  (2) Redistributions in binary form must reproduce the above copyright 
+#  notice, this list of conditions and the following disclaimer in the 
+#  documentation and or other materials provided with the distribution. 
+#
+#  (3) Neither the name of the University of California, Lawrence Berkeley 
+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors 
+#  may be used to endorse or promote products derived from this software 
+#  without specific prior written permission. 
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#  POSSIBILITY OF SUCH DAMAGE. 
+
+
+""" A python toolkit for computational biology. 
+
+http://code.google.com/p/corebio/
+""" 
+
+__all__ = [ 'data',
+            "moremath",
+            "resource", 
+            "seq", 
+            "seq_io", 
+            'ssearch_io', 
+            "utils", 
+            'transform',
+            ]
+
+from _version import __version__
+from _version import description
+
+__doc__  = description +' : ' + __doc__
+
+
+
+
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/_future/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/_future/__init__.py Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,78 @@
+
+"""
+Private compatability module for running under python version 2.3.
+    
+Replacement for 
+  o  string.Template    -- introduced in python 2.4
+  o  subprocess         -- introduced in python 2.4
+  
+  o  resource_string    -- introduced in pkg_resource of setuptools
+  o  resource_stream
+  o  resource_filename
+
+from string import Template -> from corebio._future import Template
+
+"""
+
+
+try :
+    import pkg_resources
+except ImportError :
+    pkg_resources = None
+
+
+try :
+    from string import Template
+except ImportError :
+    from _string import Template
+
+
+
+
+def resource_string( modulename, resource, basefilename = None):
+    """Locate and return a resource as a string.
+    >>> f = resource_string( __name, 'somedatafile', __file__)
+    """
+    if pkg_resources : 
+        return pkg_resources.resource_string(modulename, resource)    
+    
+    f = resource_stream( modulename, resource, basefilename)
+    return f.read()
+    
+def resource_stream( modulename, resource, basefilename = None):
+    """Locate and return a resource as a stream.
+    >>> f = resource_stream( __name__, 'somedatafile', __file__)
+    """    
+    if pkg_resources :  
+        return pkg_resources.resource_stream(modulename, resource)    
+    
+    return open( resource_filename( modulename, resource, basefilename) )
+
+def resource_filename( modulename, resource, basefilename = None): 
+    """Locate and return a resource filename.
+    >>> f = resource_stream( __name__, 'somedatafile', __file__)
+
+    A resource is a data file stored with the python code in a package.
+    All three resource methods (resource_string,  resource_stream,
+    resource_filename) call the corresponding methods in the 'pkg_resources'
+    module, if installed. Otherwise, we resort to locating the resource
+    in the local filesystem. However, this does not work if the package
+    is located inside a zip file. 
+    """ 
+    if pkg_resources : 
+        return pkg_resources.resource_filename(modulename, resource)            
+    
+    if basefilename is None :
+        raise NotImplementedError(
+            "Require either basefilename or pkg_resources")
+    
+    import os
+    return os.path.join(os.path.dirname(basefilename), resource)
+
+
+
+
+
+
+
+
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/_future/_string.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/_future/_string.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,127 @@
+####################################################################
+import re as _re
+
+class _multimap:
+    """Helper class for combining multiple mappings.
+
+    Used by .{safe_,}substitute() to combine the mapping and keyword
+    arguments.
+    """
+    def __init__(self, primary, secondary):
+        self._primary = primary
+        self._secondary = secondary
+
+    def __getitem__(self, key):
+        try:
+            return self._primary[key]
+        except KeyError:
+            return self._secondary[key]
+
+
+class _TemplateMetaclass(type):
+    pattern = r"""
+    %(delim)s(?:
+      (?P<escaped>%(delim)s) |   # Escape sequence of two delimiters
+      (?P<named>%(id)s)      |   # delimiter and a Python identifier
+      {(?P<braced>%(id)s)}   |   # delimiter and a braced identifier
+      (?P<invalid>)              # Other ill-formed delimiter exprs
+    )
+    """
+
+    def __init__(cls, name, bases, dct):
+        super(_TemplateMetaclass, cls).__init__(name, bases, dct)
+        if 'pattern' in dct:
+            pattern = cls.pattern
+        else:
+            pattern = _TemplateMetaclass.pattern % {
+                'delim' : _re.escape(cls.delimiter),
+                'id'    : cls.idpattern,
+                }
+        cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
+
+
+class Template:
+    """A string class for supporting $-substitutions."""
+    __metaclass__ = _TemplateMetaclass
+
+    delimiter = '$'
+    idpattern = r'[_a-z][_a-z0-9]*'
+
+    def __init__(self, template):
+        self.template = template
+
+    # Search for $$, $identifier, ${identifier}, and any bare $'s
+
+    def _invalid(self, mo):
+        i = mo.start('invalid')
+        lines = self.template[:i].splitlines(True)
+        if not lines:
+            colno = 1
+            lineno = 1
+        else:
+            colno = i - len(''.join(lines[:-1]))
+            lineno = len(lines)
+        raise ValueError('Invalid placeholder in string: line %d, col %d' %
+                         (lineno, colno))
+
+    def substitute(self, *args, **kws):
+        if len(args) > 1:
+            raise TypeError('Too many positional arguments')
+        if not args:
+            mapping = kws
+        elif kws:
+            mapping = _multimap(kws, args[0])
+        else:
+            mapping = args[0]
+        # Helper function for .sub()
+        def convert(mo):
+            # Check the most common path first.
+            named = mo.group('named') or mo.group('braced')
+            if named is not None:
+                val = mapping[named]
+                # We use this idiom instead of str() because the latter will
+                # fail if val is a Unicode containing non-ASCII characters.
+                return '%s' % val
+            if mo.group('escaped') is not None:
+                return self.delimiter
+            if mo.group('invalid') is not None:
+                self._invalid(mo)
+            raise ValueError('Unrecognized named group in pattern',
+                             self.pattern)
+        return self.pattern.sub(convert, self.template)
+
+    def safe_substitute(self, *args, **kws):
+        if len(args) > 1:
+            raise TypeError('Too many positional arguments')
+        if not args:
+            mapping = kws
+        elif kws:
+            mapping = _multimap(kws, args[0])
+        else:
+            mapping = args[0]
+        # Helper function for .sub()
+        def convert(mo):
+            named = mo.group('named')
+            if named is not None:
+                try:
+                    # We use this idiom instead of str() because the latter
+                    # will fail if val is a Unicode containing non-ASCII
+                    return '%s' % mapping[named]
+                except KeyError:
+                    return self.delimiter + named
+            braced = mo.group('braced')
+            if braced is not None:
+                try:
+                    return '%s' % mapping[braced]
+                except KeyError:
+                    return self.delimiter + '{' + braced + '}'
+            if mo.group('escaped') is not None:
+                return self.delimiter
+            if mo.group('invalid') is not None:
+                return self.delimiter
+            raise ValueError('Unrecognized named group in pattern',
+                             self.pattern)
+        return self.pattern.sub(convert, self.template)
+
+
+
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/_future/subprocess.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/_future/subprocess.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,1165 @@\n+# subprocess - Subprocesses with accessible I/O streams\n+#\n+# For more information about this module, see PEP 324.\n+#\n+# Copyright (c) 2003-2004 by Peter Astrand <astrand@lysator.liu.se>\n+#\n+# By obtaining, using, and/or copying this software and/or its\n+# associated documentation, you agree that you have read, understood,\n+# and will comply with the following terms and conditions:\n+#\n+# Permission to use, copy, modify, and distribute this software and\n+# its associated documentation for any purpose and without fee is\n+# hereby granted, provided that the above copyright notice appears in\n+# all copies, and that both that copyright notice and this permission\n+# notice appear in supporting documentation, and that the name of the\n+# author not be used in advertising or publicity pertaining to\n+# distribution of the software without specific, written prior\n+# permission.\n+#\n+# THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\n+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION\n+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n+\n+r"""subprocess - Subprocesses with accessible I/O streams\n+\n+This module allows you to spawn processes, connect to their\n+input/output/error pipes, and obtain their return codes.  This module\n+intends to replace several other, older modules and functions, like:\n+\n+os.system\n+os.spawn*\n+os.popen*\n+popen2.*\n+commands.*\n+\n+Information about how the subprocess module can be used to replace these\n+modules and functions can be found below.\n+\n+\n+\n+Using the subprocess module\n+===========================\n+This module defines one class called Popen:\n+\n+class Popen(args, bufsize=0, executable=None,\n+            stdin=None, stdout=None, stderr=None,\n+            preexec_fn=None, close_fds=False, shell=False,\n+            cwd=None, env=None, universal_newlines=False,\n+            startupinfo=None, creationflags=0):\n+\n+\n+Arguments are:\n+\n+args should be a string, or a sequence of program arguments.  The\n+program to execute is normally the first item in the args sequence or\n+string, but can be explicitly set by using the executable argument.\n+\n+On UNIX, with shell=False (default): In this case, the Popen class\n+uses os.execvp() to execute the child program.  args should normally\n+be a sequence.  A string will be treated as a sequence with the string\n+as the only item (the program to execute).\n+\n+On UNIX, with shell=True: If args is a string, it specifies the\n+command string to execute through the shell.  If args is a sequence,\n+the first item specifies the command string, and any additional items\n+will be treated as additional shell arguments.\n+\n+On Windows: the Popen class uses CreateProcess() to execute the child\n+program, which operates on strings.  If args is a sequence, it will be\n+converted to a string using the list2cmdline method.  Please note that\n+not all MS Windows applications interpret the command line the same\n+way: The list2cmdline is designed for applications using the same\n+rules as the MS C runtime.\n+\n+bufsize, if given, has the same meaning as the corresponding argument\n+to the built-in open() function: 0 means unbuffered, 1 means line\n+buffered, any other positive value means use a buffer of\n+(approximately) that size.  A negative bufsize means to use the system\n+default, which usually means fully buffered.  The default value for\n+bufsize is 0 (unbuffered).\n+\n+stdin, stdout and stderr specify the executed programs\' standard\n+input, standard output and standard error file handles, respectively.\n+Valid values are PIPE, an existing file descriptor (a positive\n+integer), an existing file object, and None.  PIPE indicates that a\n+new pipe to the child should be created.  With None, n'..b'fashion.\n+                self.stdin.flush()\n+                if input:\n+                    write_set.append(self.stdin)\n+                else:\n+                    self.stdin.close()\n+            if self.stdout:\n+                read_set.append(self.stdout)\n+                stdout = []\n+            if self.stderr:\n+                read_set.append(self.stderr)\n+                stderr = []\n+\n+            while read_set or write_set:\n+                rlist, wlist, xlist = select.select(read_set, write_set, [])\n+\n+                if self.stdin in wlist:\n+                    # When select has indicated that the file is writable,\n+                    # we can write up to PIPE_BUF bytes without risk\n+                    # blocking.  POSIX defines PIPE_BUF >= 512\n+                    bytes_written = os.write(self.stdin.fileno(), input[:512])\n+                    input = input[bytes_written:]\n+                    if not input:\n+                        self.stdin.close()\n+                        write_set.remove(self.stdin)\n+\n+                if self.stdout in rlist:\n+                    data = os.read(self.stdout.fileno(), 1024)\n+                    if data == "":\n+                        self.stdout.close()\n+                        read_set.remove(self.stdout)\n+                    stdout.append(data)\n+\n+                if self.stderr in rlist:\n+                    data = os.read(self.stderr.fileno(), 1024)\n+                    if data == "":\n+                        self.stderr.close()\n+                        read_set.remove(self.stderr)\n+                    stderr.append(data)\n+\n+            # All data exchanged.  Translate lists into strings.\n+            if stdout != None:\n+                stdout = \'\'.join(stdout)\n+            if stderr != None:\n+                stderr = \'\'.join(stderr)\n+\n+            # Translate newlines, if requested.  We cannot let the file\n+            # object do the translation: It is based on stdio, which is\n+            # impossible to combine with select (unless forcing no\n+            # buffering).\n+            if self.universal_newlines and hasattr(open, \'newlines\'):\n+                if stdout:\n+                    stdout = self._translate_newlines(stdout)\n+                if stderr:\n+                    stderr = self._translate_newlines(stderr)\n+\n+            self.wait()\n+            return (stdout, stderr)\n+\n+\n+def _demo_posix():\n+    #\n+    # Example 1: Simple redirection: Get process list\n+    #\n+    plist = Popen(["ps"], stdout=PIPE).communicate()[0]\n+    print "Process list:"\n+    print plist\n+\n+    #\n+    # Example 2: Change uid before executing child\n+    #\n+    if os.getuid() == 0:\n+        p = Popen(["id"], preexec_fn=lambda: os.setuid(100))\n+        p.wait()\n+\n+    #\n+    # Example 3: Connecting several subprocesses\n+    #\n+    print "Looking for \'hda\'..."\n+    p1 = Popen(["dmesg"], stdout=PIPE)\n+    p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)\n+    print repr(p2.communicate()[0])\n+\n+    #\n+    # Example 4: Catch execution error\n+    #\n+    print\n+    print "Trying a weird file..."\n+    try:\n+        print Popen(["/this/path/does/not/exist"]).communicate()\n+    except OSError, e:\n+        if e.errno == errno.ENOENT:\n+            print "The file didn\'t exist.  I thought so..."\n+            print "Child traceback:"\n+            print e.child_traceback\n+        else:\n+            print "Error", e.errno\n+    else:\n+        print >>sys.stderr, "Gosh.  No error."\n+\n+\n+def _demo_windows():\n+    #\n+    # Example 1: Connecting several subprocesses\n+    #\n+    print "Looking for \'PROMPT\' in set output..."\n+    p1 = Popen("set", stdout=PIPE, shell=True)\n+    p2 = Popen(\'find "PROMPT"\', stdin=p1.stdout, stdout=PIPE)\n+    print repr(p2.communicate()[0])\n+\n+    #\n+    # Example 2: Simple execution of program\n+    #\n+    print "Executing calc..."\n+    p = Popen("calc")\n+    p.wait()\n+\n+\n+if __name__ == "__main__":\n+    if mswindows:\n+        _demo_windows()\n+    else:\n+        _demo_posix()\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/_version.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/_version.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,18 @@
+
+
+# Keywords between dollar signs are subsituted by subversion.
+# The date and build will only tell the truth after a branch or tag,
+# since different files in trunk will have been changed at different times
+date ="$Date: 2006-11-27 12:10:21 -0800 (Mon, 27 Nov 2006) $".split()[1]
+revision = "$Revision: 167 $".split()[1]
+
+# major.minor.patch 
+# The patch level should be zero in trunk, a positive number in a release 
+# branch. During a release, increment the minor number in trunk and set the
+# patch level to 1 in the branch. Increment patch number for bug fix releases.
+__version__ = '0.5.0' #b' + revision 
+
+
+description = "CoreBio %s (%s)" % (__version__,  date)
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,385 @@\n+#  Copyright (c) 2006, The Regents of the University of California, through \n+#  Lawrence Berkeley National Laboratory (subject to receipt of any required\n+#  approvals from the U.S. Dept. of Energy).  All rights reserved.\n+\n+#  This software is distributed under the new BSD Open Source License.\n+#  <http://www.opensource.org/licenses/bsd-license.html>\n+#\n+#  Redistribution and use in source and binary forms, with or without \n+#  modification, are permitted provided that the following conditions are met: \n+#\n+#  (1) Redistributions of source code must retain the above copyright notice, \n+#  this list of conditions and the following disclaimer. \n+#\n+#  (2) Redistributions in binary form must reproduce the above copyright \n+#  notice, this list of conditions and the following disclaimer in the \n+#  documentation and or other materials provided with the distribution. \n+#\n+#  (3) Neither the name of the University of California, Lawrence Berkeley \n+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors \n+#  may be used to endorse or promote products derived from this software \n+#  without specific prior written permission. \n+#\n+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" \n+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE \n+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \n+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN \n+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \n+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \n+#  POSSIBILITY OF SUCH DAMAGE. \n+\n+"""\n+Standard information used in computational biology.\n+\n+\n+To convert a property dictionary to a list :\n+>>> comp = [ amino_acid_composition[k] for k in amino_acid_letters]\n+\n+\n+Resources: (Various standard data files.)\n+ \n+\n+BLOSUM Scoring Matrices\n+    Source: ftp://ftp.ncbi.nih.gov/repository/blocks/unix/blosum\n+    These are all new blast style with 1/3 bit scaling\n+    - blosum35\n+    - blosum45    \n+    - blosum62    \n+    - blosum40    \n+    - blosum50    \n+    - blosum80    \n+    - blosum100   \n+\n+Other subsitution scoring matrices:\n+    - dist20_comp \n+    - pam250\n+    - pam120\n+    \n+    \n+Status: Beta (Data needs to be proof checked.)    \n+"""\n+# TODO: add this datafile?\n+# Description of database cross references :\n+#    - dbxref.txt (http://www.expasy.org/cgi-bin/lists?dbxref.txt)\n+    \n+\n+# FIXME: Move documentation of data to docstring above. docstrings\n+# after variables don\'t work.\n+\n+\n+# The ExPasy ProtScale tool is a great source of amino acid properties.\n+# http://au.expasy.org/cgi-bin/protscale.pl       \n+\n+from StringIO import StringIO\n+from corebio._future import resource_string, resource_stream,resource_filename\n+from corebio import utils\n+\n+# Explictly list set of available data resources. We want to be able to access\n+# these resources in, for example, a webapp, without inadvertently allowing\n+# unrestricted read access to the local file system.\n+\n+resource_names = [\n+    \'blosum35\',\n+    \'blosum45\',    \n+    \'blosum62\',    \n+    \'blosum40\',    \n+    \'blosum50\',    \n+    \'blosum80\',    \n+    \'blosum100\',   \n+    \'dist20_comp\', \n+    \'pam250\',\n+    \'pam120\', \n+    ]\n+\n+_resource_filenames = {\n+    \'blosum35\':    \'data/blosum35.mat\',\n+    \'blosum45\':    \'data/blosum45.mat\',    \n+    \'blosum62\':    \'data/blosum62.mat\',    \n+    \'blosum40\':    \'data/blosum40.mat\',    \n+    \'blosum50\':    \'data/blosum50.mat\',    \n+    \'blosum80\':    \'data/blosum80.mat\',    \n+    \'blosum100\':   \'data/blosum100.mat\',   \n+    \'dist20_comp\': \'data/dist20_comp.mat\''..b'\'Q\', \'Dha\':\'A\', \'Dhi\':\'H\', \'Dil\':\'I\', \'Div\':\'V\', \'Dle\':\'L\', \'Dly\':\'K\', \'Dnp\':\'A\', \'Dpn\':\'F\', \'Dpr\':\'P\', \'Dsn\':\'S\', \'Dsp\':\'D\', \'Dth\':\'T\', \'Dtr\':\'W\', \'Dty\':\'Y\', \'Dva\':\'V\', \'Efc\':\'C\', \'Fla\':\'A\', \'Fme\':\'M\', \'Ggl\':\'E\', \'Gl3\':\'G\', \'Gln\':\'Q\', \'Glu\':\'E\', \'Glx\':\'Z\', \'Gly\':\'G\', \'Glz\':\'G\', \'Gma\':\'E\', \'Gsc\':\'G\', \'Hac\':\'A\', \'Har\':\'R\', \'Hic\':\'H\', \'Hip\':\'H\', \'His\':\'H\', \'Hmr\':\'R\', \'Hpq\':\'F\', \'Htr\':\'W\', \'Hyp\':\'P\', \'Iil\':\'I\', \'Ile\':\'I\', \'Iyr\':\'Y\', \'Kcx\':\'K\', \'Leu\':\'L\', \'Llp\':\'K\', \'Lly\':\'K\', \'Ltr\':\'W\', \'Lym\':\'K\', \'Lys\':\'K\', \'Lyz\':\'K\', \'Maa\':\'A\', \'Men\':\'N\', \'Met\':\'M\', \'Mhs\':\'H\', \'Mis\':\'S\', \'Mle\':\'L\', \'Mpq\':\'G\', \'Msa\':\'G\', \'Mse\':\'M\', \'Mva\':\'V\', \'Nem\':\'H\', \'Nep\':\'H\', \'Nle\':\'L\', \'Nln\':\'L\', \'Nlp\':\'L\', \'Nmc\':\'G\', \'Oas\':\'S\', \'Ocs\':\'C\', \'Omt\':\'M\', \'Paq\':\'Y\', \'Pca\':\'E\', \'Pec\':\'C\', \'Phe\':\'F\', \'Phi\':\'F\', \'Phl\':\'F\', \'Pr3\':\'C\', \'Pro\':\'P\', \'Prr\':\'A\', \'Ptr\':\'Y\', \'Pyl\':\'O\', \'Sac\':\'S\', \'Sar\':\'G\', \'Sch\':\'C\', \'Scs\':\'C\', \'Scy\':\'C\', \'Sec\':\'U\', \'Sel\':\'U\', \'Sep\':\'S\', \'Ser\':\'S\', \'Set\':\'S\', \'Shc\':\'C\', \'Shr\':\'K\', \'Smc\':\'C\', \'Soc\':\'C\', \'Sty\':\'Y\', \'Sva\':\'S\', \'Ter\':\'*\', \'Thr\':\'T\', \'Tih\':\'A\', \'Tpl\':\'W\', \'Tpo\':\'T\', \'Tpq\':\'A\', \'Trg\':\'K\', \'Tro\':\'W\', \'Trp\':\'W\', \'Tyb\':\'Y\', \'Tyq\':\'Y\', \'Tyr\':\'Y\', \'Tys\':\'Y\', \'Tyy\':\'Y\', \'Unk\':\'X\', \'Val\':\'V\', \'Xaa\':\'X\', \'Xer\':\'X\', \'Xle\':\'J\'}\n+\n+""" Map between three letter amino acid codes and standard one letter codes. \n+This map contains many nonstandard three letter codes, used, for example, to specify chemically modified amino acids in PDB files.\n+\n+Ref: http://astral.berkeley.edu/ \n+Ref: http://www.ebi.ac.uk/RESID/faq.html\n+"""\n+# Initial table is from the ASTRAL RAF release notes.\n+# added UNK\n+# Extra IUPAC: Xle, Xaa, Sec, Pyl\n+# The following have been seen in biopython code.\n+# Ter : \'*\'     Termination\n+# Sel : \'U\'     A typo for Sec, selenocysteine? \n+# Xer : \'X\'     Another alternative for unknown?\n+\n+\n+amino_acid_names = {\n+    \'A\'\t: \'alanine\',\t\n+    \'M\'\t: \'methionine\',  \n+    \'C\'\t: \'cysteine\',\n+    \'N\'\t: \'asparagine\',\n+    \'D\'\t: \'aspartic acid\',\n+    \'P\'\t: \'proline\',\n+    \'E\'\t: \'glutamic acid\',\n+    \'Q\'\t: \'glutamine\',\n+    \'F\'\t: \'phenylalanine\',\n+    \'R\'\t: \'arginine\',\n+    \'G\'\t: \'glycine\',\t\n+    \'S\'\t: \'serine\',\n+    \'H\'\t: \'histidine\',\t\n+    \'T\' : \'threonine\',\n+    \'I\'\t: \'isoleucine\',\t\n+    \'V\'\t: \'valine\',\n+    \'K\'\t: \'lysine\',\n+    \'W\'\t: \'tryptophan\', \n+    \'L\'\t: \'leucine\',\t\n+    \'Y\'\t: \'tyrosine\', \n+    \'B\' : \'aspartic acid or asparagine\',\n+    \'J\' : \'leucine or isoleucine\',\n+    \'X\' : \'unknown\',\n+    \'Z\' : \'glutamic acid or glutamine\',\n+    \'U\' : \'selenocysteine\',\n+    \'O\' : \'pyrrolysine\',\n+    \'*\' : \'translation stop\',\n+    \'-\' : \'gap\'\n+    }\n+\n+amino_acid_composition = dict(\n+    A = .082, R = .057, N = .044, D = .053, C = .017, \n+    Q = .040, E = .062, G = .072, H = .022, I = .052,  \n+    L = .090, K = .057, M = .024, F =.039, P = .051, \n+    S = .069, T = .058, W = .013, Y= .032, V =.066 )\n+      \n+"""\n+Overall amino acid composition of proteins.\n+Ref: McCaldon P., Argos P. Proteins 4:99-122 (1988).\n+"""\n+# FIXME : Proof these values\n+\n+kyte_doolittle_hydrophobicity = dict(\n+    A=1.8, R=-4.5, N=-3.5, D=-3.5,  C=2.5, \n+    Q=-3.5, E=-3.5, G=-0.4, H=-3.2, I=4.5,\n+    L=3.8, K=-3.9,  M=1.9,  F=2.8, P=-1.6,\n+    S=-0.8, T=-0.7, W=-0.9, Y=-1.3, V=4.2 )\n+"""\n+Kyte-Doolittle hydrophobicity scale.\n+Ref: Kyte J., Doolittle R.F. J. Mol. Biol. 157:105-132 (1982)\n+"""\n+# FIXME : Proof these values\n+\n+\n+nucleotide_names = { \n+    \'A\' : \'Adenosine\',\n+    \'C\'\t: \'Cytidine\',\n+    \'G\'\t: \'Guanine\',\n+    \'T\'\t: \'Thymidine\',\n+    \'U\'\t: \'Uracil\',\n+    \'R\'\t: \'G A (puRine)\',\n+    \'Y\'\t: \'T C (pYrimidine)\',\n+    \'K\'\t: \'G T (Ketone)\',\n+    \'M\'\t: \'A C (aMino group)\',\n+    \'S\'\t: \'G C (Strong interaction)\',\n+    \'W\'\t: \'A T (Weak interaction)\',\n+    \'B\'\t: \'G T C (not A) (B comes after A)\',\n+    \'D\'\t: \'G A T (not C) (D comes after C)\',\n+    \'H\'\t: \'A C T (not G) (H comes after G)\',\n+    \'V\'\t: \'G C A (not T, not U) (V comes after U)\',\n+    \'N\' : \'A G C T (aNy)\',\n+    \'-\' : \'gap\', \n+    }\n+    \n+    \n+\n+    \n+    \n+    \n+    \n+    \n+    \n\\ No newline at end of file\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/blosum100.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/blosum100.mat Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,31 @@
+#  Matrix made by matblas from blosum100_3.iij
+#  * column uses minimum score
+#  BLOSUM Clustered Scoring Matrix in 1/3 Bit Units
+#  Blocks Database = /data/blocks_5.0/blocks.dat
+#  Cluster Percentage: >= 100
+#  Entropy =   1.4516, Expected =  -1.0948
+   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *  
+A  8 -3 -4 -5 -2 -2 -3 -1 -4 -4 -4 -2 -3 -5 -2  1 -1 -6 -5 -2 -4 -2 -2 -10 
+R -3 10 -2 -5 -8  0 -2 -6 -1 -7 -6  3 -4 -6 -5 -3 -3 -7 -5 -6 -4 -1 -3 -10 
+N -4 -2 11  1 -5 -1 -2 -2  0 -7 -7 -1 -5 -7 -5  0 -1 -8 -5 -7  5 -2 -3 -10 
+D -5 -5  1 10 -8 -2  2 -4 -3 -8 -8 -3 -8 -8 -5 -2 -4 -10 -7 -8  6  0 -4 -10 
+C -2 -8 -5 -8 14 -7 -9 -7 -8 -3 -5 -8 -4 -4 -8 -3 -3 -7 -6 -3 -7 -8 -5 -10 
+Q -2  0 -1 -2 -7 11  2 -5  1 -6 -5  2 -2 -6 -4 -2 -3 -5 -4 -5 -2  5 -2 -10 
+E -3 -2 -2  2 -9  2 10 -6 -2 -7 -7  0 -5 -8 -4 -2 -3 -8 -7 -5  0  7 -3 -10 
+G -1 -6 -2 -4 -7 -5 -6  9 -6 -9 -8 -5 -7 -8 -6 -2 -5 -7 -8 -8 -3 -5 -4 -10 
+H -4 -1  0 -3 -8  1 -2 -6 13 -7 -6 -3 -5 -4 -5 -3 -4 -5  1 -7 -2 -1 -4 -10 
+I -4 -7 -7 -8 -3 -6 -7 -9 -7  8  2 -6  1 -2 -7 -5 -3 -6 -4  4 -8 -7 -3 -10 
+L -4 -6 -7 -8 -5 -5 -7 -8 -6  2  8 -6  3  0 -7 -6 -4 -5 -4  0 -8 -6 -3 -10 
+K -2  3 -1 -3 -8  2  0 -5 -3 -6 -6 10 -4 -6 -3 -2 -3 -8 -5 -5 -2  0 -3 -10 
+M -3 -4 -5 -8 -4 -2 -5 -7 -5  1  3 -4 12 -1 -5 -4 -2 -4 -5  0 -7 -4 -3 -10 
+F -5 -6 -7 -8 -4 -6 -8 -8 -4 -2  0 -6 -1 11 -7 -5 -5  0  4 -3 -7 -7 -4 -10 
+P -2 -5 -5 -5 -8 -4 -4 -6 -5 -7 -7 -3 -5 -7 12 -3 -4 -8 -7 -6 -5 -4 -4 -10 
+S  1 -3  0 -2 -3 -2 -2 -2 -3 -5 -6 -2 -4 -5 -3  9  2 -7 -5 -4 -1 -2 -2 -10 
+T -1 -3 -1 -4 -3 -3 -3 -5 -4 -3 -4 -3 -2 -5 -4  2  9 -7 -5 -1 -2 -3 -2 -10 
+W -6 -7 -8 -10 -7 -5 -8 -7 -5 -6 -5 -8 -4  0 -8 -7 -7 17  2 -5 -9 -7 -6 -10 
+Y -5 -5 -5 -7 -6 -4 -7 -8  1 -4 -4 -5 -5  4 -7 -5 -5  2 12 -5 -6 -6 -4 -10 
+V -2 -6 -7 -8 -3 -5 -5 -8 -7  4  0 -5  0 -3 -6 -4 -1 -5 -5  8 -7 -5 -3 -10 
+B -4 -4  5  6 -7 -2  0 -3 -2 -8 -8 -2 -7 -7 -5 -1 -2 -9 -6 -7  6  0 -4 -10 
+Z -2 -1 -2  0 -8  5  7 -5 -1 -7 -6  0 -4 -7 -4 -2 -3 -7 -6 -5  0  6 -2 -10 
+X -2 -3 -3 -4 -5 -2 -3 -4 -4 -3 -3 -3 -3 -4 -4 -2 -2 -6 -4 -3 -4 -2 -3 -10 
+* -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10  1 
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/blosum35.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/blosum35.mat Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,31 @@
+#  Matrix made by matblas from blosum35.iij
+#  * column uses minimum score
+#  BLOSUM Clustered Scoring Matrix in 1/4 Bit Units
+#  Blocks Database = /data/blocks_5.0/blocks.dat
+#  Cluster Percentage: >= 35
+#  Entropy =   0.2111, Expected =  -0.1550
+   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *  
+A  5 -1 -1 -1 -2  0 -1  0 -2 -1 -2  0  0 -2 -2  1  0 -2 -1  0 -1 -1  0 -5 
+R -1  8 -1 -1 -3  2 -1 -2 -1 -3 -2  2  0 -1 -2 -1 -2  0  0 -1 -1  0 -1 -5 
+N -1 -1  7  1 -1  1 -1  1  1 -1 -2  0 -1 -1 -2  0  0 -2 -2 -2  4  0  0 -5 
+D -1 -1  1  8 -3 -1  2 -2  0 -3 -2 -1 -3 -3 -1 -1 -1 -3 -2 -2  5  1 -1 -5 
+C -2 -3 -1 -3 15 -3 -1 -3 -4 -4 -2 -2 -4 -4 -4 -3 -1 -5 -5 -2 -2 -2 -2 -5 
+Q  0  2  1 -1 -3  7  2 -2 -1 -2 -2  0 -1 -4  0  0  0 -1  0 -3  0  4 -1 -5 
+E -1 -1 -1  2 -1  2  6 -2 -1 -3 -1  1 -2 -3  0  0 -1 -1 -1 -2  0  5 -1 -5 
+G  0 -2  1 -2 -3 -2 -2  7 -2 -3 -3 -1 -1 -3 -2  1 -2 -1 -2 -3  0 -2 -1 -5 
+H -2 -1  1  0 -4 -1 -1 -2 12 -3 -2 -2  1 -3 -1 -1 -2 -4  0 -4  0 -1 -1 -5 
+I -1 -3 -1 -3 -4 -2 -3 -3 -3  5  2 -2  1  1 -1 -2 -1 -1  0  4 -2 -3  0 -5 
+L -2 -2 -2 -2 -2 -2 -1 -3 -2  2  5 -2  3  2 -3 -2  0  0  0  2 -2 -2  0 -5 
+K  0  2  0 -1 -2  0  1 -1 -2 -2 -2  5  0 -1  0  0  0  0 -1 -2  0  1  0 -5 
+M  0  0 -1 -3 -4 -1 -2 -1  1  1  3  0  6  0 -3 -1  0  1  0  1 -2 -2  0 -5 
+F -2 -1 -1 -3 -4 -4 -3 -3 -3  1  2 -1  0  8 -4 -1 -1  1  3  1 -2 -3 -1 -5 
+P -2 -2 -2 -1 -4  0  0 -2 -1 -1 -3  0 -3 -4 10 -2  0 -4 -3 -3 -1  0 -1 -5 
+S  1 -1  0 -1 -3  0  0  1 -1 -2 -2  0 -1 -1 -2  4  2 -2 -1 -1  0  0  0 -5 
+T  0 -2  0 -1 -1  0 -1 -2 -2 -1  0  0  0 -1  0  2  5 -2 -2  1 -1 -1  0 -5 
+W -2  0 -2 -3 -5 -1 -1 -1 -4 -1  0  0  1  1 -4 -2 -2 16  3 -2 -3 -1 -1 -5 
+Y -1  0 -2 -2 -5  0 -1 -2  0  0  0 -1  0  3 -3 -1 -2  3  8  0 -2 -1 -1 -5 
+V  0 -1 -2 -2 -2 -3 -2 -3 -4  4  2 -2  1  1 -3 -1  1 -2  0  5 -2 -2  0 -5 
+B -1 -1  4  5 -2  0  0  0  0 -2 -2  0 -2 -2 -1  0 -1 -3 -2 -2  5  0 -1 -5 
+Z -1  0  0  1 -2  4  5 -2 -1 -3 -2  1 -2 -3  0  0 -1 -1 -1 -2  0  4  0 -5 
+X  0 -1  0 -1 -2 -1 -1 -1 -1  0  0  0  0 -1 -1  0  0 -1 -1  0 -1  0 -1 -5 
+* -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5  1 
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/blosum40.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/blosum40.mat Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,31 @@
+#  Matrix made by matblas from blosum40.iij
+#  * column uses minimum score
+#  BLOSUM Clustered Scoring Matrix in 1/4 Bit Units
+#  Blocks Database = /data/blocks_5.0/blocks.dat
+#  Cluster Percentage: >= 40
+#  Entropy =   0.2851, Expected =  -0.2090
+   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *  
+A  5 -2 -1 -1 -2  0 -1  1 -2 -1 -2 -1 -1 -3 -2  1  0 -3 -2  0 -1 -1  0 -6 
+R -2  9  0 -1 -3  2 -1 -3  0 -3 -2  3 -1 -2 -3 -1 -2 -2 -1 -2 -1  0 -1 -6 
+N -1  0  8  2 -2  1 -1  0  1 -2 -3  0 -2 -3 -2  1  0 -4 -2 -3  4  0 -1 -6 
+D -1 -1  2  9 -2 -1  2 -2  0 -4 -3  0 -3 -4 -2  0 -1 -5 -3 -3  6  1 -1 -6 
+C -2 -3 -2 -2 16 -4 -2 -3 -4 -4 -2 -3 -3 -2 -5 -1 -1 -6 -4 -2 -2 -3 -2 -6 
+Q  0  2  1 -1 -4  8  2 -2  0 -3 -2  1 -1 -4 -2  1 -1 -1 -1 -3  0  4 -1 -6 
+E -1 -1 -1  2 -2  2  7 -3  0 -4 -2  1 -2 -3  0  0 -1 -2 -2 -3  1  5 -1 -6 
+G  1 -3  0 -2 -3 -2 -3  8 -2 -4 -4 -2 -2 -3 -1  0 -2 -2 -3 -4 -1 -2 -1 -6 
+H -2  0  1  0 -4  0  0 -2 13 -3 -2 -1  1 -2 -2 -1 -2 -5  2 -4  0  0 -1 -6 
+I -1 -3 -2 -4 -4 -3 -4 -4 -3  6  2 -3  1  1 -2 -2 -1 -3  0  4 -3 -4 -1 -6 
+L -2 -2 -3 -3 -2 -2 -2 -4 -2  2  6 -2  3  2 -4 -3 -1 -1  0  2 -3 -2 -1 -6 
+K -1  3  0  0 -3  1  1 -2 -1 -3 -2  6 -1 -3 -1  0  0 -2 -1 -2  0  1 -1 -6 
+M -1 -1 -2 -3 -3 -1 -2 -2  1  1  3 -1  7  0 -2 -2 -1 -2  1  1 -3 -2  0 -6 
+F -3 -2 -3 -4 -2 -4 -3 -3 -2  1  2 -3  0  9 -4 -2 -1  1  4  0 -3 -4 -1 -6 
+P -2 -3 -2 -2 -5 -2  0 -1 -2 -2 -4 -1 -2 -4 11 -1  0 -4 -3 -3 -2 -1 -2 -6 
+S  1 -1  1  0 -1  1  0  0 -1 -2 -3  0 -2 -2 -1  5  2 -5 -2 -1  0  0  0 -6 
+T  0 -2  0 -1 -1 -1 -1 -2 -2 -1 -1  0 -1 -1  0  2  6 -4 -1  1  0 -1  0 -6 
+W -3 -2 -4 -5 -6 -1 -2 -2 -5 -3 -1 -2 -2  1 -4 -5 -4 19  3 -3 -4 -2 -2 -6 
+Y -2 -1 -2 -3 -4 -1 -2 -3  2  0  0 -1  1  4 -3 -2 -1  3  9 -1 -3 -2 -1 -6 
+V  0 -2 -3 -3 -2 -3 -3 -4 -4  4  2 -2  1  0 -3 -1  1 -3 -1  5 -3 -3 -1 -6 
+B -1 -1  4  6 -2  0  1 -1  0 -3 -3  0 -3 -3 -2  0  0 -4 -3 -3  5  0 -1 -6 
+Z -1  0  0  1 -3  4  5 -2  0 -4 -2  1 -2 -4 -1  0 -1 -2 -2 -3  0  5 -1 -6 
+X  0 -1 -1 -1 -2 -1 -1 -1 -1 -1 -1 -1  0 -1 -2  0  0 -2 -1 -1 -1 -1 -1 -6 
+* -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6  1 
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/blosum45.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/blosum45.mat Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,31 @@
+#  Matrix made by matblas from blosum45.iij
+#  * column uses minimum score
+#  BLOSUM Clustered Scoring Matrix in 1/3 Bit Units
+#  Blocks Database = /data/blocks_5.0/blocks.dat
+#  Cluster Percentage: >= 45
+#  Entropy =   0.3795, Expected =  -0.2789
+   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *  
+A  5 -2 -1 -2 -1 -1 -1  0 -2 -1 -1 -1 -1 -2 -1  1  0 -2 -2  0 -1 -1  0 -5 
+R -2  7  0 -1 -3  1  0 -2  0 -3 -2  3 -1 -2 -2 -1 -1 -2 -1 -2 -1  0 -1 -5 
+N -1  0  6  2 -2  0  0  0  1 -2 -3  0 -2 -2 -2  1  0 -4 -2 -3  4  0 -1 -5 
+D -2 -1  2  7 -3  0  2 -1  0 -4 -3  0 -3 -4 -1  0 -1 -4 -2 -3  5  1 -1 -5 
+C -1 -3 -2 -3 12 -3 -3 -3 -3 -3 -2 -3 -2 -2 -4 -1 -1 -5 -3 -1 -2 -3 -2 -5 
+Q -1  1  0  0 -3  6  2 -2  1 -2 -2  1  0 -4 -1  0 -1 -2 -1 -3  0  4 -1 -5 
+E -1  0  0  2 -3  2  6 -2  0 -3 -2  1 -2 -3  0  0 -1 -3 -2 -3  1  4 -1 -5 
+G  0 -2  0 -1 -3 -2 -2  7 -2 -4 -3 -2 -2 -3 -2  0 -2 -2 -3 -3 -1 -2 -1 -5 
+H -2  0  1  0 -3  1  0 -2 10 -3 -2 -1  0 -2 -2 -1 -2 -3  2 -3  0  0 -1 -5 
+I -1 -3 -2 -4 -3 -2 -3 -4 -3  5  2 -3  2  0 -2 -2 -1 -2  0  3 -3 -3 -1 -5 
+L -1 -2 -3 -3 -2 -2 -2 -3 -2  2  5 -3  2  1 -3 -3 -1 -2  0  1 -3 -2 -1 -5 
+K -1  3  0  0 -3  1  1 -2 -1 -3 -3  5 -1 -3 -1 -1 -1 -2 -1 -2  0  1 -1 -5 
+M -1 -1 -2 -3 -2  0 -2 -2  0  2  2 -1  6  0 -2 -2 -1 -2  0  1 -2 -1 -1 -5 
+F -2 -2 -2 -4 -2 -4 -3 -3 -2  0  1 -3  0  8 -3 -2 -1  1  3  0 -3 -3 -1 -5 
+P -1 -2 -2 -1 -4 -1  0 -2 -2 -2 -3 -1 -2 -3  9 -1 -1 -3 -3 -3 -2 -1 -1 -5 
+S  1 -1  1  0 -1  0  0  0 -1 -2 -3 -1 -2 -2 -1  4  2 -4 -2 -1  0  0  0 -5 
+T  0 -1  0 -1 -1 -1 -1 -2 -2 -1 -1 -1 -1 -1 -1  2  5 -3 -1  0  0 -1  0 -5 
+W -2 -2 -4 -4 -5 -2 -3 -2 -3 -2 -2 -2 -2  1 -3 -4 -3 15  3 -3 -4 -2 -2 -5 
+Y -2 -1 -2 -2 -3 -1 -2 -3  2  0  0 -1  0  3 -3 -2 -1  3  8 -1 -2 -2 -1 -5 
+V  0 -2 -3 -3 -1 -3 -3 -3 -3  3  1 -2  1  0 -3 -1  0 -3 -1  5 -3 -3 -1 -5 
+B -1 -1  4  5 -2  0  1 -1  0 -3 -3  0 -2 -3 -2  0  0 -4 -2 -3  4  0 -1 -5 
+Z -1  0  0  1 -3  4  4 -2  0 -3 -2  1 -1 -3 -1  0 -1 -2 -2 -3  0  4 -1 -5 
+X  0 -1 -1 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  0  0 -2 -1 -1 -1 -1 -1 -5 
+* -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5  1 
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/blosum50.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/blosum50.mat Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,31 @@
+#  Matrix made by matblas from blosum50.iij
+#  * column uses minimum score
+#  BLOSUM Clustered Scoring Matrix in 1/3 Bit Units
+#  Blocks Database = /data/blocks_5.0/blocks.dat
+#  Cluster Percentage: >= 50
+#  Entropy =   0.4808, Expected =  -0.3573
+ A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *
+ 5 -2 -1 -2 -1 -1 -1  0 -2 -1 -2 -1 -1 -3 -1  1  0 -3 -2  0 -2 -1 -1 -5 
+-2  7 -1 -2 -4  1  0 -3  0 -4 -3  3 -2 -3 -3 -1 -1 -3 -1 -3 -1  0 -1 -5 
+-1 -1  7  2 -2  0  0  0  1 -3 -4  0 -2 -4 -2  1  0 -4 -2 -3  4  0 -1 -5 
+-2 -2  2  8 -4  0  2 -1 -1 -4 -4 -1 -4 -5 -1  0 -1 -5 -3 -4  5  1 -1 -5 
+-1 -4 -2 -4 13 -3 -3 -3 -3 -2 -2 -3 -2 -2 -4 -1 -1 -5 -3 -1 -3 -3 -2 -5 
+-1  1  0  0 -3  7  2 -2  1 -3 -2  2  0 -4 -1  0 -1 -1 -1 -3  0  4 -1 -5 
+-1  0  0  2 -3  2  6 -3  0 -4 -3  1 -2 -3 -1 -1 -1 -3 -2 -3  1  5 -1 -5 
+ 0 -3  0 -1 -3 -2 -3  8 -2 -4 -4 -2 -3 -4 -2  0 -2 -3 -3 -4 -1 -2 -2 -5 
+-2  0  1 -1 -3  1  0 -2 10 -4 -3  0 -1 -1 -2 -1 -2 -3  2 -4  0  0 -1 -5 
+-1 -4 -3 -4 -2 -3 -4 -4 -4  5  2 -3  2  0 -3 -3 -1 -3 -1  4 -4 -3 -1 -5 
+-2 -3 -4 -4 -2 -2 -3 -4 -3  2  5 -3  3  1 -4 -3 -1 -2 -1  1 -4 -3 -1 -5 
+-1  3  0 -1 -3  2  1 -2  0 -3 -3  6 -2 -4 -1  0 -1 -3 -2 -3  0  1 -1 -5 
+-1 -2 -2 -4 -2  0 -2 -3 -1  2  3 -2  7  0 -3 -2 -1 -1  0  1 -3 -1 -1 -5 
+-3 -3 -4 -5 -2 -4 -3 -4 -1  0  1 -4  0  8 -4 -3 -2  1  4 -1 -4 -4 -2 -5 
+-1 -3 -2 -1 -4 -1 -1 -2 -2 -3 -4 -1 -3 -4 10 -1 -1 -4 -3 -3 -2 -1 -2 -5 
+ 1 -1  1  0 -1  0 -1  0 -1 -3 -3  0 -2 -3 -1  5  2 -4 -2 -2  0  0 -1 -5 
+ 0 -1  0 -1 -1 -1 -1 -2 -2 -1 -1 -1 -1 -2 -1  2  5 -3 -2  0  0 -1  0 -5 
+-3 -3 -4 -5 -5 -1 -3 -3 -3 -3 -2 -3 -1  1 -4 -4 -3 15  2 -3 -5 -2 -3 -5 
+-2 -1 -2 -3 -3 -1 -2 -3  2 -1 -1 -2  0  4 -3 -2 -2  2  8 -1 -3 -2 -1 -5 
+ 0 -3 -3 -4 -1 -3 -3 -4 -4  4  1 -3  1 -1 -3 -2  0 -3 -1  5 -4 -3 -1 -5 
+-2 -1  4  5 -3  0  1 -1  0 -4 -4  0 -3 -4 -2  0  0 -5 -3 -4  5  0 -1 -5 
+-1  0  0  1 -3  4  5 -2  0 -3 -3  1 -1 -4 -1  0 -1 -2 -2 -3  0  5 -1 -5 
+-1 -1 -1 -1 -2 -1 -1 -2 -1 -1 -1 -1 -1 -2 -2 -1  0 -3 -1 -1 -1 -1 -1 -5 
+-5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5 -5  1 
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/blosum62.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/blosum62.mat Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,31 @@
+#  Matrix made by matblas from blosum62_3.iij
+#  * column uses minimum score
+#  BLOSUM Clustered Scoring Matrix in 1/3 Bit Units
+#  Blocks Database = /data/blocks_5.0/blocks.dat
+#  Cluster Percentage: >= 62
+#  Entropy =   0.6979, Expected =  -0.5209
+   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *  
+A  6 -2 -2 -3 -1 -1 -1  0 -2 -2 -2 -1 -1 -3 -1  2  0 -4 -3  0 -2 -1 -1 -6 
+R -2  8 -1 -2 -5  1  0 -3  0 -4 -3  3 -2 -4 -3 -1 -2 -4 -3 -4 -2  0 -2 -6 
+N -2 -1  8  2 -4  0  0 -1  1 -5 -5  0 -3 -4 -3  1  0 -6 -3 -4  5  0 -2 -6 
+D -3 -2  2  9 -5  0  2 -2 -2 -5 -5 -1 -5 -5 -2  0 -2 -6 -5 -5  6  1 -2 -6 
+C -1 -5 -4 -5 13 -4 -5 -4 -4 -2 -2 -5 -2 -4 -4 -1 -1 -3 -4 -1 -5 -5 -3 -6 
+Q -1  1  0  0 -4  8  3 -3  1 -4 -3  2 -1 -5 -2  0 -1 -3 -2 -3  0  5 -1 -6 
+E -1  0  0  2 -5  3  7 -3  0 -5 -4  1 -3 -5 -2  0 -1 -4 -3 -4  1  6 -1 -6 
+G  0 -3 -1 -2 -4 -3 -3  8 -3 -6 -5 -2 -4 -5 -3  0 -2 -4 -5 -5 -1 -3 -2 -6 
+H -2  0  1 -2 -4  1  0 -3 11 -5 -4 -1 -2 -2 -3 -1 -3 -4  3 -5 -1  0 -2 -6 
+I -2 -4 -5 -5 -2 -4 -5 -6 -5  6  2 -4  2  0 -4 -4 -1 -4 -2  4 -5 -5 -2 -6 
+L -2 -3 -5 -5 -2 -3 -4 -5 -4  2  6 -4  3  1 -4 -4 -2 -2 -2  1 -5 -4 -2 -6 
+K -1  3  0 -1 -5  2  1 -2 -1 -4 -4  7 -2 -5 -2  0 -1 -4 -3 -3 -1  1 -1 -6 
+M -1 -2 -3 -5 -2 -1 -3 -4 -2  2  3 -2  8  0 -4 -2 -1 -2 -1  1 -4 -2 -1 -6 
+F -3 -4 -4 -5 -4 -5 -5 -5 -2  0  1 -5  0  9 -5 -4 -3  1  4 -1 -5 -5 -2 -6 
+P -1 -3 -3 -2 -4 -2 -2 -3 -3 -4 -4 -2 -4 -5 11 -1 -2 -5 -4 -4 -3 -2 -2 -6 
+S  2 -1  1  0 -1  0  0  0 -1 -4 -4  0 -2 -4 -1  6  2 -4 -3 -2  0  0 -1 -6 
+T  0 -2  0 -2 -1 -1 -1 -2 -3 -1 -2 -1 -1 -3 -2  2  7 -4 -2  0 -1 -1 -1 -6 
+W -4 -4 -6 -6 -3 -3 -4 -4 -4 -4 -2 -4 -2  1 -5 -4 -4 16  3 -4 -6 -4 -3 -6 
+Y -3 -3 -3 -5 -4 -2 -3 -5  3 -2 -2 -3 -1  4 -4 -3 -2  3 10 -2 -4 -3 -2 -6 
+V  0 -4 -4 -5 -1 -3 -4 -5 -5  4  1 -3  1 -1 -4 -2  0 -4 -2  6 -5 -4 -1 -6 
+B -2 -2  5  6 -5  0  1 -1 -1 -5 -5 -1 -4 -5 -3  0 -1 -6 -4 -5  5  0 -2 -6 
+Z -1  0  0  1 -5  5  6 -3  0 -5 -4  1 -2 -5 -2  0 -1 -4 -3 -4  0  5 -1 -6 
+X -1 -2 -2 -2 -3 -1 -1 -2 -2 -2 -2 -1 -1 -2 -2 -1 -1 -3 -2 -1 -2 -1 -2 -6 
+* -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6 -6  1 
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/blosum80.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/blosum80.mat Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,31 @@
+#  Matrix made by matblas from blosum80_3.iij
+#  * column uses minimum score
+#  BLOSUM Clustered Scoring Matrix in 1/3 Bit Units
+#  Blocks Database = /data/blocks_5.0/blocks.dat
+#  Cluster Percentage: >= 80
+#  Entropy =   0.9868, Expected =  -0.7442
+   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *  
+A  7 -3 -3 -3 -1 -2 -2  0 -3 -3 -3 -1 -2 -4 -1  2  0 -5 -4 -1 -3 -2 -1 -8 
+R -3  9 -1 -3 -6  1 -1 -4  0 -5 -4  3 -3 -5 -3 -2 -2 -5 -4 -4 -2  0 -2 -8 
+N -3 -1  9  2 -5  0 -1 -1  1 -6 -6  0 -4 -6 -4  1  0 -7 -4 -5  5 -1 -2 -8 
+D -3 -3  2 10 -7 -1  2 -3 -2 -7 -7 -2 -6 -6 -3 -1 -2 -8 -6 -6  6  1 -3 -8 
+C -1 -6 -5 -7 13 -5 -7 -6 -7 -2 -3 -6 -3 -4 -6 -2 -2 -5 -5 -2 -6 -7 -4 -8 
+Q -2  1  0 -1 -5  9  3 -4  1 -5 -4  2 -1 -5 -3 -1 -1 -4 -3 -4 -1  5 -2 -8 
+E -2 -1 -1  2 -7  3  8 -4  0 -6 -6  1 -4 -6 -2 -1 -2 -6 -5 -4  1  6 -2 -8 
+G  0 -4 -1 -3 -6 -4 -4  9 -4 -7 -7 -3 -5 -6 -5 -1 -3 -6 -6 -6 -2 -4 -3 -8 
+H -3  0  1 -2 -7  1  0 -4 12 -6 -5 -1 -4 -2 -4 -2 -3 -4  3 -5 -1  0 -2 -8 
+I -3 -5 -6 -7 -2 -5 -6 -7 -6  7  2 -5  2 -1 -5 -4 -2 -5 -3  4 -6 -6 -2 -8 
+L -3 -4 -6 -7 -3 -4 -6 -7 -5  2  6 -4  3  0 -5 -4 -3 -4 -2  1 -7 -5 -2 -8 
+K -1  3  0 -2 -6  2  1 -3 -1 -5 -4  8 -3 -5 -2 -1 -1 -6 -4 -4 -1  1 -2 -8 
+M -2 -3 -4 -6 -3 -1 -4 -5 -4  2  3 -3  9  0 -4 -3 -1 -3 -3  1 -5 -3 -2 -8 
+F -4 -5 -6 -6 -4 -5 -6 -6 -2 -1  0 -5  0 10 -6 -4 -4  0  4 -2 -6 -6 -3 -8 
+P -1 -3 -4 -3 -6 -3 -2 -5 -4 -5 -5 -2 -4 -6 12 -2 -3 -7 -6 -4 -4 -2 -3 -8 
+S  2 -2  1 -1 -2 -1 -1 -1 -2 -4 -4 -1 -3 -4 -2  7  2 -6 -3 -3  0 -1 -1 -8 
+T  0 -2  0 -2 -2 -1 -2 -3 -3 -2 -3 -1 -1 -4 -3  2  8 -5 -3  0 -1 -2 -1 -8 
+W -5 -5 -7 -8 -5 -4 -6 -6 -4 -5 -4 -6 -3  0 -7 -6 -5 16  3 -5 -8 -5 -5 -8 
+Y -4 -4 -4 -6 -5 -3 -5 -6  3 -3 -2 -4 -3  4 -6 -3 -3  3 11 -3 -5 -4 -3 -8 
+V -1 -4 -5 -6 -2 -4 -4 -6 -5  4  1 -4  1 -2 -4 -3  0 -5 -3  7 -6 -4 -2 -8 
+B -3 -2  5  6 -6 -1  1 -2 -1 -6 -7 -1 -5 -6 -4  0 -1 -8 -5 -6  6  0 -3 -8 
+Z -2  0 -1  1 -7  5  6 -4  0 -6 -5  1 -3 -6 -2 -1 -2 -5 -4 -4  0  6 -1 -8 
+X -1 -2 -2 -3 -4 -2 -2 -3 -2 -2 -2 -2 -2 -3 -3 -1 -1 -5 -3 -2 -3 -1 -2 -8 
+* -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8 -8  1 
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/dist20_comp.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/dist20_comp.mat Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,25 @@
+#TOTAL: 1.000000 
+# entropy = 0.404334
+A    4  -2  -2  -2   0  -1  -1  -1  -2  -2  -2  -2  -1  -2  -1   0  -1  -3  -2  -1  -2  -1  -1
+R   -2   6  -1  -1  -4   1   0  -3   0  -3  -3   2  -2  -3  -2  -1  -1  -2  -2  -3   3  -1  -1
+N   -2  -1   7   1  -3   0   0  -1   0  -5  -4   0  -3  -4  -2   0  -1  -3  -2  -4   3  -1  -1
+D   -2  -1   1   7  -4   0   1  -1  -1  -6  -5   0  -4  -5  -1   0  -1  -4  -3  -5   0  -2  -2
+C    0  -4  -3  -4  12  -3  -4  -3  -3  -1  -2  -4  -1  -2  -3  -2  -1  -2  -2   0  -3   5  -2
+Q   -1   1   0   0  -3   6   1  -2   0  -3  -3   1  -2  -3  -1   0  -1  -2  -2  -3   0   1  -1
+E   -1   0   0   1  -4   1   5  -2  -1  -4  -4   1  -3  -4  -1  -1  -1  -3  -3  -4   0  -1  -1
+G   -1  -3  -1  -1  -3  -2  -2   7  -2  -6  -5  -2  -4  -5  -2  -1  -2  -4  -4  -5  -2  -2  -2
+H   -2   0   0  -1  -3   0  -1  -2   9  -3  -3  -1  -2  -1  -2  -1  -1   0   0  -3   0  -1  -1
+I   -2  -3  -5  -6  -1  -3  -4  -6  -3   5   2  -4   1   0  -4  -4  -2  -1  -1   3  -4  -2  -2
+L   -2  -3  -4  -5  -2  -3  -4  -5  -3   2   5  -3   2   1  -3  -3  -2  -1  -1   1  -4  -2  -2
+K   -2   2   0   0  -4   1   1  -2  -1  -4  -3   5  -2  -4  -1  -1  -1  -3  -3  -3   1  -1  -1
+M   -1  -2  -3  -4  -1  -2  -3  -4  -2   1   2  -2   7   1  -3  -2  -1   0   0   1  -3  -2  -1
+F   -2  -3  -4  -5  -2  -3  -4  -5  -1   0   1  -4   1   7  -3  -3  -2   3   3   0  -3  -2  -1
+P   -1  -2  -2  -1  -3  -1  -1  -2  -2  -4  -3  -1  -3  -3   8  -1  -2  -3  -3  -3  -2  -2  -2
+S    0  -1   0   0  -2   0  -1  -1  -1  -4  -3  -1  -2  -3  -1   4   1  -3  -2  -3   0  -1  -1
+T   -1  -1  -1  -1  -1  -1  -1  -2  -1  -2  -2  -1  -1  -2  -2   1   5  -2  -2  -1  -1  -1  -1
+W   -3  -2  -3  -4  -2  -2  -3  -4   0  -1  -1  -3   0   3  -3  -3  -2  12   3  -2  -3  -2  -1
+Y   -2  -2  -2  -3  -2  -2  -3  -4   0  -1  -1  -3   0   3  -3  -2  -2   3   8  -2  -2  -2  -1
+V   -1  -3  -4  -5   0  -3  -4  -5  -3   3   1  -3   1   0  -3  -3  -1  -2  -2   5  -4  -2  -2
+B   -2   3   3   0  -3   0   0  -2   0  -4  -4   1  -3  -3  -2   0  -1  -3  -2  -4   3  -1  -1
+Z   -1  -1  -1  -2   5   1  -1  -2  -1  -2  -2  -1  -2  -2  -2  -1  -1  -2  -2  -2  -1   3  -1
+X   -1  -1  -1  -2  -2  -1  -1  -2  -1  -2  -2  -1  -1  -1  -2  -1  -1  -1  -1  -2  -1  -1  -1
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/pam120.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/pam120.mat Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,34 @@
+#
+# This matrix was produced by "pam" Version 1.0.6 [28-Jul-93]
+#
+# PAM 120 substitution matrix, scale = ln(2)/2 = 0.346574
+#
+# Expected score = -1.64, Entropy = 0.979 bits
+#
+# Lowest score = -8, Highest score = 12
+#
+   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X
+A  3 -3 -1  0 -3 -1  0  1 -3 -1 -3 -2 -2 -4  1  1  1 -7 -4  0  0 -1 -1
+R -3  6 -1 -3 -4  1 -3 -4  1 -2 -4  2 -1 -5 -1 -1 -2  1 -5 -3 -2 -1 -2
+N -1 -1  4  2 -5  0  1  0  2 -2 -4  1 -3 -4 -2  1  0 -4 -2 -3  3  0 -1
+D  0 -3  2  5 -7  1  3  0  0 -3 -5 -1 -4 -7 -3  0 -1 -8 -5 -3  4  3 -2
+C -3 -4 -5 -7  9 -7 -7 -4 -4 -3 -7 -7 -6 -6 -4  0 -3 -8 -1 -3 -6 -7 -4
+Q -1  1  0  1 -7  6  2 -3  3 -3 -2  0 -1 -6  0 -2 -2 -6 -5 -3  0  4 -1
+E  0 -3  1  3 -7  2  5 -1 -1 -3 -4 -1 -3 -7 -2 -1 -2 -8 -5 -3  3  4 -1
+G  1 -4  0  0 -4 -3 -1  5 -4 -4 -5 -3 -4 -5 -2  1 -1 -8 -6 -2  0 -2 -2
+H -3  1  2  0 -4  3 -1 -4  7 -4 -3 -2 -4 -3 -1 -2 -3 -3 -1 -3  1  1 -2
+I -1 -2 -2 -3 -3 -3 -3 -4 -4  6  1 -3  1  0 -3 -2  0 -6 -2  3 -3 -3 -1
+L -3 -4 -4 -5 -7 -2 -4 -5 -3  1  5 -4  3  0 -3 -4 -3 -3 -2  1 -4 -3 -2
+K -2  2  1 -1 -7  0 -1 -3 -2 -3 -4  5  0 -7 -2 -1 -1 -5 -5 -4  0 -1 -2
+M -2 -1 -3 -4 -6 -1 -3 -4 -4  1  3  0  8 -1 -3 -2 -1 -6 -4  1 -4 -2 -2
+F -4 -5 -4 -7 -6 -6 -7 -5 -3  0  0 -7 -1  8 -5 -3 -4 -1  4 -3 -5 -6 -3
+P  1 -1 -2 -3 -4  0 -2 -2 -1 -3 -3 -2 -3 -5  6  1 -1 -7 -6 -2 -2 -1 -2
+S  1 -1  1  0  0 -2 -1  1 -2 -2 -4 -1 -2 -3  1  3  2 -2 -3 -2  0 -1 -1
+T  1 -2  0 -1 -3 -2 -2 -1 -3  0 -3 -1 -1 -4 -1  2  4 -6 -3  0  0 -2 -1
+W -7  1 -4 -8 -8 -6 -8 -8 -3 -6 -3 -5 -6 -1 -7 -2 -6 12 -2 -8 -6 -7 -5
+Y -4 -5 -2 -5 -1 -5 -5 -6 -1 -2 -2 -5 -4  4 -6 -3 -3 -2  8 -3 -3 -5 -3
+V  0 -3 -3 -3 -3 -3 -3 -2 -3  3  1 -4  1 -3 -2 -2  0 -8 -3  5 -3 -3 -1
+B  0 -2  3  4 -6  0  3  0  1 -3 -4  0 -4 -5 -2  0  0 -6 -3 -3  4  2 -1
+Z -1 -1  0  3 -7  4  4 -2  1 -3 -3 -1 -2 -6 -1 -1 -2 -7 -5 -3  2  4 -1
+X -1 -2 -1 -2 -4 -1 -1 -2 -2 -1 -2 -2 -2 -3 -2 -1 -1 -5 -3 -1 -1 -1 -2
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/data/pam250.mat
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/data/pam250.mat Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,34 @@
+#
+# This matrix was produced by "pam" Version 1.0.6 [28-Jul-93]
+#
+# PAM 250 substitution matrix, scale = ln(2)/3 = 0.231049
+#
+# Expected score = -0.844, Entropy = 0.354 bits
+#
+# Lowest score = -8, Highest score = 17
+#
+   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X
+A  2 -2  0  0 -2  0  0  1 -1 -1 -2 -1 -1 -3  1  1  1 -6 -3  0  0  0  0
+R -2  6  0 -1 -4  1 -1 -3  2 -2 -3  3  0 -4  0  0 -1  2 -4 -2 -1  0 -1
+N  0  0  2  2 -4  1  1  0  2 -2 -3  1 -2 -3  0  1  0 -4 -2 -2  2  1  0
+D  0 -1  2  4 -5  2  3  1  1 -2 -4  0 -3 -6 -1  0  0 -7 -4 -2  3  3 -1
+C -2 -4 -4 -5 12 -5 -5 -3 -3 -2 -6 -5 -5 -4 -3  0 -2 -8  0 -2 -4 -5 -3
+Q  0  1  1  2 -5  4  2 -1  3 -2 -2  1 -1 -5  0 -1 -1 -5 -4 -2  1  3 -1
+E  0 -1  1  3 -5  2  4  0  1 -2 -3  0 -2 -5 -1  0  0 -7 -4 -2  3  3 -1
+G  1 -3  0  1 -3 -1  0  5 -2 -3 -4 -2 -3 -5  0  1  0 -7 -5 -1  0  0 -1
+H -1  2  2  1 -3  3  1 -2  6 -2 -2  0 -2 -2  0 -1 -1 -3  0 -2  1  2 -1
+I -1 -2 -2 -2 -2 -2 -2 -3 -2  5  2 -2  2  1 -2 -1  0 -5 -1  4 -2 -2 -1
+L -2 -3 -3 -4 -6 -2 -3 -4 -2  2  6 -3  4  2 -3 -3 -2 -2 -1  2 -3 -3 -1
+K -1  3  1  0 -5  1  0 -2  0 -2 -3  5  0 -5 -1  0  0 -3 -4 -2  1  0 -1
+M -1  0 -2 -3 -5 -1 -2 -3 -2  2  4  0  6  0 -2 -2 -1 -4 -2  2 -2 -2 -1
+F -3 -4 -3 -6 -4 -5 -5 -5 -2  1  2 -5  0  9 -5 -3 -3  0  7 -1 -4 -5 -2
+P  1  0  0 -1 -3  0 -1  0  0 -2 -3 -1 -2 -5  6  1  0 -6 -5 -1 -1  0 -1
+S  1  0  1  0  0 -1  0  1 -1 -1 -3  0 -2 -3  1  2  1 -2 -3 -1  0  0  0
+T  1 -1  0  0 -2 -1  0  0 -1  0 -2  0 -1 -3  0  1  3 -5 -3  0  0 -1  0
+W -6  2 -4 -7 -8 -5 -7 -7 -3 -5 -2 -3 -4  0 -6 -2 -5 17  0 -6 -5 -6 -4
+Y -3 -4 -2 -4  0 -4 -4 -5  0 -1 -1 -4 -2  7 -5 -3 -3  0 10 -2 -3 -4 -2
+V  0 -2 -2 -2 -2 -2 -2 -1 -2  4  2 -2  2 -1 -1 -1  0 -6 -2  4 -2 -2 -1
+B  0 -1  2  3 -4  1  3  0  1 -2 -3  1 -2 -4 -1  0  0 -5 -3 -2  3  2 -1
+Z  0  0  1  3 -5  3  3  0  2 -2 -3  0 -2 -5  0  0 -1 -6 -4 -2  2  3 -1
+X  0 -1  0 -1 -3 -1 -1 -1 -1 -1 -1 -1 -1 -2 -1  0  0 -4 -2 -1 -1 -1 -1
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/moremath.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/moremath.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,455 @@\n+#!/usr/bin/env python\n+  \n+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+#\n+\n+\n+""" Various bits of useful math not in the standard python library.\n+\n+Constants :\n+\n+- euler_gamma  = 0.577215...\n+- catalan      = 0.915965...\n+- golden_ratio = 1.618033...\n+- bits_per_nat = log2(e) = 1/log(2) \n+- sqrt_2pi     = 2.50662...\n+    \n+Special Functions :\n+\n+- gamma()                       -- Gamma function.\n+- lngamma()                     -- Logarithm of the gamma function\n+- factorial()                   -- The factorial function.\n+- digamma()                     -- Digamma function (logarithmic derivative of gamma).\n+- trigamma()                    -- Trigamma function (derivative of digamma).\n+- entropy()                     -- The entropy of a probability vector\n+- incomplete_gamma()            -- The \'upper\' incomplete gamma function.\n+- normalized_incomplete_gamma() -- \n+- lg()                          -- Base 2 logarithms.\n+\n+\n+Vector Operations :\n+\n+- rmsd()            -- Root mean squared deviation of two point vectors\n+- minimize_rmsd()   -- Find the rigid transformation that minimized the \n+                            RMSD between two vectors of points. \n+    \n+Minimization :\n+\n+- find_root()          -- 1d root finding\n+\n+Probability Distributions :\n+- Gamma\n+- Dirichlet\n+- Multinomial\n+- Gaussian\n+\n+"""\n+\n+\n+\n+__all__ = (\'euler_gamma\', \'catalan\', \'golden_ratio\', \'bits_per_nat\', \'sqrt_2pi\',\n+            \'gamma\', \'lngamma\', \'factorial\', \'digamma\', \'trigamma\',\n+            \'entropy\', \'log2\',            \n+            \'incomplete_gamma\', \'normalized_incomplete_gamma\', \n+        #    \'integrate\',\n+       #     \'rmsd\', \'minimize_rmsd\', \'find_root\',\n+       #     \'Gamma\', \'Dirichlet\', \n+      #      \'decompose_log_odds_array\',\n+            \'argmax\', \'argmin\'\n+            )            \n+\n+from math import *\n+import random\n+from itertools import izip, count\n+\n+# Some mathematical constants\n+euler_gamma  = 0.57721566490153286060651\n+catalan      = 0.91596559417721901505460\n+golden_ratio = 1.6180339887498948482046\n+bits_per_nat = 1.44269504088896340735992468100 # = log_2(e) = 1/log(2) \n+sqrt_2pi     = 2.5066282746310005024157652848110\n+\n+\n+\n+\n+\n+# The Lanczos approximation for the gamma function is\n+#                          \n+#                -(z + g + 1/2)               (z + 1/2)                   \n+# Gamma(z+1) =  e               * (z + g + 1/2)        * Sqrt(2Pi) * C \n+#                                                                        \n+#\n+#                      c[1]    c[2]    c[3]\n+#          C = [c[0] + ----- + ----- + ----- + ...   ]\n+#                      z + 1   z + 2   z + 3 \n+#\n+#\n+#  To calculate digamma and trigamma functions we take an analytic derivative\n+#  of the Lanczos '..b'anczos_coefficients \n+        \n+    t1=0.\n+    t2=0.\n+    t3=0.\n+    for k in range(len(c)-1,0,-1):\n+        dz =1./(z+k);       \n+        dd1 = c[k]* dz\n+        t1 += dd1\n+        dd2 = dd1 * dz\n+        t2 += dd2\n+        t3 += dd2 * dz\n+\n+    t1 += c[0]\n+    c =  - (t2*t2)/(t1*t1)  +2*t3/t1\n+\n+    result = 1./(z*z)\n+    gg = z + g + 0.5\n+    result += - (z+0.5)/ (gg*gg)\n+    result += 2./gg\n+\n+    result += c\n+\n+    return result\n+\n+def incomplete_gamma(a,x) :\n+    """The \'upper\' incomplete gamma function:\n+\n+                            oo\n+                             -\n+                            |    -t  a-1\n+    incomplete_gamma(a,x) = |   e   t   dt.\n+                            |\n+                           -                         \n+                            x\n+\n+    In Mathematica, Gamma[a,x].\n+\n+    Note that, very confusingly, the phrase \'incomplete gamma fucntion\'\n+    can also refer to the same integral between 0 and x, (the \'lower\'\n+    incomplete gamma function) or to the normalized versions,\n+    normalized_incomplete_gamma() )\n+\n+\n+    See: Eric W. Weisstein. "Gamma Function." From MathWorld, A Wolfram Web Resource.\n+         http://mathworld.wolfram.com/IncompleteGammaFunction.html\n+\n+    Bugs :\n+        This implentation is not very accurate for some arguments. \n+    """   \n+    return  normalized_incomplete_gamma(a,x) * gamma(a)\n+\n+    \n+def normalized_incomplete_gamma(a,x) :\n+    """The upper, incomplete gamma function normalized so that the limiting\n+    values are zero and one.\n+    \n+     Q(a,x) = incomplete_gamma(a,x) / gamma(a) \n+\n+    See: \n+        incomplete_gamma()\n+    Bugs :\n+        This implentation is not very accurate for some arguments. \n+    """\n+    maxiter = 100\n+    epsilon = 1.48e-8\n+    small = 1e-30\n+    \n+        \n+    if a<=0 or x<0 : \n+        raise ValueError("Invalid arguments")\n+    if x == 0.0 : return 1.0\n+    \n+    if x<= a+1 :\n+        # Use the series representation\n+        term = 1./a\n+        total = term\n+        for n in range(1,maxiter) :\n+            term *= x/(a+n)\n+            total += term\n+            if abs(term/total) < epsilon : \n+                return 1. - total * exp(-x+a*log(x) - lngamma(a) )\n+        raise RuntimeError(\n+            "Failed to converge after %d iterations." % (maxiter) )\n+    else :\n+        # Use the continued fraction representation\n+        total = 1.0\n+        b = x + 1. -a\n+        c = 1./small\n+        d = 1./b\n+        h = d\n+        for i in range(1, maxiter) :\n+            an = -i * (i-a)\n+            b = b+2.\n+            d = an * d + b\n+            if abs(d) < small : d = small\n+            c = b + an /c\n+            if abs(c) < small : c= small\n+            d = 1./d\n+            term = d * c\n+            h = h * term\n+            if abs( term-1.) < epsilon :\n+                return h * exp(-x+a*log(x) - lngamma(a) )\n+        raise RuntimeError(\n+            "Failed to converge after %d iterations." % (maxiter) )\n+\n+\n+ \n+def log2( x) :\n+    """ Return the base 2 logarithm of x """\n+    return log(x,2)\n+\n+\n+def entropy( pvec, base= exp(1) ) :\n+    """ The entropy S = -Sum_i p_i ln p_i\n+        pvec is a frequency vector, not necessarily normalized. \n+    """\n+    # TODO: Optimize\n+    if len(pvec) ==0 : \n+        raise ValueError("Zero length vector")\n+        \n+        \n+    total = 0.0\n+    ent = 0.0\n+    for p in pvec:\n+        if p>0 : # 0 log(0) =0 \n+            total += p\n+            ent += - log(float(p)) *p\n+        elif p<0:\n+            raise ValueError("Negative probability")\n+    \n+    \n+    ent = (ent/total) + log(total)\n+    ent /= log(base)\n+\n+    return ent\n+   \n+    \n+\n+\n+    \n+def argmax( alist) :\n+    """Return the index of the last occurance of the maximum value in the list."""\n+    return max(izip(alist, count() ))[1]\n+\n+def argmin( alist) :\n+    """Return the index of the first occurance of the minimum value in the list."""\n+    return min(izip(alist, count() ))[1]\n+\n+     \n+    \n+           \n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/resource/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/resource/__init__.py Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,38 @@
+#  Copyright (c) 2006, The Regents of the University of California, through 
+#  Lawrence Berkeley National Laboratory (subject to receipt of any required
+#  approvals from the U.S. Dept. of Energy).  All rights reserved.
+
+#  This software is distributed under the new BSD Open Source License.
+#  <http://www.opensource.org/licenses/bsd-license.html>
+#
+#  Redistribution and use in source and binary forms, with or without 
+#  modification, are permitted provided that the following conditions are met: 
+#
+#  (1) Redistributions of source code must retain the above copyright notice, 
+#  this list of conditions and the following disclaimer. 
+#
+#  (2) Redistributions in binary form must reproduce the above copyright 
+#  notice, this list of conditions and the following disclaimer in the 
+#  documentation and or other materials provided with the distribution. 
+#
+#  (3) Neither the name of the University of California, Lawrence Berkeley 
+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors 
+#  may be used to endorse or promote products derived from this software 
+#  without specific prior written permission. 
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#  POSSIBILITY OF SUCH DAMAGE. 
+
+
+"""Access to programs, complex file formats and databases used in
+computational biology.
+"""
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/resource/astral.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/resource/astral.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,341 @@\n+\n+# Copyright 2000 by Jeffrey Chang.  All rights reserved.\n+# Copyright 2001 by Gavin E. Crooks.  All rights reserved.\n+# Modifications Copyright 2004/2005 James Casbon. \n+# Copyright 2005 by Regents of the University of California. All rights reserved\n+#   (Major rewrite for conformance to corebio. Gavin Crooks)\n+#\n+# This code is derived from the Biopython distribution and is governed by it\'s\n+# license.  Please see the LICENSE file that should have been included\n+# as part of this package.\n+\n+""" ASTRAL dataset IO.\n+\n+From http://astral.berkeley.edu/ :\n+\n+The ASTRAL Compendium for Sequence and Structure Analysis \n+\n+The ASTRAL compendium provides databases and tools useful for analyzing protein structures and their sequences.  It is partially derived from, and augments the SCOP: Structural Classification of Proteins database. Most of the resources depend upon the coordinate files maintained and distributed by the Protein Data Bank.\n+\n+* Classes :\n+    - Raf       -- A file ofASTRAL RAF (Rapid Access Format) Sequence Maps.\n+    - RafSeqMap -- A sequence map, a RAF record.\n+    - Res       -- A single residue mapping from a RAF record.\n+    \n+* Functions :\n+    - parse_domain  -- Convert an ASTRAL fasta header string into a Scop domain.\n+    - normalize_letters -- Bormalize RAF amino acid codes.\n+\n+"""\n+\n+# TODO : Need to pull more of James Casbon\'s Astral code. \n+\n+import re\n+from copy import copy\n+\n+from corebio.resource.scop import Domain, Residues\n+from corebio.data import extended_three_to_one as to_one_letter_code\n+from corebio.utils import FileIndex\n+\n+__all__ = (\'astral_evalues\', \'astral_percent_identities\', \n+            \'astral_evalues_filenames\', \'normalize_letters\', \'parse_domain\', \n+            \'Raf\', \'RafSeqMap\', \'Res\')\n+\n+# Percentage identity filtered ASTRAL SCOP genetic domain sequence subset\n+astral_percent_identities = [10,20,25,30,35,40,50,70,90,95,100]\n+\n+# E-value filtered ASTRAL SCOP genetic domain sequence subsets, based on PDB SEQRES records.\n+astral_evalues = [10, 5, 1, 0.5, 0.1, 0.05, 0.01, 0.005, 0.001, 1e-4, 1e-5, 1e-10, 1e-15,1e-20, 1e-25, 1e-50]\n+\n+# A map between evalues and astral filename suffixes.\n+astral_evalues_filenames = { \n+    10: \'e+1\', 5: \'e+0,7\', 1: \'e+0\', 0.5: \'e-0,3\', 0.1: \'e-1\',\n+    0.05: \'e-1,3\', 0.01: \'e-2\', 0.005: \'e-2,3\', 0.001: \'e-3\',\n+    1e-4: \'e-4\',  1e-5: \'e-5\', 1e-10: \'e-10\', 1e-15: \'e-15\',\n+    1e-20: \'e-20\', 1e-25: \'e-25\', 1e-50: \'e-50\' }\n+\n+\n+\n+def normalize_letters(one_letter_code) :\n+    """Convert RAF one-letter amino acid codes into IUPAC standard codes.\n+    Letters are uppercased, and "." ("Unknown") is converted to "X".\n+    """\n+    if one_letter_code == \'.\' :\n+        return \'X\'\n+    else :\n+        return one_letter_code.upper()\n+     \n+_domain_re = re.compile(r">?([\\w_\\.]*)\\s+([\\w\\.]*)\\s+\\(([^)]*)\\) (.*)")\n+def parse_domain(str) :\n+    """Convert an ASTRAL fasta header string into a Scop domain.\n+\n+    An ASTRAL (http://astral.stanford.edu/) header contains a concise\n+    description of a SCOP domain. A very similar format is used when a\n+    Domain object is converted into a string.  The Domain returned by this\n+    method contains most of the SCOP information, but it will not be located\n+    within the SCOP hierarchy (i.e. The parent node will be None). The\n+    description is composed of the SCOP protein and species descriptions.\n+\n+    A typical ASTRAL header looks like --\n+    >d1tpt_1 a.46.2.1 (1-70) Thymidine phosphorylase {Escherichia coli}\n+    """\n+\n+    m = _domain_re.match(str)\n+    if (not m) : raise ValueError("Domain: "+ str)\n+\n+    dom = Domain()\n+    dom.sid = m.group(1)\n+    dom.sccs = m.group(2)\n+    dom.residues = Residues(m.group(3))\n+    if not dom.residues.pdbid :\n+        dom.residues.pdbid= dom.sid[1:5]\n+    dom.description = m.group(4).strip()\n+\n+    return dom\n+\n+    \n+class Raf(FileIndex) :\n+    """ASTRAL RAF (Rapid Access Format) Sequence Maps.\n+\n+    The ASTRAL RAF Sequence Maps record the relationship bet'..b'  for line in raf_file:\n+            if line[0] ==\'#\':  continue  # A comment \n+            if line.isspace() : continue\n+            yield RafSeqMap(line)        \n+    records = staticmethod(records)      \n+        \n+    def index(self, resid, chainid="_") :\n+        for i in range(0, len(self.res)) :\n+            if self.res[i].resid == resid and self.res[i].chainid == chainid :\n+                return i\n+        raise KeyError("No such residue "+chainid+resid)\n+\n+    def __getslice__(self, i, j) :\n+        s = copy(self)\n+        s.res = s.res[i:j]\n+        return s\n+\n+    def append(self, res) :\n+        """Append another Res object onto the list of residue mappings."""\n+        self.res.append(res)\n+\n+    def extend(self, other) :\n+        """Append another RafSeqMap onto the end of self.\n+\n+        Both RafSeqMaps must have the same PDB ID, PDB datestamp and\n+        RAF version.  The RAF flags are erased if they are inconsistent. This\n+        may happen when fragments are taken from different chains.\n+        """\n+        if not isinstance(other, RafSeqMap):\n+            raise TypeError("Can only extend a RafSeqMap with a RafSeqMap.")\n+        if self.pdbid != other.pdbid :\n+            raise TypeError("Cannot add fragments from different proteins.")\n+        if self.version != other.version :\n+            raise TypeError("Incompatible rafs.")\n+        if self.pdb_datestamp != other.pdb_datestamp :\n+            raise TypeError("Different pdb dates!")\n+        if self.flags != other.flags :\n+            self.flags = \'\'\n+        self.res += other.res\n+\n+    def __iadd__(self, other) :\n+        self.extend(other)\n+        return self\n+\n+    def __add__(self, other) :\n+        s = copy(self)\n+        s.extend(other)\n+        return s\n+\n+    def extract_atoms(self, pdb_handle, out_handle) :\n+        """Extract all relevant ATOM and HETATOM records from a PDB file.\n+\n+        The PDB file is scanned for ATOM and HETATOM records. If the\n+        chain ID, residue ID (seqNum and iCode), and residue type match\n+        a residue in this sequence map, then the record is echoed to the\n+        output handle.\n+\n+        This is typically used to find the coordinates of a domain, or other\n+        residue subset.\n+\n+        pdb_file -- A handle to the relevant PDB file.\n+        out_file -- All output is written to this stream.\n+        """\n+        resSet = {}\n+        for r in self.res :\n+            if r.atom==\'X\' : # Unknown residue type\n+                continue\n+            chainid = r.chainid\n+            if chainid == \'_\':\n+                chainid = \' \'\n+            resid = r.resid\n+            resSet[(chainid,resid)] = r\n+\n+        resFound = {}\n+        for line in pdb_handle :\n+            if line.startswith("ATOM  ") or line.startswith("HETATM") :\n+                chainid = line[21:22]\n+                resid = line[22:27].strip()\n+                key = (chainid, resid)\n+                if key in resSet:\n+                    res = resSet[key]\n+                    atom_aa = res.atom\n+                    resName = line[17:20].capitilize()\n+                    if resName in to_one_letter_code :\n+                        if to_one_letter_code[resName] == atom_aa :\n+                            out_handle.write(line)\n+                            resFound[key] = res\n+\n+        if len(resSet) != len(resFound) :\n+            raise RuntimeError(\'I could not find at least one ATOM or \' \n+               \'HETATM record for each and every residue in this sequence map.\')\n+\n+        \n+class Res(object) :\n+    """ A single residue mapping from a RAF record.\n+\n+    - chainid -- A single character chain ID.\n+    - resid   -- The residue ID. \n+    - atom    -- amino acid one-letter code from ATOM records. \n+    - seqres  -- amino acid one-letter code from SEQRES records.\n+    """\n+    def __init__(self) :\n+        self.chainid = \'\'\n+        self.resid = \'\'\n+        self.atom = \'\'\n+        self.seqres = \'\'\n+\n+   \n\\ No newline at end of file\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/resource/scop.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/resource/scop.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,757 @@\n+\n+# Copyright 2000 by Jeffrey Chang.  All rights reserved.\n+# Copyright 2001 by Gavin E. Crooks.  All rights reserved.\n+# Modifications Copyright 2004/2005 James Casbon. \n+# Copyright 2005 by Regents of the University of California. All rights Reserved.\n+#   (Major rewrite for conformance to corebio. Gavin Crooks)\n+#\n+# This code is derived from the Biopython distribution and is governed by it\'s\n+# license.  Please see the LICENSE file that should have been included\n+# as part of this package.\n+\n+\n+""" SCOP: Structural Classification of Proteins.\n+\n+The SCOP database aims to provide a manually constructed classification of\n+all know protein structures into a hierarchy, the main levels of which\n+are family, superfamily and fold.\n+\n+* SCOP: http://scop.mrc-lmb.cam.ac.uk/scop/\n+* Introduction: http://scop.mrc-lmb.cam.ac.uk/scop/intro.html\n+* SCOP parsable files: http://scop.mrc-lmb.cam.ac.uk/scop/parse/\n+\n+The Scop object in this module represents the entire SCOP classification. It\n+can be built from the three SCOP parsable files (see DesRecord, HieRecord and\n+ClaRecord), modified is so desired, and converted back to the same file formats.\n+A single SCOP domain (represented by the Domain class) can be obtained from\n+Scop using the domain\'s SCOP identifier (sid).\n+\n+Classes:\n+ - Scop     -- The entire SCOP hierarchy.\n+ - Node     -- A node in the SCOP hierarchy.\n+ - Domain   -- A SCOP domain.\n+ - Residues -- A collection of residues from a PDB structure.\n+ - HieRecord -- Handle the SCOP HIErarchy files.\n+ - DesRecord -- Handle the SCOP DEScription file.\n+ - ClaRecord -- Handle the SCOP CLAssification file.\n+\n+\n+nodeCodeDict  -- A mapping between known 2 letter node codes and a longer\n+                  description. The known node types are \'cl\' (class), \'cf\'\n+                  (fold), \'sf\' (superfamily), \'fa\' (family), \'dm\' (domain), \n+                  \'sp\' (species), \'px\' (domain). Additional node types may\n+                  be added in the future.\n+"""\n+\n+import os, re\n+\n+\n+nodeCodeDict = { \'cl\':\'class\', \'cf\':\'fold\', \'sf\':\'superfamily\',\n+                 \'fa\':\'family\', \'dm\':\'protein\', \'sp\':\'species\', \'px\':\'domain\'}\n+\n+\n+_nodetype_to_code= dict([[v,k] for k,v in nodeCodeDict.items()])\n+\n+\n+nodeCodeOrder = [ \'ro\', \'cl\', \'cf\', \'sf\', \'fa\', \'dm\', \'sp\', \'px\' ] \n+\n+\n+def cmp_sccs(sccs1, sccs2) :\n+    """Order SCOP concise classification strings (sccs).\n+\n+    a.4.5.1 < a.4.5.11 < b.1.1.1 \n+\n+    A sccs (e.g. a.4.5.11) compactly represents a domain\'s classification.\n+    The letter represents the class, and the numbers are the fold,\n+    superfamily, and family, respectively.\n+\n+    """\n+\n+    s1 = sccs1.split(".")\n+    s2 = sccs2.split(".")\n+\n+    if s1[0] != s2[0]: return cmp(s1[0], s2[0])\n+\n+    s1 = map(int, s1[1:])\n+    s2 = map(int, s2[1:])\n+\n+    return cmp(s1,s2)\n+\n+\n+\n+def _open_scop_file(scop_dir_path, version, filetype) :\n+    filename = "dir.%s.scop.txt_%s" % (filetype,version)\n+    afile = open(os.path.join( scop_dir_path, filename))\n+    return afile\n+\n+\n+class Scop(object):\n+    """The entire SCOP hierarchy.\n+\n+    root             -- The root node of the hierarchy \n+    domains          -- A list of all domains\n+    nodes_by_sid     -- A dictionary of nodes indexed by SCOP identifier \n+                        (e.g. \'d1hbia_\')\n+    domains_by_sunid -- A dictionary of domains indexed by SCOP uniquie\n+                        identifiers (e.g. 14996)\n+    """\n+    def __init__(self):\n+        """ An empty Scop object.\n+        \n+        See also Scop.parse() and Scop.parse_files()\n+        """\n+        self.root = None\n+        self.domains = []\n+        self.nodes_by_sunid = dict()\n+        self.domains_by_sid = dict()\n+\n+    #@classmethod\n+    def parse(cls, dir_path, version) :\n+        """Build the SCOP hierarchy from the SCOP parsable files.\n+            \n+         - dir_path -- A directory that contains the SCOP files\n+         - version  -- The SCOP version (as a string)\n+         \n+        The S'..b'2\n+\n+    sid -- The SCOP ID of the entry, e.g. d1anu1\n+    residues -- The domain definition as a Residues object\n+    hierarchy -- A string specifying where this domain is in the hierarchy.\n+    """\n+    def __init__(self, record= None):\n+        self.sid = \'\'\n+        self.residues = []\n+        self.hierarchy = \'\'\n+        \n+        if record:\n+            entry = record.rstrip()  # no trailing whitespace\n+            columns = entry.split("\\t")  # separate the tab-delineated cols\n+            if len(columns) != 4:\n+                raise ValueError("I don\'t understand the format of %s" % entry)\n+            self.sid, pdbid, res, self.hierarchy = columns\n+            self.residues = Residues(res)\n+            self.residues.pdbid = pdbid\n+        \n+    def __str__(self):\n+        s = []\n+        s.append(self.sid)\n+        s.append(str(self.residues).replace(" ","\\t") )\n+        s.append(self.hierarchy)\n+        return "\\t".join(s) + "\\n"\n+        \n+    #@staticmethod\n+    def records(dom_file):\n+        """Iterates over a DOM file, generating DomRecords """\n+        for line in dom_file:\n+            if line[0] ==\'#\':  continue  # A comment \n+            if line.isspace() : continue\n+            yield DomRecord(line)\n+    records = staticmethod(records)\n+# End DomRecord\n+    \n+\n+    \n+\n+_pdbid_re = re.compile(r"^(\\w\\w\\w\\w)(?:$|\\s+|_)(.*)")\n+_fragment_re = re.compile(r"\\(?(\\w:)?(-?\\w*)-?(-?\\w*)\\)?(.*)")\n+\n+class Residues(object) :\n+    """A collection of residues from a PDB structure.\n+\n+    This class provides code to work with SCOP domain definitions. These\n+    are concisely expressed as a one or more chain fragments. For example,\n+    "(1bba A:10-20,B:)" indicates residue 10 through 20 (inclusive) of\n+    chain A, and every residue of chain B in the pdb structure 1bba. The pdb\n+    id and brackets are optional. In addition "-" indicates every residue of\n+    a pbd structure with one unnamed chain.\n+\n+    Start and end residue ids consist of the residue sequence number and an\n+    optional single letter insertion code. e.g. "12", "-1", "1a", "1000"\n+\n+\n+    pdbid -- An optional PDB id, e.g. "1bba"\n+    fragments -- A sequence of tuples (chainID, startResID, endResID)\n+    """\n+\n+\n+    def __init__(self, str=None) :\n+        self.pdbid = \'\'\n+        self.fragments = ()\n+        if str is not None : self._parse(str)\n+\n+\n+    def _parse(self, string):\n+        string = string.strip()\n+\n+        #Is there a pdbid at the front? e.g. 1bba A:1-100\n+        m = _pdbid_re.match(string)\n+        if m is not None :\n+            self.pdbid = m.group(1)\n+            string = m.group(2) # Everything else\n+\n+        if string==\'\' or string == \'-\' or string==\'(-)\':  # no fragments, whole sequence\n+            return\n+    \n+        fragments = []\n+        for l in string.split(",") :\n+            m = _fragment_re.match(l)\n+            if m is None:\n+                raise ValueError("I don\'t understand the format of %s" % l)\n+            chain, start, end, postfix = m.groups()\n+\n+            if postfix != "" :\n+                 raise ValueError("I don\'t understand the format of %s" % l )\n+\n+            if chain:\n+                if chain[-1] != \':\':\n+                    raise ValueError("I don\'t understand the chain in %s" % l)\n+                chain = chain[:-1]   # chop off the \':\'\n+            else :\n+                chain ="" \n+            \n+            fragments.append((chain, start, end))\n+        self.fragments = tuple(fragments)\n+            \n+    def __str__(self):\n+        prefix =""\n+        if self.pdbid :\n+            prefix =self.pdbid +\' \'\n+            \n+        if not self.fragments: return prefix+\'-\'\n+        strs = []\n+        for chain, start, end in self.fragments:\n+            s = []\n+            if chain: s.append("%s:" % chain)\n+            if start: s.append("%s-%s" % (start, end))\n+            strs.append("".join(s))\n+        return prefix+ ",".join(strs)\n+# End Residues\n+    \n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/resource/stride.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/resource/stride.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,164 @@
+
+#  Copyright (c) 2003 Gavin E. Crooks
+#  Copyright (c) 2005 David D. Ding <dding@berkeley.edu>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+
+"""STRIDE: Protein secondary structure assignment from atomic coordinates.
+
+This module provides an interface to STRIDE, a c program used to recognize
+secondary structural elements in proteins from their atomic coordinates.
+
+"""
+
+from corebio.seq import Seq, protein_alphabet, Alphabet
+from corebio.resource.astral import to_one_letter_code
+
+# alphabet for stride secondary structure
+stride_alphabet = Alphabet("HGIEBC12345678@&T")
+
+# Dictionary for conversion between names and alphabet
+stride_alphabet_names  = ( 
+    "H", "AlphaHelix",
+    "G", "310Helix",
+    "I", "PiHelix",
+    "E", "Strand",
+    "b", "Bridge",
+    "B", "Bridge",
+    "C", "Coil",
+    "1", "TurnI",
+    "2", "TurnI'",
+    "3", "TurnII",
+    "4", "TurnII'",
+    "5", "TurnVIa",
+    "6", "TurnVIb",
+    "7", "TurnVIII",
+    "8", "TurnIV",
+    "@", "GammaClassic",
+    "&", "GammaInv",
+    "T", "Turn"
+    )
+
+
+class Stride(object) :
+    def __init__(self, stride_file) :
+        """ Read and parse a STRIDE output file.
+        
+        args:
+            - stride_file   : An open file handle
+        attributes :
+            - pdbid     : The PDB id.
+            - res       : A list of Res objects, one per PDB resiude
+        """     
+        res =[]
+        f=stride_file
+        self.pdbid = f.readline()[75:79]
+        for l in f:
+            if l[0:3] =="ASG":
+                res.append(Res(l)) 
+                
+        self.res = res # A list of Res objects
+        
+        self._res_dict = None
+
+    def total_area(self) :
+        """ Return the solvent accessible area """
+        area = 0
+        for i in self.res :
+            area += i.solvent_acc_area
+        return area
+    
+    def primary(self):
+        """ Return the protein primary sequence as a Seq object."""
+        return Seq(''.join([r.primary_seq for r in self.res]), protein_alphabet)
+        
+    def secondary(self):
+        """Return the secondary structure of the protien as a Seq object"""
+        return Seq(''.join([r.secondary_str for r in self.res]), stride_alphabet)
+        
+        
+    def get_res(self, chainid, resid) :
+        """ Return the given resiude """
+        if not self._res_dict :
+            d = {}
+            for r in self.res :
+                d[ (r.chainid, r.resid)] = r
+            self._res_dict =d
+        
+        return self._res_dict[(chainid, resid)]
+
+    
+    
+class Res(object):
+    """ Structural information of a single resiude. An ASG line from a stride
+        output file.
+        
+        Attributes :
+         - chainid 
+         - resid   
+         - primary_seq 
+         - secondary_str 
+         - solvent_acc_area 
+         - phi 
+         - psi
+    """
+         
+    def __init__(self, res_line) :
+        """ Eats a single 'ASG' line from a stride file, splits it up  
+        into parts and return a Res object."""
+            
+        if (len(res_line)<70): 
+            raise ValueError("Line not long enough")
+        try: 
+            self.chainid = res_line[9:10]
+            # STRIDE converts blank chain ids into dashes. Undo.
+            if self.chainid=="-" : self.chainid = " "
+                
+            # In rare cases STRIDE columns can be misaligned. Grab extra 
+            # white space to compensate.
+            self.resid = res_line[10:15].strip() 
+            self.primary_seq = to_one_letter_code[res_line[5:8].capitalize()]
+            self.secondary_str = res_line[24:25]
+            self.solvent_acc_area = float(res_line[64:71]) 
+            self.phi = float(res_line[42:49].strip())
+            self.psi = float(res_line[52:59].strip())
+        except FloatingPointError:
+            raise FloatingPointError("Can't float phi, psi, or area")
+        except KeyError:
+            raise KeyError("Can't find three letter code in dictionary")
+        except LookupError:
+            raise LookupError("One of the values is out of index of res_line")
+            
+                
+            
+
+
+
+
+
+
+
+
+
+
+
+        
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,665 @@\n+\n+#  Copyright (c) 2005 Gavin E. Crooks <gec@compbio.berkeley.edu>\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+#\n+\n+\n+\n+""" Alphabetic sequences and associated tools and data.\n+\n+Seq is a subclass of a python string with additional annotation and an alphabet.\n+The characters in string must be contained in the alphabet. Various standard\n+alphabets are provided.\n+\n+\n+Classes :\n+    Alphabet    -- A subset of non-null ascii characters\n+    Seq         -- An alphabetic string\n+    SeqList     -- A collection of Seq\'s\n+  \n+Alphabets :    \n+    o generic_alphabet  -- A generic alphabet. Any printable ASCII character.\n+    o protein_alphabet -- IUCAP/IUB Amino Acid one letter codes. \n+    o nucleic_alphabet -- IUPAC/IUB Nucleic Acid codes \'ACGTURYSWKMBDHVN-\'\n+    o dna_alphabet -- Same as nucleic_alphabet, with \'U\' (Uracil) an \n+        alternative for \'T\' (Thymidine).\n+    o rna_alphabet -- Same as nucleic_alphabet, with \'T\' (Thymidine) an\n+        alternative for \'U\' (Uracil).\n+    o reduced_nucleic_alphabet -- All ambiguous codes in \'nucleic_alphabet\' are\n+        alternative to \'N\' (aNy)\n+    o reduced_protein_alphabet -- All ambiguous (\'BZJ\') and non-canonical amino \n+        acids codes ( \'U\', Selenocysteine and \'O\', Pyrrolysine)  in \n+        \'protein_alphabet\' are alternative to \'X\'.\n+    o unambiguous_dna_alphabet -- \'ACGT\'\n+    o unambiguous_rna_alphabet -- \'ACGU\'\n+    o unambiguous_protein_alphabet -- The twenty canonical amino acid one letter\n+        codes, in alphabetic order, \'ACDEFGHIKLMNPQRSTVWY\'\n+\n+Amino Acid Codes:\n+    Code  Alt.  Meaning\n+    -----------------\n+    A           Alanine\n+    B           Aspartic acid or Asparagine\n+    C           Cysteine\n+    D           Aspartate\n+    E           Glutamate\n+    F           Phenylalanine\n+    G           Glycine\n+    H           Histidine\n+    I           Isoleucine\n+    J           Leucine or Isoleucine    \n+    K           Lysine\n+    L           Leucine\n+    M           Methionine\n+    N           Asparagine\n+    O           Pyrrolysine    \n+    P           Proline\n+    Q           Glutamine\n+    R           Arginine\n+    S           Serine\n+    T           Threonine\n+    U           Selenocysteine\n+    V           Valine\n+    W           Tryptophan\n+    Y           Tyrosine\n+    Z           Glutamate or Glutamine\n+    X    ?      any\n+    *           translation stop\n+    -    .~     gap \n+\n+Nucleotide Codes:\n+    Code  Alt.  Meaning\n+    ------------------------------\n+    A           Adenosine\n+    C           Cytidine\n+    G           Guanine\n+    T           Thymidine\n+    U           Uracil\n+    R           G A (puRine)\n+    Y           T C (pYrimidine)\n+    K           G T (Ketone)\n+    M           A C (aMino group)\n+    S           G C (Strong interaction)\n+    W           A'..b't)\n+        \n+    def mask(self, letters= \'abcdefghijklmnopqrstuvwxyz\', mask=\'X\') :\n+        """Replace all occurences of letters with the mask character.\n+        The default is to replace all lower case letters with \'X\'.\n+        """\n+        LL = len(letters)\n+        if len(mask) !=1 : \n+            raise ValueError("Mask should be single character") \n+        to = mask * LL\n+        trans = maketrans( letters, to)\n+        cls = self.__class__\n+        return cls(str(self).translate(trans), self.alphabet)\n+ \n+    def translate(self) :\n+        """Translate a nucleotide sequence to a polypeptide using full\n+        IUPAC ambiguities in DNA/RNA and amino acid codes, using the\n+        standard genetic code. See corebio.transform.GeneticCode for\n+        details and more options.\n+        """\n+        # Note: masks str.translate\n+        from transform import GeneticCode\n+        return GeneticCode.std().translate(self)\n+\n+    def back_translate(self) :\n+        """Translate a protein sequence back into coding DNA, using using the\n+        standard genetic code. See corebio.transform.GeneticCode for\n+        details and more options.\n+        """\n+        from transform import GeneticCode\n+        return GeneticCode.std().back_translate(self)\n+\n+       \n+    def reverse_complement(self) :\n+        """Returns reversed complementary nucleic acid sequence (i.e. the other\n+        strand of a DNA sequence.) \n+        """\n+        return self.reverse().complement()\n+       \n+    def complement(self) :\n+        """Returns complementary nucleic acid sequence."""\n+        if not nucleic_alphabet.alphabetic(self.alphabet):\n+            raise ValueError("Incompatable alphabets")\n+        s = str.translate(self, _complement_table)\n+        cls = self.__class__\n+        return cls(s, self.alphabet, self.name, self.description) \n+ \n+        \n+# end class Seq\n+\n+\n+class SeqList(list):\n+    """ A list of sequences. \n+    \n+    Status:\n+        Beta\n+    """\n+    # TODO: If alphabet given, we should ensure that all sequences conform. \n+    # TODO: Need an isaligned() method. All seqs same length, same alphabet.\n+    __slots__ =["alphabet", "name", "description"]\n+\n+    def __init__(self, alist=[], alphabet=None, name=None, description=None):\n+        list.__init__(self, alist)\n+        self.alphabet = alphabet\n+        self.name = name\n+        self.description = description\n+\n+    # TOOWTDI. Replicates seq_io.read()\n+    #@classmethod\n+    #def read(cls, afile, alphabet = None):\n+    #    return corebio.seq_io.read(afile, alphabet)\n+    #read = classmethod(read)    \n+     \n+    def ords(self, alphabet=None) :\n+        """ Convert sequence list into a 2D array of ordinals.\n+        """\n+        if not alphabet : alphabet = self.alphabet\n+        if not alphabet : raise ValueError("No alphabet")\n+        k = []\n+        for s in self:\n+            k.append( alphabet.ords(s) )\n+        return k\n+        \n+    def tally(self, alphabet = None):\n+        """Counts the occurrences of characters in each column.""" \n+        if not alphabet : alphabet = self.alphabet\n+        if not alphabet : raise ValueError("No alphabet")        \n+        \n+        N = len(alphabet) \n+        ords = self.ords(alphabet)\n+        L = len(ords[0])\n+        counts = [ [0,]*N for l in range(0,L)]\n+        \n+        for o in ords :\n+            for j,n in enumerate(o) :\n+                if n<N : counts[ j][n] +=1\n+ \n+        return counts\n+# end class SeqList\n+\n+\n+def dna(string) :\n+    """Create an alphabetic sequence representing a stretch of DNA.    \n+    """\n+    return Seq(string, alphabet = dna_alphabet)\n+    \n+def rna(string) :\n+    """Create an alphabetic sequence representing a stretch of RNA.    \n+    """\n+    return Seq(string, alphabet = rna_alphabet)\n+\n+def protein(string) :\n+    """Create an alphabetic sequence representing a stretch of polypeptide.    \n+    """\n+    return Seq(string, alphabet = protein_alphabet)\n+\n+\n+\n+\n+ \n\\ No newline at end of file\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/__init__.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,261 @@\n+\n+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>\n+#  Copyright (c) 2006, The Regents of the University of California, through \n+#  Lawrence Berkeley National Laboratory (subject to receipt of any required\n+#  approvals from the U.S. Dept. of Energy).  All rights reserved.\n+\n+#  This software is distributed under the new BSD Open Source License.\n+#  <http://www.opensource.org/licenses/bsd-license.html>\n+#\n+#  Redistribution and use in source and binary forms, with or without \n+#  modification, are permitted provided that the following conditions are met: \n+#\n+#  (1) Redistributions of source code must retain the above copyright notice, \n+#  this list of conditions and the following disclaimer. \n+#\n+#  (2) Redistributions in binary form must reproduce the above copyright \n+#  notice, this list of conditions and the following disclaimer in the \n+#  documentation and or other materials provided with the distribution. \n+#\n+#  (3) Neither the name of the University of California, Lawrence Berkeley \n+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors \n+#  may be used to endorse or promote products derived from this software \n+#  without specific prior written permission. \n+#\n+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" \n+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE \n+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \n+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN \n+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \n+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \n+#  POSSIBILITY OF SUCH DAMAGE. \n+\n+\n+\n+\n+\n+""" Sequence file reading and writing.\n+\n+Biological sequence data is stored and transmitted using a wide variety of\n+different file formats. This package provides convient methods to read and\n+write several of these file fomats.\n+\n+CoreBio is often capable of guessing the correct file type, either from the\n+file extension or the structure of the file:\n+>>> import corebio.seq_io\n+>>> afile = open("test_corebio/data/cap.fa")\n+>>> seqs = corebio.seq_io.read(afile)\n+\n+Alternatively, each sequence file type has a seperate module named FILETYPE_io\n+(e.g. fasta_io, clustal_io).\n+>>> import corebio.seq_io.fasta_io\n+>>> afile = open("test_corebio/data/cap.fa")\n+>>> seqs = corebio.seq_io.fasta_io.read( afile )\n+\n+Sequence data can also be written back to files:\n+>>> fout = open("out.fa", "w")\n+>>> corebio.seq_io.fasta_io.write( fout, seqs )\n+\n+\n+Supported File Formats\n+----------------------\n+\n+Module              Name            Extension  read write features   \n+---------------------------------------------------------------------------\n+array_io            array, flatfile             yes  yes    none\n+clustal_io          clustalw        aln         yes  yes\n+fasta_io            fasta, Pearson  fa          yes  yes    none\n+genbank_io          genbank         gb          yes         \n+intelligenetics_io  intelligenetics ig          yes  yes\n+msf_io              msf             msf         yes\n+nbrf_io             nbrf, pir       pir         yes\n+nexus_io            nexus           nexus       yes\n+phylip_io           phylip          phy         yes\n+plain_io            plain, raw      txt         yes  yes    none\n+table_io            table           tbl         yes  yes    none\n+\n+Each IO module defines one or more of the following functions and variables:\n+\n+read(afile, alphabet=None) \n+    Read a file of sequence data and return a SeqList, a collection\n+    of Seq\'s (Alphabetic strings) and features.\n+'..b' parsers.\n+- format_extensions -- A map between filename extensions and parsers.\n+\n+"""\n+\n+# Dev. References :\n+#\n+#    - http://iubio.bio.indiana.edu/soft/molbio/readseq/java/Readseq2-help.html\n+#    - http://www.ebi.ac.uk/help/formats_frame.html\n+#    - http://www.cmbi.kun.nl/bioinf/tools/crab_pir.html\n+#    - http://bioperl.org/HOWTOs/html/SeqIO.html\n+#    - http://emboss.sourceforge.net/docs/themes/SequenceFormats.html\n+#    - http://www.cse.ucsc.edu/research/compbio/a2m-desc.html (a2m)\n+#    - http://www.genomatix.de/online_help/help/sequence_formats.html\n+\n+from corebio.seq import *\n+\n+import clustal_io\n+import fasta_io\n+import msf_io\n+import nbrf_io\n+import nexus_io\n+import plain_io\n+import phylip_io\n+#import null_io\n+import stockholm_io\n+import intelligenetics_io\n+import table_io\n+import array_io\n+import genbank_io\n+\n+__all__ = [\n+    \'clustal_io\', \n+    \'fasta_io\',\n+    \'msf_io\',\n+    \'nbrf_io\',\n+    \'nexus_io\',\n+    \'plain_io\',\n+    \'phylip_io\',\n+    \'null_io\',\n+    \'stockholm_io\',\n+    \'intelligenetics_io\',\n+    \'table_io\',\n+    \'array_io\',\n+    \'genbank_io\',\n+    \'read\',\n+    \'formats\',\n+    \'format_names\',\n+    \'format_extensions\',\n+    ]\n+\n+formats = ( clustal_io, fasta_io, plain_io, msf_io, genbank_io,nbrf_io, nexus_io, phylip_io, stockholm_io, intelligenetics_io, table_io, array_io)\n+"""Available seq_io formats"""\n+\n+\n+def format_names() :   \n+    """Return a map between format names and format modules"""\n+    global formats\n+    fnames = {}\n+    for f in formats :\n+        for name in f.names :\n+            assert name not in fnames # Insanity check\n+            fnames[name] = f  \n+    return fnames\n+\n+def format_extensions() :   \n+    """Return a map between filename extensions and sequence file types"""\n+    global formats\n+    fext = {}\n+    for f in formats :\n+        for ext in f.extensions :\n+            assert ext not in fext # Insanity check\n+            fext[ext] = f  \n+    return fext\n+\n+    \n+# seq_io._parsers is an ordered list of sequence parsers that are tried, in \n+# turn, on files of unknown format. Each parser must raise an exception when\n+# fed a format further down the list.\n+#\n+# The general trend is most common to least common file format. However, \n+# \'nbrf_io\' is before \'fasta_io\' because nbrf looks like fasta with extras, and\n+# \'array_io\' is last, since it is very general.\n+_parsers = (nbrf_io, fasta_io, clustal_io, phylip_io, genbank_io, stockholm_io, msf_io, nexus_io, table_io, array_io)\n+\n+ \n+def _get_parsers(fin) :\n+    global _parsers\n+    \n+    fnames = format_names()\n+    fext = format_extensions()\n+    parsers = list(_parsers)\n+    best_guess = parsers[0]\n+    \n+    # If a filename is supplied use the extension to guess the format.\n+    if hasattr(fin, "name") and \'.\' in fin.name :\n+        extension = fin.name.split(\'.\')[-1]\n+        if extension in  fnames:\n+            best_guess = fnames[extension]\n+        elif extension in fext :\n+            best_guess = fext[extension]\n+        \n+    if best_guess in parsers :\n+        parsers.remove(best_guess)\n+    parsers.insert(0,best_guess)\n+\n+    return parsers\n+\n+ \n+    \n+def read(fin, alphabet=None) :\n+    """ Read a sequence file and attempt to guess its format. \n+    First the filename extension (if available) is used to infer the format.\n+    If that fails, then we attempt to parse the file using several common   \n+    formats.\n+    \n+    returns :\n+        SeqList\n+    raises :\n+        ValueError - If the file cannot be parsed.\n+        ValueError - Sequence do not conform to the alphabet.\n+    """\n+\n+    alphabet = Alphabet(alphabet)\n+    parsers =  _get_parsers(fin)\n+    \n+    for p in _get_parsers(fin) :\n+        try:    \n+            return p.read(fin, alphabet)\n+        except ValueError:\n+            pass\n+        fin.seek(0)             # FIXME. Non seakable stdin? \n+            \n+    names = ", ".join([ p.names[0] for p in parsers])\n+    raise ValueError("Cannot parse sequence file: Tried %s " % names)\n+\n+\n+\n+\n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/_nexus/Nodes.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/_nexus/Nodes.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,172 @@
+# Copyright 2005 by Frank Kauff & Cymon J. Cox. All rights reserved.
+# This code is part of the Biopython distribution and governed by its
+# license. Please see the LICENSE file that should have been included
+# as part of this package.
+#
+# Nodes.py
+# 
+# Provides functionality of a linked list.
+# Each node has one (or none) predecessor, and an arbitrary number of successors.
+# Nodes can store arbitrary data in a NodeData class.
+#
+# Subclassed by Nexus.Trees to store phylogenetic trees.
+#
+# Bug reports to Frank Kauff (fkauff@duke.edu)
+#
+
+class ChainException(Exception):
+    pass
+
+class NodeException(Exception):
+    pass
+
+class Chain:
+    """Stores a list of nodes that are linked together."""
+    
+    def __init__(self):
+        """Initiates a node chain: (self)."""
+        self.chain={}
+        self.id=-1
+
+    def _get_id(self):
+        """Gets a new id for a node in the chain."""
+        self.id+=1
+        return self.id 
+   
+    def all_ids(self):
+        """Return a list of all node ids."""
+        return self.chain.keys()
+
+    def add(self,node,prev=None):
+        """Attaches node to another: (self, node, prev)."""
+        if prev is not None and prev not in self.chain:
+            raise ChainException('Unknow predecessor: '+str(prev))
+        else:
+            id=self._get_id()
+            node.set_id(id)
+            node.set_prev(prev)
+            if prev is not None:
+                self.chain[prev].add_succ(id)
+            self.chain[id]=node
+        return id
+
+    def collapse(self,id):
+        """Deletes node from chain and relinks successors to predecessor: collapse(self, id)."""
+        if id not in self.chain:
+            raise ChainException('Unknown ID: '+str(id))
+        prev_id=self.chain[id].get_prev()
+        self.chain[prev_id].remove_succ(id)
+        succ_ids=self.chain[id].get_succ()
+        for i in succ_ids:
+            self.chain[i].set_prev(prev_id)
+        self.chain[prev_id].add_succ(succ_ids)
+        node=self.chain[id]
+        self.kill(id)
+        return node
+
+    def kill(self,id):
+        """Kills a node from chain without caring to what it is connected: kill(self,id)."""
+        if id not in self.chain:
+            raise ChainException('Unknown ID: '+str(id))
+        else:
+            del self.chain[id]
+
+    def unlink(self,id):
+        """Disconnects node from his predecessor: unlink(self,id)."""
+        if id not in self.chain:
+            raise ChainException('Unknown ID: '+str(id))
+        else:
+            prev_id=self.chain[id].prev
+            if prev_id is not None:
+                self.chain[prev_id].succ.pop(self.chain[prev_id].succ.index(id))
+            self.chain[id].prev=None
+            return prev_id
+
+    def link(self, parent,child):
+        """Connects son to parent: link(self,son,parent)."""
+        if child not in self.chain:
+            raise ChainException('Unknown ID: '+str(child))
+        elif parent not in self.chain:
+            raise ChainException('Unknown ID: '+str(parent))
+        else:
+            self.unlink(child)
+            self.chain[parent].succ.append(child)
+            self.chain[child].set_prev(parent)
+
+    def is_parent_of(self,parent,grandchild):
+        """Check if grandchild is a subnode of parent: is_parent_of(self,parent,grandchild)."""
+        if grandchild==parent or grandchild in self.chain[parent].get_succ():
+            return True
+        else:
+            for sn in self.chain[parent].get_succ():
+                if self.is_parent_of(sn,grandchild):
+                    return True
+            else:
+                return False
+
+    def trace(self,start,finish):
+        """Returns a list of all node_ids between two nodes (excluding start, including end): trace(start,end)."""
+        if start not in self.chain or finish not in self.chain:
+            raise NodeException('Unknown node.')
+        if not self.is_parent_of(start,finish) or start==finish:
+            return []
+        for sn in self.chain[start].get_succ():
+            if self.is_parent_of(sn,finish):
+                return [sn]+self.trace(sn,finish)
+                
+class Node:
+    """A single node."""
+
+    def __init__(self,data=None):
+        """Represents a node with one predecessor and multiple successors: (self, data=None)."""
+        self.id=None
+        self.data=data
+        self.prev=None
+        self.succ=[]
+
+    def set_id(self,id):
+        """Sets the id of a node, if not set yet: (self,id)."""
+        if self.id is not None:
+            raise NodeException, 'Node id cannot be changed.'
+        self.id=id
+
+    def get_id(self):
+        """Returns the node's id: (self)."""
+        return self.id
+
+    def get_succ(self):
+        """Returns a list of the node's successors: (self)."""
+        return self.succ
+
+    def get_prev(self):
+        """Returns the id of the node's predecessor: (self)."""
+        return self.prev
+
+    def add_succ(self,id):
+        """Adds a node id to the node's successors: (self,id)."""
+        if isinstance(id,type([])):
+            self.succ.extend(id)
+        else:
+            self.succ.append(id)
+
+    def remove_succ(self,id):
+        """Removes a node id from the node's successors: (self,id)."""
+        self.succ.remove(id)
+
+    def set_succ(self,new_succ):
+        """Sets the node's successors: (self,new_succ)."""
+        if not isinstance(new_succ,type([])):
+            raise NodeException, 'Node successor must be of list type.'
+        self.succ=new_succ
+
+    def set_prev(self,id):
+        """Sets the node's predecessor: (self,id)."""
+        self.prev=id
+    
+    def get_data(self):
+        """Returns a node's data: (self)."""
+        return self.data
+
+    def set_data(self,data):
+        """Sets a node's data: (self,data)."""
+        self.data=data
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/_nexus/Trees.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/_nexus/Trees.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,686 @@\n+\n+#\n+# Trees.py \n+#\n+# Copyright 2005 by Frank Kauff & Cymon J. Cox. All rights reserved.\n+# This code is part of the Biopython distribution and governed by its\n+# license. Please see the LICENSE file that should have been included\n+# as part of this package.\n+#\n+# Tree class handles phylogenetic trees. Provides a set of methods to read and write newick-format tree\n+# descriptions, get information about trees (monphyly of taxon sets, congruence between trees, common ancestors,...)\n+# and to manipulate trees (reroot trees, split terminal nodes).\n+#\n+# Bug reports welcome: fkauff@duke.edu\n+#\n+\n+import sys, random, sets\n+import Nodes\n+\n+PRECISION_BRANCHLENGTH=6\n+PRECISION_SUPPORT=6\n+\n+class TreeError(Exception): pass\n+\n+class NodeData:\n+    """Stores tree-relevant data associated with nodes (e.g. branches or otus)."""\n+    def __init__(self,taxon=None,branchlength=0.0,support=None):\n+        self.taxon=taxon\n+        self.branchlength=branchlength\n+        self.support=support\n+\n+class Tree(Nodes.Chain):\n+    """Represents a tree using a chain of nodes with on predecessor (=ancestor)\n+    and multiple successors (=subclades).\n+    """ \n+    # A newick tree is parsed into nested list and then converted to a node list in two stages\n+    # mostly due to historical reasons. This could be done in one swoop). Note: parentheses ( ) and\n+    # colon : are not allowed in taxon names. This is against NEXUS standard, but makes life much\n+    # easier when parsing trees.\n+    \n+    ## NOTE: Tree should store its data class in something like self.dataclass=data,\n+    ## so that nodes that are generated have easy access to the data class\n+    ## Some routines use automatically NodeData, this needs to be more concise\n+\n+    def __init__(self,tree=None,weight=1.0,rooted=False,name=\'\',data=NodeData,values_are_support=False,max_support=1.0):\n+        """Ntree(self,tree)."""\n+        Nodes.Chain.__init__(self)\n+        self.dataclass=data\n+        self.__values_are_support=values_are_support\n+        self.max_support=max_support\n+        self.weight=weight\n+        self.rooted=rooted\n+        self.name=name\n+        root=Nodes.Node(data())\n+        self.add(root)\n+        self.root=root.id\n+        if tree:    # use the tree we have\n+            # if Tree is called from outside Nexus parser, we need to get rid of linebreaks, etc\n+            tree=tree.strip().replace(\'\\n\',\'\').replace(\'\\r\',\'\')\n+            # there\'s discrepancy whether newick allows semicolons et the end\n+            tree=tree.rstrip(\';\')\n+            self._add_subtree(parent_id=root.id,tree=self._parse(tree)[0])\n+        \n+    def _parse(self,tree):\n+        """Parses (a,b,c...)[[[xx]:]yy] into subcomponents and travels down recursively."""\n+        \n+        if tree.count(\'(\')!=tree.count(\')\'):\n+            raise TreeError, \'Parentheses do not match in (sub)tree: \'+tree\n+        if tree.count(\'(\')==0: # a leaf\n+            colon=tree.rfind(\':\')   \n+            if colon>-1:\n+                return [tree[:colon],self._get_values(tree[colon+1:])]\n+            else:\n+                return [tree,[None]]\n+        else:\n+            closing=tree.rfind(\')\')\n+            val=self._get_values(tree[closing+1:])\n+            if not val:\n+                val=[None]\n+            subtrees=[]\n+            plevel=0\n+            prev=1\n+            for p in range(1,closing):\n+                if tree[p]==\'(\':\n+                    plevel+=1\n+                elif tree[p]==\')\':\n+                    plevel-=1\n+                elif tree[p]==\',\' and plevel==0:\n+                    subtrees.append(tree[prev:p])\n+                    prev=p+1\n+            subtrees.append(tree[prev:closing])\n+            subclades=[self._parse(subtree) for subtree in subtrees]\n+            return [subclades,val]\n+    \n+    def _add_subtree(self,parent_id=None,tree=None):\n+        """Adds leaf or tree (in newick format) to a parent_id. (self,parent_id,tree)."""\n+        \n+        if parent_id is None:\n+   '..b'ppend([root.id,outgroup_node,0.0,0.0])   # add branch to outgroup to unrooted tree\n+        _connect_subtree(root.id,ingroup_node)      # add ingroup\n+        _connect_subtree(root.id,outgroup_node)     # add outgroup\n+        # if theres still a lonely node in self.chain, then it\'s the old root, and we delete it\n+        oldroot=[i for i in self.all_ids() if self.node(i).prev is None and i!=self.root]\n+        if len(oldroot)>1:\n+            raise TreeError, \'Isolated nodes in tree description: %s\' % \',\'.join(oldroot)\n+        elif len(oldroot)==1:\n+            self.kill(oldroot[0])\n+        return self.root\n+        \n+         \n+def consensus(trees, threshold=0.5,outgroup=None):\n+    """Compute a majority rule consensus tree of all clades with relative frequency>=threshold from a list of trees."""\n+    \n+    total=len(trees)\n+    if total==0:\n+        return None\n+    # shouldn\'t we make sure that it\'s NodeData or subclass??\n+    dataclass=trees[0].dataclass\n+    max_support=trees[0].max_support\n+    clades={}\n+    #countclades={}\n+    alltaxa=sets.Set(trees[0].get_taxa())\n+    # calculate calde frequencies\n+    c=0\n+    for t in trees:\n+        c+=1\n+        #if c%50==0:\n+        #    print c\n+        if alltaxa!=sets.Set(t.get_taxa()):\n+            raise TreeError, \'Trees for consensus must contain the same taxa\'\n+        t.root_with_outgroup(outgroup=outgroup)\n+        for st_node in t._walk(t.root):\n+            subclade_taxa=t.get_taxa(st_node)\n+            subclade_taxa.sort()\n+            subclade_taxa=str(subclade_taxa) # lists are not hashable\n+            if subclade_taxa in clades:\n+                clades[subclade_taxa]+=float(t.weight)/total\n+            else:\n+                clades[subclade_taxa]=float(t.weight)/total\n+            #if subclade_taxa in countclades:\n+            #    countclades[subclade_taxa]+=t.weight\n+            #else:\n+            #    countclades[subclade_taxa]=t.weight\n+    # weed out clades below threshold\n+    for (c,p) in clades.items():\n+        if p<threshold:\n+            del clades[c]\n+    # create a tree with a root node\n+    consensus=Tree(name=\'consensus_%2.1f\' % float(threshold),data=dataclass)\n+    # each clade needs a node in the new tree, add them as isolated nodes\n+    for (c,s) in clades.items():\n+        node=Nodes.Node(data=dataclass())\n+        node.data.support=s\n+        node.data.taxon=sets.Set(eval(c))\n+        consensus.add(node)\n+    # set root node data\n+    consensus.node(consensus.root).data.support=None\n+    consensus.node(consensus.root).data.taxon=alltaxa\n+    # we sort the nodes by no. of taxa in the clade, so root will be the last\n+    consensus_ids=consensus.all_ids()\n+    consensus_ids.sort(lambda x,y:len(consensus.node(x).data.taxon)-len(consensus.node(y).data.taxon))\n+    # now we just have to hook each node to the next smallest node that includes all taxa of the current \n+    for i,current in enumerate(consensus_ids[:-1]): # skip the last one which is the root\n+        #print \'----\'\n+        #print \'current: \',consensus.node(current).data.taxon\n+        # search remaining nodes\n+        for parent in consensus_ids[i+1:]:\n+            #print \'parent: \',consensus.node(parent).data.taxon\n+            if consensus.node(parent).data.taxon.issuperset(consensus.node(current).data.taxon):\n+                break\n+        else:\n+            sys.exit(\'corrupt tree structure?\')\n+        # internal nodes don\'t have taxa\n+        if len(consensus.node(current).data.taxon)==1:\n+            consensus.node(current).data.taxon=consensus.node(current).data.taxon.pop()\n+            # reset the support for terminal nodes to maximum\n+            #consensus.node(current).data.support=max_support\n+        else:\n+            consensus.node(current).data.taxon=None\n+        consensus.link(parent,current)\n+    # eliminate root taxon name\n+    consensus.node(consensus_ids[-1]).data.taxon=None \n+    return consensus\n+\n+    \n+                \n+        \n\\ No newline at end of file\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/_nexus/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/_nexus/__init__.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,1612 @@\n+# Nexus.py - a NEXUS parser\n+#\n+# Copyright 2005 by Frank Kauff & Cymon J. Cox. All rights reserved.\n+# This code is part of the Biopython distribution and governed by its\n+# license. Please see the LICENSE file that should have been included\n+# as part of this package.\n+# \n+# Bug reports welcome: fkauff@duke.edu\n+#\n+\n+"""Parse the contents of a nexus file.\n+Based upon \'NEXUS: An extensible file format for systematic information\'\n+Maddison, Swofford, Maddison. 1997. Syst. Biol. 46(4):590-621\n+\n+Authors: Frank Kauff and Cymon J. Cox\n+"""\n+\n+import os,sys, math, random, copy\n+import sets\n+\n+# --- Changes from Bio.Nexus ---\n+# Renamed Nexus.py to __init__.py. Helps with api documentation.\n+# One further change in file, tagged with \'GEC\'\n+#from Bio.Alphabet import IUPAC\n+#from Bio.Data import IUPACData\n+#from Bio.Seq import Seq\n+\n+\n+from corebio.seq import Seq, Alphabet, protein_alphabet\n+import corebio.data as data\n+from corebio.utils import Struct\n+\n+IUPACData = Struct( \n+    ambiguous_dna_letters = data.dna_extended_letters,\n+    ambiguous_rna_letters = data.rna_extended_letters,\n+    ambiguous_dna_values = data.dna_ambiguity,\n+    ambiguous_rna_values = data.rna_ambiguity,\n+    protein_letters = data.amino_acid_letters, \n+    unambiguous_dna_letters = data.dna_letters,\n+    unambiguous_rna_letters = data.rna_letters,\n+    )\n+    \n+IUPAC = Struct(\n+    ambiguous_dna = Alphabet(IUPACData.ambiguous_dna_letters+\'-?\'),\n+    ambiguous_rna = Alphabet(IUPACData.ambiguous_rna_letters+\'-?\'),\n+    protein = protein_alphabet #Alphabet(IUPACData.protein_letters+\'-?\')\n+    )\n+\n+\n+\n+# End Changes\n+\n+\n+from Trees import Tree,NodeData\n+\n+C = False\n+\n+#try:\n+#    import cnexus\n+#except ImportError:\n+#    C=False\n+#else:\n+#    C=True\n+\n+INTERLEAVE=70\n+SPECIAL_COMMANDS=[\'charstatelabels\',\'charlabels\',\'taxlabels\', \'taxset\', \'charset\',\'charpartition\',\'taxpartition\',\\\n+        \'matrix\',\'tree\', \'utree\',\'translate\']\n+KNOWN_NEXUS_BLOCKS = [\'trees\',\'data\', \'characters\', \'taxa\', \'sets\']\n+PUNCTUATION=\'()[]{}/\\,;:=*\\\'"`+-<>\'\n+MRBAYESSAFE=\'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_\'\n+WHITESPACE=\' \\t\\n\'\n+#SPECIALCOMMENTS=[\'!\',\'&\',\'%\',\'/\',\'\\\\\',\'@\'] #original list of special comments\n+SPECIALCOMMENTS=[\'&\'] # supported special comment (\'tree\' command), all others are ignored\n+CHARSET=\'chars\'\n+TAXSET=\'taxa\'\n+\n+class NexusError(Exception): pass\n+\n+class CharBuffer:\n+    """Helps reading NEXUS-words and characters from a buffer."""\n+    def __init__(self,string):\n+        if string:\n+            self.buffer=list(string)\n+        else:\n+            self.buffer=[]\n+    \n+    def peek(self):\n+        if self.buffer:\n+            return self.buffer[0]\n+        else:\n+            return None\n+\n+    def peek_nonwhitespace(self):\n+        b=\'\'.join(self.buffer).strip()\n+        if b:\n+            return b[0]\n+        else:\n+            return None\n+                \n+    def next(self):\n+        if self.buffer:\n+            return self.buffer.pop(0)\n+        else:\n+            return None\n+\n+    def next_nonwhitespace(self):\n+        while True:\n+            p=self.next()\n+            if p is None:\n+                break\n+            if p not in WHITESPACE: \n+                return p\n+        return None\n+\n+    def skip_whitespace(self):\n+        while self.buffer[0] in WHITESPACE:\n+            self.buffer=self.buffer[1:]\n+    \n+    def next_until(self,target):\n+        for t in target:\n+            try:\n+                pos=self.buffer.index(t)\n+            except ValueError:\n+                pass\n+            else:\n+                found=\'\'.join(self.buffer[:pos])\n+                self.buffer=self.buffer[pos:]\n+                return found\n+        else:\n+            return None\n+\n+    def peek_word(self,word):\n+        return \'\'.join(self.buffer[:len(word)])==word\n+    \n+    def next_word(self):\n+        """Return the next NEXUS word from a string, dealing with single and double quotes,\n+        whitespace and punctuation.\n+   '..b':\n+                    set[i]=c+d\n+                # if we add gaps within a group of characters, we want the gap position included in this group\n+                if c==x:\n+                    if leftgreedy or (i>0 and set[i-1]==c-1):  \n+                        addpos=i\n+            if addpos>0:\n+                set[addpos:addpos]=range(x,x+d)\n+            return set\n+\n+        if pos<0 or pos>self.nchar:\n+            raise NexusError(\'Illegal gap position: %d\' % pos)\n+        if n==0:\n+            return\n+        sitesm=zip(*[self.matrix[t].tostring() for t in self.taxlabels])\n+        sitesm[pos:pos]=[[\'-\']*len(self.taxlabels)]*n\n+        # #self.matrix=dict([(taxon,Seq(map(\'\'.join,zip(*sitesm))[i],self.alphabet)) for\\\n+        #        i,taxon in enumerate(self.taxlabels)])\n+        zipped=zip(*sitesm)\n+        mapped=map(\'\'.join,zipped)\n+        listed=[(taxon,Seq(mapped[i],self.alphabet)) for i,taxon in enumerate(self.taxlabels)]\n+        self.matrix=dict(listed) \n+        self.nchar+=n\n+        # now adjust character sets\n+        for i,s in self.charsets.items():\n+            self.charsets[i]=_adjust(s,pos,n,leftgreedy=leftgreedy)\n+        for p in self.charpartitions:\n+            for sp,s in self.charpartitions[p].items():\n+                self.charpartitions[p][sp]=_adjust(s,pos,n,leftgreedy=leftgreedy)\n+        # now adjust character state labels\n+        self.charlabels=self._adjust_charlabels(insert=[pos]*n)\n+        return self.charlabels\n+      \n+    def _adjust_charlabels(self,exclude=None,insert=None):\n+        """Return adjusted indices of self.charlabels if characters are excluded or inserted."""\n+        if exclude and insert:\n+            raise NexusError, \'Can\\\'t exclude and insert at the same time\'\n+        if not self.charlabels:\n+            return None\n+        labels=self.charlabels.keys()\n+        labels.sort()\n+        newcharlabels={}\n+        if exclude:\n+            exclude.sort()\n+            exclude.append(sys.maxint)\n+            excount=0\n+            for c in labels:\n+                if not c in exclude:\n+                    while c>exclude[excount]:\n+                        excount+=1\n+                    newcharlabels[c-excount]=self.charlabels[c]\n+        elif insert:\n+            insert.sort()\n+            insert.append(sys.maxint)\n+            icount=0\n+            for c in labels:\n+                while c>=insert[icount]:\n+                    icount+=1\n+                newcharlabels[c+icount]=self.charlabels[c]\n+        else:\n+            return self.charlabels\n+        return newcharlabels\n+\n+    def invert(self,charlist):\n+        """Returns all character indices that are not in charlist."""\n+        return [c for c in range(self.nchar) if c not in charlist]\n+\n+    def gaponly(self,include_missing=False):\n+        """Return gap-only sites."""\n+        gap=sets.Set(self.gap)\n+        if include_missing:\n+            gap.add(self.missing)\n+        sitesm=zip(*[self.matrix[t].tostring() for t in self.taxlabels])\n+        gaponly=[i for i,site in enumerate(sitesm) if sets.Set(site).issubset(gap)]\n+        return gaponly \n+        \n+    def terminal_gap_to_missing(self,missing=None,skip_n=True):\n+        """Replaces all terminal gaps with missing character.\n+        \n+        Mixtures like ???------??------- are properly resolved."""\n+        \n+        if not missing:\n+            missing=self.missing\n+        replace=[self.missing,self.gap]\n+        if not skip_n:\n+            replace.extend([\'n\',\'N\'])\n+        for taxon in self.taxlabels:\n+            sequence=self.matrix[taxon].tostring()\n+            length=len(sequence)\n+            start,end=get_start_end(sequence,skiplist=replace)\n+            sequence=sequence[:end+1]+missing*(length-end-1)\n+            sequence=start*missing+sequence[start:]\n+            assert length==len(sequence), \'Illegal sequence manipulation in Nexus.termial_gap_to_missing in taxon %s\' % taxon\n+            self.matrix[taxon]=Seq(sequence,self.alphabet)\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/array_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/array_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,133 @@
+#!/usr/bin/env python

+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+"""Read and write a rectangular array of sequence data.
+    
+One sequence per line and nothing else. Each line must contain the same number
+of characters. Blank lines and white space are ignored.

+--- Example Array ---
+
+--------------------------LENSTSPYDYGENESD-------FSDSPPCPQDF
+--------------------------LENLEDLF-WELDRLD------NYNDTSLVENH-
+--------------------------MSNITDPQMWDFDDLN-------FTGMPPADEDY
+-----------------------------------YTSDN---------YSGSGDYDSNK
+-SL-------NFDRTFLPALYSLLFLLGLLGNGAVAAVLLSQRTALSSTDTFLLHLAVAD
+--LC-PATMASFKAVFVPVAYSLIFLLGVIGNVLVLVILERHRQTRSSTETFLFHLAVAD
+-SPC-MLETETLNKYVVIIAYALVFLLSLLGNSLVMLVILYSRVGRSVTDVYLLNLALAD
+-EPC-RDENVHFNRIFLPTIYFIIFLTGIVGNGLVILVMGYQKKLRSMTDKYRLHLSVAD
+"""
+
+from corebio.seq import *
+from corebio.utils import *
+
+example = """
+--------------------------LENSTSPYDYGENESD-------FSDSPPCPQDF
+--------------------------LENLEDLF-WELDRLD------NYNDTSLVENH-
+--------------------------MSNITDPQMWDFDDLN-------FTGMPPADEDY
+-----------------------------------YTSDN---------YSGSGDYDSNK
+-SL-------NFDRTFLPALYSLLFLLGLLGNGAVAAVLLSQRTALSSTDTFLLHLAVAD
+--LC-PATMASFKAVFVPVAYSLIFLLGVIGNVLVLVILERHRQTRSSTETFLFHLAVAD
+-SPC-MLETETLNKYVVIIAYALVFLLSLLGNSLVMLVILYSRVGRSVTDVYLLNLALAD
+-EPC-RDENVHFNRIFLPTIYFIIFLTGIVGNGLVILVMGYQKKLRSMTDKYRLHLSVAD
+"""
+
+names = ("array",'flatfile')
+extensions = ()
+
+def read(fin, alphabet=None): 
+    """Read a file of raw sequecne alignment data. 
+
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data, if given
+    Returns: 
+        SeqList -- A list of sequences
+    Raises: 
+        ValueError -- If the file is unparsable
+    """         
+    seqs = [ s for s in iterseq(fin, alphabet)]
+    return SeqList(seqs)
+
+
+def iterseq(fin, alphabet=None) :
+    """ Read one line of sequence data and yeild the sequence.
+
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data, if given    
+    Yeilds: 
+        Seq -- One alphabetic sequence at a time.
+    Raises: 
+        ValueError -- If the file is unparsable
+    """
+
+    alphabet = Alphabet(alphabet)
+    line_length = 0
+    
+    for linenum, line in enumerate(fin) :
+        if line.isspace(): continue # Blank line
+        line = line.strip() 
+
+        if line[0] == '>' : # probable a fasta file. Fail.
+            raise ValueError(
+                "Parse Error on input line: %d " % (linenum) )
+        
+        line = remove_whitespace(line)
+        
+        if not alphabet.alphabetic(line) :
+            raise ValueError(
+                "Character on line: %d not in alphabet: %s : %s" % \
+                     (linenum, alphabet, line) )
+        
+        if line_length and line_length != len(line) :
+            raise ValueError("Line %d has a incommensurate length." % linenum)
+        line_length = len(line)
+        
+        yield Seq(line, alphabet)
+
+
+def write(afile, seqs): 
+    """Write raw sequence data, one line per sequence.
+
+    arguments:
+        afile -- A writable stream.
+        seqs  -- A list of Seq's
+    """         
+    for s in seqs :
+        writeseq(afile, s)
+
+    
+def writeseq(afile, seq):
+    """ Write a single sequence in raw format.
+
+    arguments:
+        afile -- A writable stream.
+        seq  -- A Seq instance
+    """
+    print >>afile, seq
+
+            
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/clustal_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/clustal_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,222 @@

+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+""" Read and write the CLUSTAL sequence file format.

+See :
+- http://www.cmpharm.ucsf.edu/~goh/Treecorr/sampleAlignment.html
+- http://www.bioperl.org/wiki/ClustalW_multiple_alignment_format
+  
+Ref :
+-   Higgins D., Thompson J., Gibson T., Thompson J.D., Higgins D.G., Gibson 
+    T.J. (1994). CLUSTAL W: improving the sensitivity of progressive multiple
+    sequence alignment through sequence weighting, position-specific gap
+    penalties and weight matrix choice. Nucleic Acids Res. 22:4673-4680.
+"""
+
+# TODO: What happens if CLUSTAL is not the first line of the file?
+
+
+import re
+
+from corebio.utils import *
+from corebio.seq import *
+from corebio.seq_io import *
+
+__all__ = ('example', 'names', 'extensions', 'read')
+
+example = """
+CLUSTAL W (1.81) multiple sequence alignment
+
+
+CXCR3_MOUSE       --------------------------LENSTSPYDYGENESD-------FSDSPPCPQDF
+BLR_HUMAN         --------------------------LENLEDLF-WELDRLD------NYNDTSLVENH-
+CXCR1_HUMAN       --------------------------MSNITDPQMWDFDDLN-------FTGMPPADEDY
+CXCR4_MURINE      -----------------------------------YTSDN---------YSGSGDYDSNK
+                                                     :  :          :..     ..

+CXCR3_MOUSE       -SL-------NFDRTFLPALYSLLFLLGLLGNGAVAAVLLSQRTALSSTDTFLLHLAVAD
+BLR_HUMAN         --LC-PATMASFKAVFVPVAYSLIFLLGVIGNVLVLVILERHRQTRSSTETFLFHLAVAD
+CXCR1_HUMAN       -SPC-MLETETLNKYVVIIAYALVFLLSLLGNSLVMLVILYSRVGRSVTDVYLLNLALAD
+CXCR4_MURINE      -EPC-RDENVHFNRIFLPTIYFIIFLTGIVGNGLVILVMGYQKKLRSMTDKYRLHLSVAD
+                             :.  .:   * ::** .::**  *  ::   :   * *: : ::*::**
+
+CXCR3_MOUSE       VLLVLTLPLWAVDAA-VQWVFGPGLCKVAGALFNINFYAGAFLLACISFDRYLSIVHATQ
+BLR_HUMAN         LLLVFILPFAVAEGS-VGWVLGTFLCKTVIALHKVNFYCSSLLLACIAVDRYLAIVHAVH
+CXCR1_HUMAN       LLFALTLPIWAASKV-NGWIFGTFLCKVVSLLKEVNFYSGILLLACISVDRYLAIVHATR
+CXCR4_MURINE      LLFVITLPFWAVDAM-ADWYFGKFLCKAVHIIYTVNLYSSVLILAFISLDRYLAIVHATN
+                  :*:.: **: ...     * :*  ***..  :  :*:*.. ::** *:.****:****..
+"""
+
+
+
+names = ("clustal", "clustalw",)
+extensions = ('aln',)
+
+
+header_line = re.compile(r'(CLUSTAL.*)$')
+
+# (sequence_id) (Sequence) (Optional sequence number)
+seq_line   = re.compile(r'(\s*\S+\s+)(\S+)\s*(\d*)$')
+
+# Saved group includes variable length leading space.
+# Must consult a seq_line to figure out how long the leading spoace is since
+# the maximum CLUSTAL ids length (normally 10 characters) can be changed.
+match_line = re.compile(r'([\s:\.\*]*)$') 
+
+
+def iterseq(fin, alphabet=None):
+    """Iterate over the sequences in the file."""
+    # Default implementation
+    return iter(read(fin, alphabet) )
+
+
+def read(fin, alphabet=None) :  
+    alphabet = Alphabet(alphabet)      
+    seq_ids = []
+    seqs = []
+    block_count = 0
+    
+    
+    for token in _scan(fin):
+        if token.typeof== "begin_block":
+            block_count = 0
+        elif token.typeof == "seq_id":
+            if len(seqs) <= block_count :
+                seq_ids.append(token.data)
+                seqs.append([])
+        elif token.typeof == "seq":
+            if not alphabet.alphabetic(token.data) :
+                raise ValueError(
+                    "Character on line: %d not in alphabet: %s : %s" % (
+                    token.lineno, alphabet, token.data) )
+            seqs[block_count].append(token.data)
+            block_count +=1
+
+          
+    seqs = [ Seq("".join(s), alphabet, name= i) for s,i in zip(seqs,seq_ids)]
+    return SeqList(seqs)
+
+
+# 1) The word "CLUSTAL" should be the first word on the first line of the file.
+# (But sometimes isn't.)
+# 2) The alignment is displayed in blocks of fixed length.
+# 3) Each line in the block corresponds to one sequence.
+# 4) Each sequence line starts with a sequence name followed by at least one
+#     space and then the sequence.
+
+def _scan( fin ):
+    """Scan a clustal format MSA file and yeild tokens.
+        The basic file structure is
+            begin_document
+                header?     
+               (begin_block
+                   (seq_id seq seq_index?)+
+                   match_line?
+               end_block)*
+            end_document     
+    
+        Usage:
+        for token in scan(clustal_file):
+            do_somthing(token)
+    """
+    header, body, block = range(3)
+    
+    yield Token("begin")
+    leader_width = -1
+    state = header
+    for L, line in enumerate(fin):
+        if state==header :
+            if line.isspace() : continue
+            m = header_line.match(line)
+            state = body
+            if m is not None :
+                yield Token("header", m.group() )
+                continue
+            else :
+                raise ValueError("Cannot find required header")
+
+        
+        if state == body :
+            if line.isspace() : continue
+            yield Token("begin_block")
+            state = block
+            # fall through to block
+        
+        if state ==  block:
+            if line.isspace() :
+                yield Token("end_block")
+                state = body
+                continue
+            
+            m = match_line.match(line)
+            if m is not None :
+                yield Token("match_line", line[leader_width:-1])
+                continue
+     
+            m = seq_line.match(line) 
+            if m is None: 
+                raise ValueError("Parse error on line: %d" % L)
+            leader_width = len(m.group(1))
+            yield Token("seq_id", m.group(1).strip() )
+            yield Token("seq", m.group(2).strip() )
+            if m.group(3)  :
+                yield Token("seq_num", m.group(3)) 
+            continue
+
+        # END state blocks. If I ever get here something has gone terrible wrong
+        raise RuntimeError()
+    
+    if state==block:
+         yield Token("end_block")
+    yield Token("end")     
+    return
+
+def write(fout, seqs) :
+    """Write 'seqs' to 'fout' as text in clustal format"""
+    header = "CLUSTAL W (1.81) multiple sequence alignment"
+    name_width = 17
+    seq_width = 60
+    
+    print >>fout, header
+    print >>fout
+    print >>fout 
+    
+    L = 0
+    for s in seqs: L = max(L, len(s))
+    
+    for block in range(0, L, seq_width):
+        for s  in seqs :
+            start = min(block, len(s))
+            end = min( start+seq_width, len(s))
+            print  >>fout, s.name.ljust(name_width),
+            print  >>fout, s[start:end]
+        print  >>fout 
+        
+        
+        
+
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/fasta_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/fasta_io.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,230 @@\n+#!/usr/bin/env python\n+ \n+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+#\n+\n+"""Read and write sequence information in FASTA format.\n+    \n+This is a very common format for unannotated biological sequence data, \n+accepted by many multiple sequence alignment programs. Each sequence \n+consists of a single-line description, followed by lines of sequence data. \n+The first character of the description line is a greater-than (">") symbol \n+in the first column. The first word of the description is often the name or \n+ID of the sequence. Fasta files containing multiple sequences have one \n+sequence listed right after another. \n+\n+\n+Example Fasta File ::\n+\n+>Lamprey GLOBIN V - SEA LAMPREY\n+PIVDTGSVA-P------------------LSAAEKTKIRSAWAPVYSTY---ETSGVDILVKFFTSTPAAQEFFPKFKGL\n+TT-----ADQLKKSA---DVRWHA-ERIINAVNDAVASMDDTEKMS--MKL-RDLSGKH----AKSFQV-----DPQYFK\n+VLAAVI-AD-TVAAGD--AGFEKLMSM------I---CILLR----S-----A-----Y------------\n+>Hagfish GLOBIN III - ATLANTIC HAGFISH\n+PITDHGQPP-T------------------LSEGDKKAIRESWPQIYKNF---EQNSLAVLLEFLKKFPKAQDSFPKFSAK\n+KS-------HLEQDP---AVKLQA-EVIINAVNHTIGLMDKEAAMK--KYL-KDLSTKH----STEFQV-----NPDMFK\n+ELSAVF-VS-TMG-GK--AAYEKLFSI------I---ATLLR----S-----T-----YDA----------\n+>Frog HEMOGLOBIN BETA CHAIN - EDIBLE FROG\n+----------GS-----------------------DLVSGFWGKV--DA---HKIGGEALARLLVVYPWTQRYFTTFGNL\n+GSADAIC-----HNA---KVLAHG-EKVLAAIGEGLKHPENLKAHY--AKL-SEYHSNK----LHVDPANFRLLGNVFIT\n+VLARHF-QH-EFTPELQ-HALEAHFCA------V---GDALA----K-----A-----YH-----------\n+\n+\n+"""\n+import re\n+from corebio.utils import *\n+from corebio.seq import *\n+from corebio.seq_io import *\n+\n+\n+names = ( \'fasta\', \'pearson\', \'fa\')\n+extensions = (\'fa\', \'fasta\', \'fast\', \'seq\', \'fsa\', \'fst\', \'nt\', \'aa\',\'fna\',\'mpfa\', \'faa\', \'fnn\',\'mfasta\') \n+\n+\n+example = """\n+>Lamprey GLOBIN V - SEA LAMPREY\n+PIVDTGSVA-P------------------LSAAEKTKIRSAWAPVYSTY---ETSGVDILVKFFTSTPAAQEFFPKFKGL\n+TT-----ADQLKKSA---DVRWHA-ERIINAVNDAVASMDDTEKMS--MKL-RDLSGKH----AKSFQV-----DPQYFK\n+VLAAVI-AD-TVAAGD--AGFEKLMSM------I---CILLR----S-----A-----Y------------\n+\n+>Hagfish GLOBIN III - ATLANTIC HAGFISH\n+PITDHGQPP-T------------------LSEGDKKAIRESWPQIYKNF---EQNSLAVLLEFLKKFPKAQDSFPKFSAK\n+KS-------HLEQDP---AVKLQA-EVIINAVNHTIGLMDKEAAMK--KYL-KDLSTKH----STEFQV-----NPDMFK\n+ELSAVF-VS-TMG-GK--AAYEKLFSI------I---ATLLR----S-----T-----YDA----------\n+\n+>Frog HEMOGLOBIN BETA CHAIN - EDIBLE FROG\n+----------GS-----------------------DLVSGFWGKV--DA---HKIGGEALARLLVVYPWTQRYFTTFGNL\n+GSADAIC-----HNA---KVLAHG-EKVLAAIGEGLKHPENLKAHY--AKL-SEYHSNK----LHVDPANFRLLGNVFIT\n+VLARHF-QH-EFTPELQ-HALEAHFCA------V---GDALA----K-----A-----YH-----------\n+\n+"""    \n+\n+\n+def read(fin, alphabet=None): \n+    """Read and parse a fasta file. \n+\n+    Args:\n+        fin -- A stream or file to read\n+        alph'..b'quences\n+    Raises: \n+        ValueError -- If the file is unparsable\n+    """         \n+    seqs = [ s for s in iterseq(fin, alphabet)]\n+    name = names[0]\n+    if hasattr(fin, "name") : name = fin.name    \n+    return SeqList(seqs, name=name)\n+\n+\n+def readseq(fin, alphabet=None) :\n+    """Read one sequence from the file, starting \n+    from the current file position."""\n+    return iterseq(fin, alphabet).next()\n+    \n+     \n+def iterseq(fin, alphabet=None):\n+    """ Parse a fasta file and generate sequences.\n+    \n+    Args:\n+        fin -- A stream or file to read\n+        alphabet -- The expected alphabet of the data, if given    \n+    Yeilds: \n+        Seq -- One alphabetic sequence at a time.\n+    Raises: \n+        ValueError -- If the file is unparsable\n+    """\n+    alphabet = Alphabet(alphabet)\n+\n+    seqs = []\n+    comments = []   # FIXME: comments before first sequence are lost.\n+    header = None\n+    header_lineno = -1\n+    \n+    def build_seq(seqs,alphabet, header, header_lineno,comments) :\n+        try :\n+            name = header.split(\' \',1)[0]\n+            if comments :\n+                header += \'\\n\' + \'\\n\'.join(comments)\n+            s = Seq( "".join(seqs), alphabet, name=name, description=header)\n+        except ValueError:\n+             raise ValueError(\n+                "Parsed failed with sequence starting at line %d: "\n+                "Character not in alphabet: %s" % (header_lineno, alphabet) )\n+        return s\n+\n+    for lineno, line in enumerate(fin) :\n+        line = line.strip()\n+        if line == \'\' : continue\n+        if line.startswith(\'>\') :\n+            if header is not None :\n+                yield  build_seq(seqs,alphabet, header, header_lineno, comments)\n+                header = None\n+                seqs = []\n+            header = line[1:]\n+            header_lineno = lineno\n+            comments = []\n+        elif line.startswith(\';\') : \n+            # Optional (and unusual) comment line\n+            comments.append(line[1:])           \n+        else :\n+            if header is None :\n+                raise ValueError (\n+                    "Parse failed on line %d: sequence before header"  \n+                    % (lineno) )\n+            seqs.append(line)    \n+\n+    if not seqs: return\n+    yield build_seq(seqs,alphabet, header, header_lineno, comments)\n+\n+     \n+def write(fout, seqs): \n+    """Write a fasta file. \n+\n+    Args:\n+        fout -- A writable stream.\n+        seqs  -- A list of Seq\'s\n+    """ \n+    if seqs.description :\n+        for line in seqs.description.splitlines():\n+            print >>fout, \';\'+ line        \n+    for s in seqs :\n+        writeseq(fout, s)\n+\n+    \n+def writeseq(afile, seq):\n+    """ Write a single sequence in fasta format.\n+\n+    Args:\n+        afile -- A writable stream.\n+        seq  -- A Seq instance\n+    """\n+\n+    header = seq.description or seq.name or \'\'\n+    \n+    # We prepend \'>\' to the first header line\n+    # Additional lines start with \';\' to indicate comment lines\n+    if header :\n+        header = header.splitlines()  \n+        print >>afile, \'>\'+header[0]\n+        if len(header) > 1 :\n+            for h in header[1:] :\n+                print >>afile, \';\' +h\n+    else :\n+        print >>afile, \'>\'\n+    \n+    L = len(seq) \n+    line_length = 80\n+    for n in range (1+ L/line_length) :\n+        print >>afile, seq[n * line_length: (n+1) * line_length] \n+    print >>afile\n+    \n+    \n+def index(afile, alphabet=None) :\n+    """Return a FileIndex for the fasta file. Sequences can be retrieved\n+    by item number or name.\n+    """\n+    def parser( afile) :\n+        return readseq(afile, alphabet)\n+    \n+    key = re.compile(r"^>\\s*(\\S*)")\n+    def linekey( line):\n+        k = key.search(line)\n+        if k is None : return None\n+        return k.group(1)\n+        \n+    return FileIndex(afile, linekey, parser)\n+\n+                \n+        \n+        \n+        \n+        \n+        \n+         \n+\n+\n+    \n+    \n+    \n\\ No newline at end of file\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/genbank_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/genbank_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,85 @@
+#!/usr/bin/env python

+
+"""Read GenBank flat files. 
+
+Currently only reads sequence data and not annotations.
+
+"""
+from corebio.utils import *
+from corebio.seq import *
+
+  
+names = ( 'genbank',)
+extensions = ('gb','genbank', 'gbk')
+
+
+
+def read(fin, alphabet=None): 
+    """Read and parse a file of genbank records. 
+
+    Args:
+    fin -- A stream or file to read
+    alphabet -- The expected alphabet of the data, if given
+    
+    Returns: 
+    SeqList -- A list of sequences
+    
+    Raises: 
+    ValueError -- If the file is unparsable
+    """         
+    seqs = [ s for s in iterseq(fin, alphabet)]
+    return SeqList(seqs)
+
+    
+def iterseq(fin, alphabet=None):
+    """ Iterate over genbank records
+    
+    Args:
+    fin -- A stream or file to read
+    alphabet -- The expected alphabet of the data, if given    
+    
+    Yeilds: 
+    Seq -- One alphabetic sequence at a time.
+    
+    Raises: 
+    ValueError -- If the file is unparsable
+    """
+    alphabet = Alphabet(alphabet)
+
+    seq = []
+    
+    def notblank(string) :
+        return not isblank(string)
+
+    lines = Reiterate(iter(fin))
+    
+    
+    while True :
+        line = lines.filter( notblank )
+        if not line.startswith('LOCUS') :
+            raise ValueError(
+                "Cannot find start of record at line %d"% lines.index() )
+
+        line = lines.filter(lambda s : s.startswith('ORIGIN') 
+                                            or  s.startswith('//') )
+
+        if line.startswith('//') :
+            # No sequence data    
+            yield Seq( '', alphabet)
+        else:
+            for line in lines :
+                if line.startswith('//') :
+                    yield Seq( ''.join(seq), alphabet)
+                    seq = []
+                    break    
+                seq.extend( line.split()[1:] )
+       
+    
+        
+    
+
+
+     
+     
+     
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/intelligenetics_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/intelligenetics_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,203 @@
+#!/usr/bin/env python

+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+"""Read and write sequence information in IntelliGenetics format.
+    
+A sequence file in IG format can contain several sequences, each consisting of a
+number of comment lines that must begin with a semicolon (";"), a line with the 
+sequence name and the sequence itself terminated with the termination character 
+'1' for linear or '2' for circular sequences. The termination caracter is
+defacto optional.
+
+--- Example IG File ---
+
+;H.sapiens fau mRNA, 518 bases
+HSFAU
+ttcctctttctcgactccatcttcgcggtagctgggaccgccgttcagtc
+actcttaagtcttttgtaattctggctttctctaataaaaaagccactta
+gttcagtcaaaaaaaaaa1
+;H.sapiens fau 1 gene, 2016 bases
+HSFAU1
+ctaccattttccctctcgattctatatgtacactcgggacaagttctcct
+gatcgaaaacggcaaaactaaggccccaagtaggaatgccttagttttcg
+gggttaacaatgattaacactgagcctcacacccacgcgatgccctcagc
+tcctcgctcagcgctctcaccaacagccgtagcccgcagccccgctggac
+accggttctccatccccgcagcgtagcccggaacatggtagctgccatct
+ttacctgctacgccagccttctgtgcgcgcaactgtctggtcccgcccc2
+
+"""
+
+from corebio.utils import *
+from corebio.seq import *
+from corebio.seq_io import *
+
+
+names = ( 'intelligenetics', 'ig', 'stanford', )
+extensions = ('ig') 
+
+
+example = """
+;H.sapiens fau mRNA, 518 bases
+HSFAU
+ttcctctttctcgactccatcttcgcggtagctgggaccgccgttcagtc
+actcttaagtcttttgtaattctggctttctctaataaaaaagccactta
+gttcagtcaaaaaaaaaa1
+;H.sapiens fau 1 gene, 2016 bases
+HSFAU1
+ctaccattttccctctcgattctatatgtacactcgggacaagttctcct
+gatcgaaaacggcaaaactaaggccccaagtaggaatgccttagttttcg
+gggttaacaatgattaacactgagcctcacacccacgcgatgccctcagc
+tcctcgctcagcgctctcaccaacagccgtagcccgcagccccgctggac
+accggttctccatccccgcagcgtagcccggaacatggtagctgccatct
+ttacctgctacgccagccttctgtgcgcgcaactgtctggtcccgcccc2
+"""    
+
+
+
+
+def read(fin, alphabet=None): 
+    """Read and parse an IG file. 
+
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data, if given
+    Returns: 
+        SeqList -- A list of sequences
+    Raises: 
+        ValueError -- If the file is unparsable
+    """         
+    seqs = [ s for s in iterseq(fin, alphabet)]
+    return SeqList(seqs)
+
+    
+def iterseq(fin, alphabet=None):
+    """ Parse an IG file and generate sequences.
+    
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data, if given    
+    Yeilds: 
+        Seq -- One alphabetic sequence at a time.
+    Raises: 
+        ValueError -- If the file is unparsable
+    """
+    alphabet = Alphabet(alphabet)
+
+    seqs = []
+    header = []   
+    start_lineno = -1
+    name = None
+    
+    def build_seq(seqs,alphabet, name, comments, lineno) :
+        try :
+            desc = '\n'.join(comments)
+            s = Seq( "".join(seqs), alphabet, name=name, description=desc)
+        except ValueError :
+             raise ValueError(
+                "Parsed failed with sequence starting at line %d: "
+                "Character not in alphabet: %s" % (lineno, alphabet) )
+        return s
+
+    for lineno, line in enumerate(fin) :
+        line = line.strip()
+        if line == '' : continue
+        if line.startswith(';') :
+            if seqs :
+                # end of sequence
+                yield  build_seq(seqs,alphabet, name, header, start_lineno)
+                header = []
+                seqs = []
+                name = None
+            header.append(line[1:])
+            start_lineno = lineno
+        elif not name :  
+            name = line
+        elif line[-1] == '1' or line[-1]=='2': 
+            # End of sequence
+            seqs.append(remove_whitespace(line[0:-1]))
+            yield  build_seq(seqs,alphabet, name, header, start_lineno)
+            header = []
+            seqs = []       
+            name = None
+        else:
+            seqs.append( remove_whitespace(line))    
+    
+    if seqs :
+        yield build_seq(seqs,alphabet, name, header, start_lineno)
+    return
+    
+    
+    
+
+
+def write(fout, seqs): 
+    """Write an IG file. 
+
+    Args:
+        fout -- A writable stream.
+        seqs  -- A list of Seq's
+    Raises:
+        ValueError -- If a sequence is missing a name
+    """        
+    for s in seqs :
+        writeseq(fout, s)
+
+    
+def writeseq(fout, seq):
+    """ Write a single sequence in IG format.
+
+    Args:
+        afile -- A writable stream.
+        seq  -- A Seq instance
+    Raises:
+        ValueError -- If a sequence is missing a name        
+    """
+
+    desc = seq.description or ''
+    
+    # We prepend ';' to each line
+    for h in desc.splitlines()  :
+        print >> fout, ';' +h
+
+    if not seq.name :
+        raise ValueError(
+            "Write failed with missing sequence name: %s"% str(seq) )
+    print >>fout, seq.name
+    L = len(seq) 
+    line_length = 80
+    for n in range (1+ int(L/line_length)) :
+        print >>fout, seq[n * line_length: (n+1) * line_length] 
+    print >>fout
+    
+    
+    
+    
+     
+
+
+    
+    
+    
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/msf_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/msf_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,156 @@
+#!/usr/bin/env python
+
+#  Copyright (c) 2005 Clare Gollnick <cgollnick@berkeley.edu>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+
+"""Read sequence information in MSF format.
+    
+This is a file format for biological sequence data. The sequences are interweaved and each line is labeled with the sequence name. The MSF format can be identified in one, or more of the following ways: 
+1. The word PileUp on the first line (optional)
+2. the word !!AA_MULTIPLE_ALIGNMENT or !!NA_MULTIPLE_ALIGNMENT at the start of the file (optional)
+3. the word MSF on the first line of the file, and the characters ".." at the end of this line (optional)
+4. A header containing sequence information followed by a line with the characters "//"
+"""
+example= """
+
+ PileUp
+
+
+MSF: 64 Type: P Check: 767 ..
+
+ Name: Cow              Len:   100  Check: 3761  Weight:  1.00
+ Name: Carp             Len:   100  Check: 1550  Weight:  1.00
+ Name: Chicken          Len:   100  Check: 2397  Weight:  1.00
+ Name: Human            Len:   100  Check: 9021  Weight:  1.00
+ Name: Loach            Len:   100  Check:  984  Weight:  1.00
+ Name: Mouse            Len:   100  Check: 2993  Weight:  1.00
+
+
+//
+
+                                                            
+    Cow  MAYPMQLGFQ DATSPIMEEL LHFHDHTLMI VFLISSLVLY IISLMLTTKL 
+   Carp  MAHPTQLGFK DAAMPVMEEL LHFHDHALMI VLLISTLVLY IITAMVSTKL 
+Chicken  MANHSQLGFQ DASSPIMEEL VEFHDHALMV ALAICSLVLY LLTLMLMEKL 
+  Human  MAHAAQVGLQ DATSPIMEEL ITFHDHALMI IFLICFLVLY ALFLTLTTKL 
+  Loach  MAHPTQLGFQ DAASPVMEEL LHFHDHALMI VFLISALVLY VIITTVSTKL 
+  Mouse  MAYPFQLGLQ DATSPIMEEL MNFHDHTLMI VFLISSLVLY IISLMLTTKL 
+
+
+                                                       
+    Cow  THTSTMDAQE VETIWTILPA IILILIALPS LRILYMMDEI NNPSLTVKTM 
+   Carp  TNKYILDSQE IEIVWTILPA VILVLIALPS LRILYLMDEI NDPHLTIKAM 
+Chicken  S.SNTVDAQE VELIWTILPA IVLVLLALPS LQILYMMDEI DEPDLTLKAI 
+  Human  TNTNISDAQE METVWTILPA IILVLIALPS LRILYMTDEV NDPSLTIKSI 
+  Loach  TNMYILDSQE IEIVWTVLPA LILILIALPS LRILYLMDEI NDPHLTIKAM 
+  Mouse  THTSTMDAQE VETIWTILPA VILIMIALPS LRILYMMDEI NNPVLTVKTM 

+   """
+
+import re
+
+from corebio.seq import *
+from corebio.seq_io import *
+from corebio.utils import *
+
+names = ('msf', 'gcg-msf', 'gcg', 'PileUp')
+extensions = ('msf')
+
+end_header=re.compile(r'(//)(\s*)$')
+seq_line=re.compile(r'\s*(\S+)\s+([\S\s.?]+)$')
+
+def iterseq(fin, alphabet=None):
+    """Iterate over the sequences in the file."""
+    # Default implementation
+    return iter(read(fin, alphabet) )
+
+
+        
+def read(fin, alphabet=None):
+    alphabet =Alphabet(alphabet)
+    seq_ids=[]
+    seqs=[]
+    block_count=0
+
+    for token in _line_is(fin):
+        if token.typeof=="begin_block":
+                block_count=0
+            
+        elif token.typeof == "seq_id":
+            if len(seqs)<= block_count:
+                seq_ids.append(token.data)
+                seqs.append([])
+        elif token.typeof=="seq":
+            if not alphabet.alphabetic(token.data):
+                raise ValueError(
+                    "Character on line: %d not in alphabet: %s : %s" % (
+                    token.lineno, alphabet, token.data) ) 
+            seqs[block_count].append(token.data)
+            block_count +=1
+    if seq_ids==[]:
+            raise ValueError("Parse error, possible wrong format")
+    seqs = [ Seq("".join(s), alphabet, name= i) for s,i in zip(seqs,seq_ids)]
+    return SeqList(seqs)
+    
+def _line_is(fin):
+    header, body, block = range(3) 
+    yield Token("begin")
+    state=header
+    for L, line in enumerate(fin):
+        if state==header:
+            if line.isspace():continue
+            m=end_header.match(line)
+            if m is not None:
+                yield Token("end_header")
+                state=body
+                continue            
+            else: continue
+            
+        if state==body:
+            if line.isspace():continue
+            yield Token("begin_block")
+            state=block
+            #skips to a block of sequences
+            
+        if state==block:
+            if line.isspace():
+                yield Token("end_block") 
+                state=body 
+                continue
+            m=seq_line.match(line)
+            if m is None:
+                raise ValueError("Parse error on line: %d" % L)
+            if m.group(1).isdigit() and m.group(2).strip().isdigit():
+                continue
+            yield Token("seq_id",m.group(1).strip() )
+            data=m.group(2)
+            data="".join((data.split()))
+            yield Token("seq",data.strip() )
+
+            
+            
+            
+
+                
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/nbrf_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/nbrf_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,169 @@
+
+#  Copyright (c) 2006, The Regents of the University of California, through 
+#  Lawrence Berkeley National Laboratory (subject to receipt of any required
+#  approvals from the U.S. Dept. of Energy).  All rights reserved.
+
+#  This software is distributed under the new BSD Open Source License.
+#  <http://www.opensource.org/licenses/bsd-license.html>
+#
+#  Redistribution and use in source and binary forms, with or without 
+#  modification, are permitted provided that the following conditions are met: 
+#
+#  (1) Redistributions of source code must retain the above copyright notice, 
+#  this list of conditions and the following disclaimer. 
+#
+#  (2) Redistributions in binary form must reproduce the above copyright 
+#  notice, this list of conditions and the following disclaimer in the 
+#  documentation and or other materials provided with the distribution. 
+#
+#  (3) Neither the name of the University of California, Lawrence Berkeley 
+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors 
+#  may be used to endorse or promote products derived from this software 
+#  without specific prior written permission. 
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#  POSSIBILITY OF SUCH DAMAGE. 
+
+"""Sequence IO for NBRF/PIR format.
+
+The format is similar to fasta. The header line consistins of '>', a two-
+letter sequence type (P1, F1, DL, DC, RL, RC, or XX), a semicolon, and a
+sequence ID. The next line is a textual description of the sequence, 
+followed by one or more lines containing the sequence data. The end of 
+the sequence is marked by a "*" (asterisk) character.
+
+type_code -- A map between NBRF two letter type codes and Alphabets.
+
+
+see:  http://www.cmbi.kun.nl/bioinf/tools/crab_pir.html
+
+--- Example NBRF File ---
+
+>P1;CRAB_ANAPL
+ALPHA CRYSTALLIN B CHAIN (ALPHA(B)-CRYSTALLIN).
+  MDITIHNPLI RRPLFSWLAP SRIFDQIFGE HLQESELLPA SPSLSPFLMR 
+  SPIFRMPSWL ETGLSEMRLE KDKFSVNLDV KHFSPEELKV KVLGDMVEIH 
+  GKHEERQDEH GFIAREFNRK YRIPADVDPL TITSSLSLDG VLTVSAPRKQ 
+  SDVPERSIPI TREEKPAIAG AQRK*
+
+>P1;CRAB_BOVIN
+ALPHA CRYSTALLIN B CHAIN (ALPHA(B)-CRYSTALLIN).
+  MDIAIHHPWI RRPFFPFHSP SRLFDQFFGE HLLESDLFPA STSLSPFYLR 
+  PPSFLRAPSW IDTGLSEMRL EKDRFSVNLD VKHFSPEELK VKVLGDVIEV 
+  HGKHEERQDE HGFISREFHR KYRIPADVDP LAITSSLSSD GVLTVNGPRK 
+  QASGPERTIP ITREEKPAVT AAPKK*
+
+"""
+
+from corebio.utils import *
+from corebio.seq import *
+from corebio.seq_io import *
+
+names = ("nbrf", "pir",)
+extensions = ('nbrf', 'pir', 'ali')
+
+
+
+
+type_code = {
+    'P1' : protein_alphabet,   # Protein (complete)
+    'F1' : protein_alphabet,   # Protein (fragment)
+    'DL' : dna_alphabet,       # DNA (linear)
+    'DC' : dna_alphabet,       # DNA (circular)
+    'RC' : rna_alphabet,       # RNA (linear)
+    'RL' : rna_alphabet,       # RNA (circular)
+    'N3' : rna_alphabet,       # tRNA
+    'N1' : rna_alphabet,       # other functional RNA
+    'XX' : generic_alphabet
+    }
+
+def read(fin, alphabet=None):  
+    """Read and parse a NBRF seqquence file. 
+
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data. If not supplied, then
+                an appropriate alphabet will be inferred from the data.
+    Returns: 
+        SeqList -- A list of sequences
+    Raises: 
+        ValueError -- If the file is unparsable        
+    """
+    seqs = [ s for s in iterseq(fin, alphabet)]
+    return SeqList(seqs)
+
+
+        
+def iterseq(fin, alphabet=None):
+    """ Generate sequences from an NBRF file.
+    
+    arguments:
+        fin -- A stream or file to read
+        alphabet --    
+    yeilds :
+        Seq
+    raises :
+        ValueError -- On a parse error.
+    """
+        
+    body, header,sequence = range(3) # Internal states
+    
+    state = body
+    seq_id = None
+    seq_desc = None
+    seq_alpha = None
+    seqs = []
+
+    for lineno, line in enumerate(fin) :
+        if state == body :
+            if line == "" or line.isspace() :
+                continue
+            if line[0] == '>':
+                seq_type, seq_id = line[1:].split(';')
+                if alphabet :
+                    seq_alpha = alphabet
+                else :
+                    seq_alpha = type_code[seq_type]
+                state = header
+                continue
+            raise ValueError("Parse error on line: %d" % lineno)
+
+        elif state == header :
+            seq_desc = line.strip()
+            state = sequence
+            continue
+                          
+        elif state == sequence :
+            data = "".join(line.split()) # Strip out white space
+            if data[-1] =='*' :
+                # End of sequence data
+                seqs.append(data[:-1])   
+
+                seq = Seq( "".join(seqs), name = seq_id.strip(), 
+                    description = seq_desc, alphabet = seq_alpha)
+
+                yield seq
+                state= body
+                seq_id = None
+                seq_desc = None
+                seqs = []
+                continue
+            else :
+                seqs.append(data)
+                continue
+        else :       
+            # If we ever get here something has gone terrible wrong
+            assert(False)
+
+    # end for
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/nexus_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/nexus_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+# Copyright 2005 Gavin E. Crooks <gec@threeplusone.com>
+# Copyright 2005-2006 The Regents of the University of California.
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+"""Read the sequence data from a nexus file.
+
+This IO code only gives read access to the sequence data.
+
+Reference:
+'NEXUS: An extensible file format for systematic information'
+Maddison, Swofford, Maddison. 1997. Syst. Biol. 46(4):590-621
+"""
+
+from corebio.seq import Seq, SeqList, Alphabet
+from corebio.seq_io._nexus import Nexus, safename
+
+
+
+
+
+names = ( 'nexus', 'paup')
+extensions = ('nex', 'nexus', 'paup', 'nxs')
+
+def iterseq(fin, alphabet=None):
+    """Iterate over the sequences in the file."""
+    # Default implementation
+    return iter(read(fin, alphabet) )
+
+
+def read(fin, alphabet=None):          
+    """ Extract sequence data from a nexus file."""
+    n = Nexus(fin)
+    
+    seqs = []
+    for taxon in n.taxlabels:   
+        name = safename(taxon)
+        r = n.matrix[taxon]
+        if alphabet is None  :
+            s = Seq(r, name = name, alphabet=r.alphabet)
+        else :
+            s = Seq(r, name = name, alphabet=alphabet )
+        seqs.append(s)
+
+    if len(seqs) == 0 :
+        # Something went terrible wrong.
+        raise ValueError("Cannot parse file")
+        
+    return SeqList(seqs)
+
+    
+    
+    
+    
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/null_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/null_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,57 @@
+#!/usr/bin/env python

+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+"""Null sequence IO. Acts like /dev/null. Read returns empty sequences or sequence lists, writes do nothing."""
+
+
+from corebio.seq import Seq, SeqList
+
+names = ()
+extensions = ()
+
+def read(fin, alphabet=None):       
+    assert fin is not None    # Do something with arguments to quite pychecker
+    if alphabet is not None : pass
+    return SeqList([])
+
+def iterseq(fin, alphabet=None) :
+    assert fin is not None
+    if alphabet is not None : pass
+    yield Seq('')
+    return
+
+def write(fout, seqs): 
+    assert fout is not None
+    assert seqs is not None
+    return
+
+    
+def writeseq(fout, seq):
+    assert fout is not None
+    assert seq is not None
+    return
+
+            
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/phylip_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/phylip_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,167 @@
+#!/usr/bin/env python
+
+#  Copyright (c) 2005 David D. Ding <dding@berkeley.edu>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+"""Read Sequences in interleaved Phylip format (not sequential) and returns a
+list of sequences. Phylips is a very common phylogeny generating sequence type
+that has the following traits
+1) First line contains number of species and number of characters in a species'
+sequence. Options can may follow, and they can be spaced or unspaced. Options are
+simply letters such as A and W after the number of characters.
+2) Options doesn't have to contain U in order for a usertree to appear.
+3) If there are options then options appear first, then the sequences. For the
+first iteration of sequences the first ten spaces are reserved for names of
+options and species, the rest is for sequences.
+4) For the second and following iterations the names are removed, only
+sequence appears
+4) At end of file an usertree may appear. First there is a number that indicts
+the number of lines the usertree will take, and then the usertrees follow.
+
+Examples:
+  6   50   W
+W         0101001111 0101110101 01011
+dmras1    GTCGTCGTTG GACCTGGAGG CGTGG
+hschras   GTGGTGGTGG GCGCCGGCCG TGTGG
+ddrasa    GTTATTGTTG GTGGTGGTGG TGTCG
+spras     GTAGTTGTAG GAGATGGTGG TGTTG
+scras1    GTAGTTGTCG GTGGAGGTGG CGTTG
+scras2    GTCGTCGTTG GTGGTGGTGG TGTTG
+
+0101001111 0101110101 01011
+GTCGTCGTTG GACCTGGAGG CGTGG
+GTGGTGGTGG GCGCCGGCCG TGTGG
+GTTATTGTTG GTGGTGGTGG TGTCG
+GTAGTTGTAG GAGATGGTGG TGTTG
+GTAGTTGTCG GTGGAGGTGG CGTTG
+GTCGTCGTTG GTGGTGGTGG TGTTG
+
+1
+((dmras1,ddrasa),((hschras,spras),(scras1,scras2)));
+
+
+"""
+
+from corebio.seq import *
+
+names = ( 'phylip',)
+extensions = ('phy',)
+
+def iterseq(fin, alphabet=None):
+    """Iterate over the sequences in the file."""
+    # Default implementation
+    return iter(read(fin, alphabet) )
+
+
+#Read takes in a phylip file name, read it, processes it, and returns a SeqList
+def read(fin, alphabet=None):
+    
+   
+    sequence=[] #where sequences are stored
+    idents=[]
+    num_seq=0
+    num_total_seq=0 #length of sequence of 1 species
+    tracker=0 #track what sequence the line is on
+    usertree_tracker=0 #track usertree lines
+    options='' #options
+    num_options=0 #number/lens of options - U
+
+    line=fin.readline()
+    while line:
+        s_line=line.split() #for ease of use, not used in all scenarios, but easier on the eye
+
+        if s_line == []: #see nothing do nothing
+            pass
+
+        elif (s_line[0].isdigit() and len(s_line) == 1 and len(sequence)==num_seq and len(sequence[0])==num_total_seq):    #identifies usertree
+            usertree_tracker = int(s_line[0])
+            pass
+        
+        elif num_options > 0:
+            if len(sequence) < num_seq:
+                if s_line[0][0] in options:
+                    num_options -= 1
+                    pass
+                else:
+                    raise ValueError('Not an option, but it should be one')
+            else:
+                num_options -= 1
+                pass
+    
+        elif usertree_tracker > 0:                    #baskically skip usertree
+            if len(sequence[num_seq-1]) == num_total_seq:
+                usertree_tracker -=1
+                pass
+            else:
+                raise ValueError('User Tree in Wrong Place')
+    
+        #####problems parse error unexpected
+        elif s_line[0].isdigit():
+            if len(s_line) >= 2 and len(sequence) == 0: #identifies first line of file
+                num_seq = int(s_line[0])               #get number of sequences
+                num_total_seq = int(s_line[1])         #get length of sequences
+                if len(s_line) > 2:                   #takes care of the options
+                    options= (''.join(s_line[2:]))
+                    num_options=len(options) - options.count('U')
+            else:
+                raise ValueError('parse error') 
+
+
+    #when options end, this take care of the sequence
+        elif num_options == 0:
+            if (num_seq==0):
+                raise ValueError("Empty File, or possibly wrong file")
+            elif tracker < num_seq:
+                if num_seq > len(sequence):
+                    sequence.append(''.join(line[10:].split())) #removes species name
+                    idents.append(line[0:10].strip())
+                    tracker +=1
+                    
+                else:
+                    sequence[tracker] += (''.join(s_line))      
+                    tracker +=1
+                    
+                if tracker == num_seq:
+                    tracker = 0
+                    num_options = len(options)-options.count('U')
+        
+        line=fin.readline()
+   
+    if len(sequence) != len(idents) or len(sequence)!=num_seq:
+        raise ValueError("Number of different sequences wrong") 
+    
+    seqs = []
+    for i in range (0, len(idents)):
+        if len(sequence[i])==num_total_seq:
+            seqs.append(Seq(sequence[i], alphabet, idents[i]))
+        else:
+            raise ValueError("extra sequence in list")
+    
+    return SeqList(seqs)
+
+
+        
+    
+    
+   
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/plain_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/plain_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,129 @@
+#!/usr/bin/env python

+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+"""Read and write raw, unformatted sequence data. The whole file is read 
+in as a sequence.  Whitespace is removed.
+
+
+--- Example Plain/Raw/Text File ---
+
+--------------------------LENSTSPYDYGENESD-------FSDSPPCPQDF
+--------------------------LENLEDLF-WELDRLD------NYNDTSLVENH-
+--------------------------MSNITDPQMWDFDDLN-------FTGMPPADEDY
+-----------------------------------YTSDN---------YSGSGDYDSNK
+-SL-------NFDRTFLPALYSLLFLLGLLGNGAVAAVLLSQRTALSSTDTFLLHLAVAD
+--LC-PATMASFKAVFVPVAYSLIFLLGVIGNVLVLVILERHRQTRSSTETFLFHLAVAD
+-SPC-MLETETLNKYVVIIAYALVFLLSLLGNSLVMLVILYSRVGRSVTDVYLLNLALAD
+-EPC-RDENVHFNRIFLPTIYFIIFLTGIVGNGLVILVMGYQKKLRSMTDKYRLHLSVAD
+"""
+
+from corebio.seq import *
+from corebio.utils import remove_whitespace
+
+example = """
+--------------------------LENSTSPYDYGENESD-------FSDSPPCPQDF
+--------------------------LENLEDLF-WELDRLD------NYNDTSLVENH-
+--------------------------MSNITDPQMWDFDDLN-------FTGMPPADEDY
+-----------------------------------YTSDN---------YSGSGDYDSNK
+-SL-------NFDRTFLPALYSLLFLLGLLGNGAVAAVLLSQRTALSSTDTFLLHLAVAD
+--LC-PATMASFKAVFVPVAYSLIFLLGVIGNVLVLVILERHRQTRSSTETFLFHLAVAD
+-SPC-MLETETLNKYVVIIAYALVFLLSLLGNSLVMLVILYSRVGRSVTDVYLLNLALAD
+-EPC-RDENVHFNRIFLPTIYFIIFLTGIV
+"""
+
+names = ("plain","raw")
+extensions = ('txt',  )
+
+def read(fin, alphabet=None): 
+    """Read a file of raw sequecne data. 
+
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data, if given
+    Returns: 
+        SeqList -- A list of sequences
+    Raises: 
+        ValueError -- If the file is unparsable
+    """         
+    seqs = [ s for s in iterseq(fin, alphabet)]
+    return SeqList(seqs)
+
+
+def iterseq(fin, alphabet=None) :
+    """ Read the sequence data and yeild one (and only one) sequence.
+
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data, if given    
+    Yeilds: 
+        Seq -- One alphabetic sequence at a time.
+    Raises: 
+        ValueError -- If the file is unparsable
+    """
+
+    alphabet = Alphabet(alphabet)
+    lines = []    
+    for linenum, line in enumerate(fin) :
+        if line.isspace(): continue # Blank line
+        line = line.strip() 
+        
+        
+        if line[0] == '>' : # probable a fasta file. Fail.
+                raise ValueError(
+                    "Parse Error on input line: %d " % (linenum) )
+        line = remove_whitespace(line)
+        
+        if not alphabet.alphabetic(line) :
+                raise ValueError(
+                    "Character on line: %d not in alphabet: %s : %s" % \
+                     (linenum, alphabet, line) )
+        lines.append(line)
+
+    yield Seq(''.join(lines), alphabet)
+
+
+
+def write(afile, seqs): 
+    """Write raw sequence data, one line per sequence.
+
+    arguments:
+        afile -- A writable stream.
+        seqs  -- A list of Seq's
+    """         
+    for s in seqs :
+        writeseq(afile, s)
+
+    
+def writeseq(afile, seq):
+    """ Write a single sequence in raw format.
+
+    arguments:
+        afile -- A writable stream.
+        seq  -- A Seq instance
+    """
+    print >>afile, seq
+
+            
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/stockholm_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/stockholm_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,172 @@

+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+"""Read a multiple sequence alignment in STOCKHOLM format.
+
+This file format is used by PFAM and HMMER. At present, all annotation
+information is ignored.
+
+See: 
+    - http://www.cgb.ki.se/cgb/groups/sonnhammer/Stockholm.html
+    - HMMER manual
+
+"""
+
+import re
+
+from corebio.utils import *
+from corebio.seq import *
+from corebio.seq_io import *
+
+
+
+example = """
+# STOCKHOLM 1.0
+#=GF ID CBS
+#=GF AC PF00571
+#=GF DE CBS domain
+#=GF AU Bateman A
+#=GF CC CBS domains are small intracellular modules mostly found  
+#=GF CC in 2 or four copies within a protein. 
+#=GF SQ 67
+#=GS O31698/18-71 AC O31698
+#=GS O83071/192-246 AC O83071
+#=GS O83071/259-312 AC O83071
+#=GS O31698/88-139 AC O31698
+#=GS O31698/88-139 OS Bacillus subtilis
+O83071/192-246          MTCRAQLIAVPRASSLAE..AIACAQKM....RVSRVPVYERS
+#=GR O83071/192-246 SA  999887756453524252..55152525....36463774777
+O83071/259-312          MQHVSAPVFVFECTRLAY..VQHKLRAH....SRAVAIVLDEY
+#=GR O83071/259-312 SS  CCCCCHHHHHHHHHHHHH..EEEEEEEE....EEEEEEEEEEE
+O31698/18-71            MIEADKVAHVQVGNNLEH..ALLVLTKT....GYTAIPVLDPS
+#=GR O31698/18-71 SS    CCCHHHHHHHHHHHHHHH..EEEEEEEE....EEEEEEEEHHH
+O31698/88-139           EVMLTDIPRLHINDPIMK..GFGMVINN......GFVCVENDE
+#=GR O31698/88-139 SS   CCCCCCCHHHHHHHHHHH..HEEEEEEE....EEEEEEEEEEH
+#=GC SS_cons            CCCCCHHHHHHHHHHHHH..EEEEEEEE....EEEEEEEEEEH
+O31699/88-139           EVMLTDIPRLHINDPIMK..GFGMVINN......GFVCVENDE
+#=GR O31699/88-139 AS   ________________*__________________________
+#=GR_O31699/88-139_IN   ____________1______________2__________0____
+//
+"""
+
+
+
+names = ("stockholm", "pfam",)
+extensions = ('sth', 'stockholm', 'align')
+
+
+header_line = re.compile(r'#\s+STOCKHOLM\s+1.\d\s+$')
+
+def iterseq(fin, alphabet=None):
+    """Iterate over the sequences in the file."""
+    # Default implementation
+    return iter(read(fin, alphabet) )
+
+
+def read(fin, alphabet=None) :  
+    alphabet = Alphabet(alphabet)      
+    seq_ids = []
+    seqs = []
+    block_count = 0
+    
+    
+    for token in _scan(fin):
+        if token.typeof== "begin_block":
+            block_count = 0
+        elif token.typeof == "seq_id":
+            if len(seqs) <= block_count :
+                seq_ids.append(token.data)
+                seqs.append([])
+        elif token.typeof == "seq":
+            if not alphabet.alphabetic(token.data) :
+                raise ValueError (
+                    "Character on line: %d not in alphabet: %s : %s" % (
+                    token.lineno, alphabet, token.data) )
+            seqs[block_count].append(token.data)
+            block_count +=1
+
+          
+    seqs = [ Seq("".join(s), alphabet, name= i) for s,i in zip(seqs,seq_ids)]
+    return SeqList(seqs)
+
+
+def _scan( fin ):
+
+    header, body, block = range(3)
+    
+    yield Token("begin")
+    state = header
+    for L, line in enumerate(fin):
+        
+
+        if state==header :
+            if line.isspace() : continue
+            m = header_line.match(line)
+            state = body
+            if m is not None :
+                # print "header: ", m.group() 
+                yield Token("header", m.group() )
+                continue
+            else :
+                 raise ValueError("Parse error on line: %d" % L)
+        
+        
+        if state == body :
+            if line.isspace() : continue
+            yield Token("begin_block")
+            state = block
+            # fall through to block
+        
+        if state ==  block:        
+            if line.isspace() :
+                yield Token("end_block")
+                state = body
+                continue
+            if line.strip() == '//' :
+                yield Token("end_block")
+                return
+            
+            
+            if line[0] =='#' :  # Comment or annotation line 
+                continue
+   
+            name_seq = line.split(None,1) # Split into two parts at first whitespace 
+            if len(name_seq) != 2 : 
+                raise ValueError("Parse error on line: %d" % L)

+            
+            yield Token("seq_id", name_seq[0].strip() )
+            yield Token("seq", name_seq[1].strip() )
+            continue
+
+        # END state blocks. If I ever get here something has gone terrible wrong
+        raise RuntimeError()
+    
+
+
+
+
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/seq_io/table_io.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/seq_io/table_io.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,126 @@
+#!/usr/bin/env python

+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+#
+
+"""Read and write sequence information in tab delimited format.
+
+This very simple format has two columns per line. The first column is a sequence name, the second column is the sequence itself. The columns are separated by a single tab ("\\t") character.
+
+"""
+from corebio.utils import *
+from corebio.seq import *
+from corebio.seq_io import *
+
+
+names = ( 'table', 'tab')
+extensions = ('tbl')
+
+
+example = """
+EC0001 MKRISTTITTTITITTGNGAG
+EC0002 MRVLKFGGTSVANAERFLRVADILESNARQGQVATVLSAPAKITNHLVAM
+EC0003 MVKVYAPASSANMSVGFDVLGAAVTPVDGALLGDVVTVEAAETFSLNNLG
+EC0004 MKLYNLKDHNEQVSFAQAVTQGLGKNQGLFFPHDLPEFSLTEIDEMLKLD
+EC0005 MKKMQSIVLALSLVLVAPMAAQAAEITLVPSVKLQIGDRDNRGYYWDGGH
+EC0006 MLILISPAKTLDYQSPLTTTRYTLPELLDNSQQLIHEARKLTPPQISTLM
+EC0007 MPDFFSFINSVLWGSVMIYLLFGAGCWFTFRTGFVQFRYIRQFGKSLKNS
+EC0008 MTDKLTSLRQYTTVVADTGDIAAMKLYQPQDATTNPSLILNAAQIPEYRK
+EC0009 MNTLRIGLVSISDRASSGVYQDKGIPALEEWLTSALTTPFELETRLIPDE
+EC0010 MGNTKLANPAPLGLMGFGMTTILLNLHNVGYFALDGIILAMGIFYGGIAQ
+"""    
+
+
+
+
+def read(fin, alphabet=None): 
+    """Read and parse file. 
+
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data, if given
+    Returns: 
+        SeqList -- A list of sequences
+    Raises: 
+        ValueError -- If the file is unparsable
+    """         
+    seqs = [ s for s in iterseq(fin, alphabet)]
+    return SeqList(seqs)
+
+    
+def iterseq(fin, alphabet=None):
+    """ Parse a file and generate sequences.
+    
+    Args:
+        fin -- A stream or file to read
+        alphabet -- The expected alphabet of the data, if given    
+    Yeilds: 
+        Seq -- One alphabetic sequence at a time.
+    Raises: 
+        ValueError -- If the file is unparsable
+    """
+    alphabet = Alphabet(alphabet)
+
+    for lineno, line in enumerate(fin) :
+        line = line.strip()
+        if line == '' : continue
+
+        columns = line.split('\t')
+        if len(columns) !=2 :
+            raise ValueError( "Parse failed on line %d: did not find two "
+             "columns seperated by a tab."  % (lineno) )        
+        yield Seq(columns[1], alphabet=alphabet, name=columns[0])
+     
+     
+def write(fout, seqs): 
+    """Write a two column, tab delineated file. 
+
+    Args:
+        fout -- A writable stream.
+        seqs  -- A list of Seq's
+    """      
+    for s in seqs : writeseq(fout, s)
+
+    
+def writeseq(fout, seq):
+    """ Write a single sequence in fasta format.
+
+    Args:
+        afile -- A writable stream.
+        seq  -- A Seq instance
+    """
+    
+    name = seq.name or ''
+    print >>fout, name, '\t', seq
+
+    
+    
+    
+    
+     
+
+
+    
+    
+    
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/ssearch_io/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/ssearch_io/__init__.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,207 @@
+
+#  Copyright (c) 2006 John Gilman
+#
+#  This software is distributed under the MIT Open Source License.
+#  <http://www.opensource.org/licenses/mit-license.html>
+#
+#  Permission is hereby granted, free of charge, to any person obtaining a 
+#  copy of this software and associated documentation files (the "Software"),
+#  to deal in the Software without restriction, including without limitation
+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+#  and/or sell copies of the Software, and to permit persons to whom the
+#  Software is furnished to do so, subject to the following conditions:
+#
+#  The above copyright notice and this permission notice shall be included
+#  in all copies or substantial portions of the Software.
+#
+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+#  THE SOFTWARE.
+
+""" Parse the output of BLAST and similar sequence search analysis reports. 
+
+The result of a sequence database search is represented by the Report class.
+    o Each Report contains one or more results, one for each database query.
+    o Each Result contains one or more hits
+    o Each Hit may contain one or more Alignments (High scoring Sequence pairs)
+
+CoreBio is often capable of guessing the correct format:
+>>> from corebio import ssearch_io
+>>> afile = open("test_corebio/data/ssearch/ssearch_out.txt")
+>>> report = ssearch_io.read(afile)
+>>> print report
+
+Alternatively, each report type has a seperate module. Each module defines a
+read(fin) method that can parse that report format.
+
+>>> from corebio.ssearch_io import fasta
+>>> report = fasta.read( open("test_corebio/data/ssearch/ssearch_out.txt") )
+>>> print report
+
+Module          Application            Comments  
+---------------------------------------------------------------------------
+fasta           FASTA / SSEARCH     Default (-m 1) or compact (-m 9 -d 0)
+blastxml        NCBI Blast          NCBI XML format                 
+
+Status: Beta 
+"""
+# Dev. References :
+#   Inspired by Bioperls searchIO system
+#       http://www.bioperl.org/wiki/HOWTO:SearchIO
+
+__all__ = ['read', 'Report', 'Result', 
+            'Hit','Annotation', 'Alignment']
+
+
+from corebio.utils import stdrepr
+
+def read(fin) :
+    """ Read and parse an analysis report. 
+    
+    returns :
+        A database search Report.
+    raises :
+        ValueError - If the file cannot be parsed
+    """
+
+    import fasta    
+    import blastxml
+    parsers = (fasta, blastxml)
+    for p in parsers:
+        try:    
+            return p.read(fin)
+        except ValueError, e:
+            pass
+        fin.seek(0)             # FIXME. Non seakable stdin?
+            
+    raise ValueError("Cannot parse sequence file: Tried fasta and blastxml")
+      
+
+
+class Report(object) :
+    """The results of a database search. The Report contains a list of 1 or more
+    Results, one for each query. Each query result containts a list of hits. 
+    Each Hit contains a list of HSP's (High scoring segment pairs).
+    
+    The structure of the report will vary somewhat depending on the source.
+    
+  algorithm           -- e.g. 'BLASTX'
+  algorithm_version   -- e.g. '2.2.4 [Aug-26-2002]'
+     algorithm_reference   --   
+  database_name       -- e.g. 'test.fa'
+  database_letters   -- number of residues in database e.g. 1291  
+  database_entries   -- number of database entries
+
+     parameters           -- Dictionary of parameters used in search
+  
+  results              -- A list of list of Results, one per query
+  """
+    __slots__ = ['algorithm', 'algorithm_version', 'algorithm_reference','database_name', 
+                'database_letters', 'database_entries', 'parameters', 'results']
+
+    def __init__(self) :
+        for name in self.__slots__ : setattr(self, name, None)
+        self.parameters = {}
+        self.results = []
+
+    def __repr__(self):
+        return stdrepr(self)
+
+
+class Result(object) :
+    """ The result from searching a database with a single query sequence.
+    
+    query        -- Information about the query sequence
+    statistics     -- A dictionary of search statistics
+    hits         -- A list of Hits
+    """
+    __slots__ = ['query', 'statistics', 'hits']
+
+    def __init__(self) :
+        for name in self.__slots__ : setattr(self, name, None)
+        self.query = Annotation() 
+        self.statistics = {}
+        self.hits = []
+
+    def __repr__(self):
+        return stdrepr(self)        
+
+        
+class Hit(object) :
+    """ A search hit between a query sequence and a subject sequence.
+    Each hit may have one or more Alignments
+    
+    target       -- Information about the target sequence. 
+    raw_score  -- Typically the ignficance of the hit in bits, e.g. 92.0
+    significance -- Typically evalue. e.g '2e-022' 
+    alignments   -- A list of alignments between subject and target
+    """
+    __slots__ =['target', 'raw_score', 'bit_score', 'significance', 
+                'alignments']
+    def __init__(self) :
+        for name in self.__slots__ : setattr(self, name, None)
+        self.target      = Annotation()
+        self.alignments  = []
+        
+    def __repr__(self):
+        return stdrepr(self) 
+
+class Annotation(object) :
+    """ Information about a subject or query sequence.
+    
+    name      -- subject sequence name, e.g. '443893|124775'
+    description  -- e.g.  'LaForas sequence'
+    length      -- subject sequence length, e.g. 331
+    locus      -- e.g. '124775'
+    accession  -- e.g. '443893'
+    """
+    # Fixme: change into generic sequence annotation class?
+    __slots__ = ['name', 'description', 'length', 'locus', 'accession', ]
+
+    def __init__(self):
+        for name in self.__slots__ :
+            setattr(self, name, None)
+             
+    def __repr__(self):
+        return stdrepr(self) 
+
+class Alignment(object):
+    """An alignment between query and subject sequences. 
+    For BLAST, these are High scoring Segment pairs (HSPs)
+  
+    raw_score      -- Typically signficance of the hit in bits, e.g. 92.0
+    significance     -- Typically evalue. e.g '2e-022' 
+
+    similar           -- number of conserved residues #FIXME eiter frac or num
+    identical       -- number of identical residues
+    gaps              -- number of gaps    
+    length            -- length of the alignment
+    
+    query_seq       -- query string from alignment
+    target_seq       -- hit string from alignment
+    mid_seq           --
+    
+    query_start       --
+    query_frame       --
+
+    target_start      --
+    target_frame      --
+    
+    """
+    __slots__ = ['raw_score', 'bit_score', 'significance', 'similar',
+     'identical', 'gaps', 'length', 'query_seq', 'target_seq', 'mid_seq',
+      'query_start', 'query_frame', 'target_start', 
+      'target_frame']
+      
+    def __init__(self):
+        for name in self.__slots__ :
+            setattr(self, name, None)
+    
+    def __repr__(self):
+        return stdrepr(self)
+        
+                
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/ssearch_io/blastxml.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/ssearch_io/blastxml.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,249 @@\n+\n+#  Copyright (c) 2006 John Gilman\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+\n+\n+"""Read BLAST XML output.\n+\n+The DTD is available at\n+http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.mod.dtd\n+\n+"""\n+\n+# See also\n+# \n+# http://bugzilla.open-bio.org/show_bug.cgi?id=1933\n+#http://portal.open-bio.org/pipermail/biojava-dev/2004-December/002513.html\n+\n+\n+from corebio.ssearch_io import Report, Result, Hit, Annotation, Alignment\n+\n+import xml.sax\n+from xml.sax.handler import ContentHandler\n+\n+__all__ = \'read\'\n+\n+def read(fin):\n+    """Read BLAST xml output and return a list of Result objects.\n+    """\n+    parser = xml.sax.make_parser()\n+    handler = _BlastHandler() \n+    parser.setContentHandler(handler)\n+        \n+    #To avoid ValueError: unknown url type: NCBI_BlastOutput.dtd\n+    parser.setFeature(xml.sax.handler.feature_validation, 0)\n+    parser.setFeature(xml.sax.handler.feature_namespaces, 0)\n+    parser.setFeature(xml.sax.handler.feature_external_pes, 0)\n+    parser.setFeature(xml.sax.handler.feature_external_ges, 0)\n+\n+    try :\n+        parser.parse(fin)\n+    except xml.sax.SAXParseException, e :\n+        raise ValueError( "Cannot parse file; "+str(e))\n+    return handler.report\n+\n+class _BlastHandler( ContentHandler) :\n+    def __init__(self):\n+        """\n+        """\n+        ContentHandler.__init__(self)\n+        self._content = []\n+        self.report = None\n+        self._result = None\n+        self._hit = None\n+        self._hsp = None\n+\n+        \n+    def characters(self, ch):\n+        self._content.append(ch) \n+   \n+    def startDocument(self):\n+        self.report = Report()\n+        \n+    def endDocument(self) :\n+        pass\n+        \n+    def startElement(self, name, attr):\n+        if name == \'BlastOutput\' :\n+            pass\n+        elif name == \'Iteration\' :\n+            result = Result()\n+            self._result = result\n+            self.report.results.append(result)\n+        elif name == \'Parameters\' :\n+            pass\n+        elif name == \'Statistics\' :\n+            pass\n+        elif name == \'Hit\' :\n+            self._hit = Hit()\n+            self._result.hits.append(self._hit)\n+        elif name == \'Hsp\' :\n+            self._hsp = Alignment()\n+            self._hit.alignments.append(self._hsp)\n+        else :\n+            pass\n+\n+\n+    def endElement(self, name):\n+        content = \'\'.join(self._content).strip()\n+        self._content = []\n+\n+        report = self.report\n+        result = self._result\n+        hsp = self._hsp\n+        hit = self._hit\n+        \n+        if name == \'BlastOutput\' : \n+            pass\n+        elif name == \'BlastOutput_program\' :\n+            report.algorithm = content\n+        elif name == \'BlastOutput_version\' :\n+            report.algorithm_version = content.split()[1]\n+        elif'..b"ers_sc-mismatch' :\n+            report.parameters['sc-mismatch'] = content              \n+        elif name == 'Parameters_gap-open' :\n+            report.parameters['gap-open'] = content              \n+        elif name == 'Parameters_gap-extend' :\n+            report.parameters['gap-extend'] = content              \n+        elif name == 'Parameters_filter' :\n+            report.parameters['filter'] = content              \n+        elif name == 'Parameters_pattern' :\n+            report.parameters['pattern'] = content              \n+        elif name == 'Parameters_entrez-query' :\n+            report.parameters['entrez-query'] = content  \n+\n+        elif name == 'Statistics' :\n+            pass              \n+        elif name == 'Statistics_db-num' :\n+            result.statistics['db-num'] = int(content)            \n+        elif name == 'Statistics_db-len' :\n+            result.statistics['db-len'] = int(content)              \n+        elif name == 'Statistics_hsp-len' :\n+            result.statistics['hsp-len'] = int(content)            \n+        elif name == 'Statistics_eff-space' :\n+            result.statistics['eff-space'] = float(content)            \n+        elif name == 'Statistics_kappa' :\n+            result.statistics['kappa'] = float(content)            \n+        elif name == 'Statistics_lambda' :\n+            result.statistics['lambda'] = float(content)          \n+        elif name == 'Statistics_entropy' :\n+            result.statistics['entropy'] = float(content)            \n+\n+        elif name == 'Hit' :\n+            self._hit = None\n+        elif name == 'Hit_num' :\n+            pass            \n+        elif name == 'Hit_id' :\n+            hit.target.name = content            \n+        elif name == 'Hit_def' :\n+            hit.target.description = content\n+        elif name == 'Hit_accession' :\n+            hit.target.accession = content            \n+        elif name == 'Hit_len' :\n+            hit.target.length = int(content)             \n+        elif name == 'Hit_hsps' :\n+            pass            \n+\n+        elif name == 'Hsp' :\n+            self._hsp = None                \n+        elif name == 'Hsp_num' :\n+            pass            \n+        elif name == 'Hsp_bit-score' :\n+            hsp.bit_score = float(content)            \n+        elif name == 'Hsp_score' :\n+            hsp.raw_score = float(content)             \n+        elif name == 'Hsp_evalue' :\n+            hsp.significance = float(content)             \n+        elif name == 'Hsp_query-from' :\n+            hsp.query_start = int(content) -1           \n+        elif name == 'Hsp_query-to' :\n+            #hsp.query_end= int(content)              \n+            pass\n+        elif name == 'Hsp_hit-from' :\n+            hsp.target_start = int(content) -1              \n+        elif name == 'Hsp_hit-to' :\n+            #hsp.target_end = int(content)             \n+            pass\n+        elif name == 'Hsp_pattern-from' :\n+            pass            \n+        elif name == 'Hsp_pattern-to' :\n+            pass            \n+        elif name == 'Hsp_query-frame' :\n+            hsp.query_frame = int(content)              \n+        elif name == 'Hsp_hit-frame' :\n+            hsp.target_frame = int(content)            \n+        elif name == 'Hsp_identity' :\n+            hsp.identical = int(content)            \n+        elif name == 'Hsp_positive' :\n+            hsp.similar = int(content)             \n+        elif name == 'Hsp_gaps' :\n+            hsp.gaps = int(content)            \n+        elif name == 'Hsp_align-len' :\n+            hsp.length = int(content)             \n+        elif name == 'Hsp_density' :\n+            pass            \n+        elif name == 'Hsp_qseq' :\n+            hsp.query_seq = content               \n+        elif name == 'Hsp_hseq' :\n+            hsp.target_seq = content            \n+        elif name == 'Hsp_midline' :\n+            hsp.mid_seq = content     \n+        else :\n+            pass       \n+                \n+\n+\n"
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/ssearch_io/fasta.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/ssearch_io/fasta.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,349 @@\n+#  Copyright (c) 2006 John Gilman\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+\n+\n+\n+\n+"""Read the output of a fasta sequence similarity search. \n+\n+FASTA is a DNA and Protein sequence alignment software package first described\n+by David J. Lipman and William R. Pearson in 1985. In addition to rapid \n+heuristic search methods, the FASTA package provides SSEARCH, an implementation\n+of the optimal Smith Waterman algorithm.\n+\n+The module can parse the output from fasta, ssearch and other search programs\n+in the fasta collection. It will parse both default (\'-m 1\') and compact \n+(\'-m 9 -d 0\') output. \n+    \n+Refs:\n+    ftp.virginia.edu/pub/fasta\n+    http://en.wikipedia.org/wiki/FASTA\n+"""\n+\n+\n+\n+from corebio.utils import Reiterate, Token, isblank\n+from corebio.ssearch_io import Report, Result, Hit, Annotation, Alignment\n+from math import floor\n+import re\n+\n+__all__ = \'read\'\n+\n+_rangere = re.compile(r"\\((\\d+)-\\d+:(\\d+)-\\d+\\)")\n+\n+\n+def read(fin) :\n+    """Read and parse a fasta search output file.\n+    \n+    returns: a list of Results\n+    """    \n+    scanner = _scan(fin) \n+\n+    report = None\n+    result = None\n+    hit = None\n+    #query_seq = None\n+    #target_seq = None\n+    alignment_num = 0\n+    \n+    \n+    for token in scanner :\n+        #print token\n+        typeof = token.typeof\n+        value = token.data\n+        \n+        if typeof == \'begin_report\' :\n+            report = Report()\n+        elif   typeof == \'algorithm\' : \n+            report.algorithm = value\n+        elif typeof == \'algorithm_version\' : \n+            report.algorithm_version = value\n+        elif typeof == \'algorithm_reference\' : \n+            report.algorithm_reference = value\n+        elif typeof == \'database_name\' : \n+            report.database_name = value\n+        elif typeof == \'database_letters\' : \n+            report.database_letters = value\n+        elif typeof == \'database_entries\' : \n+            report.database_entries = value\n+        elif typeof == \'end_report\' :\n+            # Final sanity checking\n+            break\n+        elif typeof == \'parameter\' : \n+            key = value[0]\n+            value = value[1]\n+            report.parameters[key] = value           \n+        \n+        elif typeof == \'begin_result\' :\n+            result = Result()\n+            report.results.append(result)            \n+            \n+        elif typeof == \'query_name\' :\n+            result.query.name = value\n+        elif typeof == \'query_description\' :\n+            result.query.description = value\n+        elif typeof == \'end_result\' :\n+            pass\n+            \n+        elif typeof == \'begin_hit\' :\n+            hit = Hit()\n+        elif typeof == \'target_name\' :\n+            hit.target.name = value\n+        elif typeof == \'target_description\' :\n+            hit.target.'..b'egin_alignment", lineno=lines.index() )\n+\n+                #          1         2         3         4\n+                #01234567890123456789012345678901234567890123456789\n+                # s-w opt:  46  Z-score: 70.7  bits: 18.5 E():  3.6\n+                L = lines.next()\n+                fields = L.split()\n+                raw, bit, sig = fields[2], fields[6], fields[8]\n+                yield Token("alignment_raw_score",    float(raw), lineno)\n+                yield Token("alignment_bit_score",    float(bit), lineno)\n+                yield Token("alignment_significance", float(sig), lineno)\n+\n+                #Smith-Waterman score: 46;  38.095% identity (71.429% similar) in 21 aa overlap (2-22:36-56)\n+                L = lines.next()\n+                lineno = lines.index()\n+                fields = L.split()\n+                assert( len(fields) ==12)\n+                alen = int(fields[8])\n+                identical = int( floor(0.5+alen* float(fields[3][:-1])/100.))\n+                similar = int( floor(0.5+alen* float(fields[3][:-1])/100.))\n+                yield Token("alignment_length", alen, lineno)\n+                yield Token("alignment_similar", similar, lineno)\n+                yield Token("alignment_identical", identical, lineno)                \n+                \n+                m = _rangere.match( fields[11])\n+                assert (m is not None)\n+                yield Token("alignment_query_start", int(m.group(1))-1, lineno)\n+                yield Token("alignment_target_start", int(m.group(2))-1, lineno) \n+                \n+                \n+                count = 1                \n+                while True:\n+                    L = lines.next()\n+                    count += 1\n+\n+\n+                    \n+                    if L.startswith(\'>>\'): break\n+                    if \'>>>\' in L:\n+                        lines.push(L)\n+                        break\n+                    if \'residues\' in L and \'sequences\' in L :\n+                        lines.push(L)\n+                        break\n+                    if not L or L[0].isspace() : continue\n+  \n+  \n+                    # there are 2 lines before the first query sequence (but\n+                    # we started the count at 1). There is 1 line between query\n+                    # and target, 3 lines between target and query, unless the\n+                    # query ends before the ends and the target wraps onto another\n+                    # Then there are two lines between target and target.\n+                    \n+# Smith-Waterman score: 34;  35.294% identity ...\n+# \n+#           30        40        50        60         70              \n+# d1pfsa EGFLHLEDKPHPLQCQFFVESVIPAGSYQVPYRINVNNG-RPELAFDFKAMKRA      \n+#                                      : . . .:: .:  .::             \n+# d8rxna                 MKKYVCTVCGYEYDPAEGDPDNGVKPGTSFDDLPADWVCPVCGA\n+#                                10        20        30        40    \n+# \n+# d8rxna PKSEFEAA\n+#            50                      \n+                                        \n+                    lineno=lines.index()\n+                    if count==4 :\n+                        yield Token("query_seq", L[7:].rstrip(),  lineno)\n+                    else : \n+                        yield Token("target_seq", L[7:].rstrip(),lineno)\n+                    count = 0\n+                    \n+                yield Token("end_alignment", lineno=lines.index() )\n+            yield Token("end_result", lineno= lines.index())\n+            L = next_nonempty(lines)\n+        # End results\n+        \n+        # "13355 residues in 93 query   sequences"\n+        # "13355 residues in 93 library sequences"\n+        #print \'>>\', L\n+        LL = L.split()\n+        yield Token("database_letters",int(LL[0]), lines.index() )\n+        yield Token("database_entries", int(LL[3]), lines.index() )\n+    \n+        yield Token("end_report", lineno= lines.index())\n+    except StopIteration :\n+        raise ValueError("Premature end of file ")\n+\n+\n+    \n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/transform.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/transform.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,605 @@\n+#  Copyright (c) 2006 John Gilman\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+\n+""" Transformations of Seqs (alphabetic sequences).\n+\n+\n+\n+Classes :\n+- Transform   -- Simple transforms of alphabetic strings.\n+- GeneticCode -- The genetic mapping of dna to protein.\n+\n+Functions :\n+-  mask_low_complexity -- Implementation of Seg algorithm to remove low complexity  \n+        regions from protein sequences.\n+   \n+    \n+"""\n+\n+\n+from corebio.data import dna_extended_letters, dna_ambiguity\n+from corebio.seq import Seq, protein_alphabet, nucleic_alphabet, dna_alphabet\n+from string import maketrans\n+from corebio.moremath import log2 , entropy\n+\n+__all__ = [\n+    \'Transform\',\n+    \'mask_low_complexity\',\n+    \'GeneticCode\'\n+    ]\n+\n+class Transform(object) :\n+    """A translation between alphabetic strings.\n+    (This class is not called \'Translation\' to avoid confusion with the\n+    biological translation of rna to protein.)\n+    \n+    Example:\n+    trans = Transform( \n+        Seq("ACGTRYSWKMBDHVN-acgtUuryswkmbdhvnXx?.~\'", dna_alphabet),                    \n+        Seq("ACGTRYSWKMNNNNN-acgtUuryswkmbnnnnXx?.~", reduced_nucleic_alphabet)         \n+        )\n+    s0 = Seq("AAAAAV", nucleic_alphabet)\n+    s1 = trans(s0)              \n+    assert(s1.alphabet == reduced_nucleic_alphabet)\n+    assert(s2 == Seq("AAAAAN",  reduced_nucleic_alphabet)\n+        \n+    Status : Beta \n+    """\n+    \n+    __slots__ = ["table", "source", "target"]\n+    def __init__(self, source, target) :\n+\n+        self.table = maketrans(source, target)\n+        self.source = source\n+        self.target = target\n+     \n+     \n+    def __call__(self, seq) :\n+        """Translate sequence."""\n+        if not self.source.alphabet.alphabetic(seq) :\n+            raise ValueError("Incompatable alphabets")\n+        s = str.translate(seq, self.table)\n+        cls = self.target.__class__\n+        return cls(s, self.target.alphabet, seq.name, seq.description)\n+# End class Translation\n+\n+# FIXME: Test, document, add to seq.\n+dna_complement = Transform(\n+        Seq("ACGTRYSWKMBDHVN-acgtUuryswkmbdhvnXx?.~", dna_alphabet),  \n+        Seq("TGCAYRSWMKVHDBN-tgcaAayrswmkvhdbnXx?.~", dna_alphabet),  \n+    )\n+\n+     \n+\n+def mask_low_complexity(seq, width =12, trigger=1.8, extension=2.0, mask=\'X\') :\n+    """ Mask low complexity regions in protein sequences.\n+    \n+    Uses the method of Seg [1] by Wootton & Federhen [2] to divide a sequence   \n+    into regions of high and low complexity. The sequence is divided into\n+    overlapping windows. Low complexity windows either have a sequence entropy\n+    less that the trigger complexity, or have an entropy less than the extension    \n+    complexity and neighbor other low-complexity windows. The sequence within   \n+    low complexity regions are replaced with the'..b'TTNNKKSSRRVVVVAAAADDEEGGGG",\n+        "---M---------------M------------MMMM---------------M------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG"),\n+\n+    GeneticCode(12, "Alternative Yeast Nuclear",\n+        "FFLLSSSSYY**CC*WLLLSPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",\n+        "-------------------M---------------M----------------------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG"),\n+                                                                   \n+    GeneticCode(13,"Ascidian Mitochondrial", \n+        "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNKKSSGGVVVVAAAADDEEGGGG",\n+        "-----------------------------------M----------------------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG"),\n+\n+    GeneticCode(14, "Alternative Flatworm Mitochondrial",\n+        "FFLLSSSSYYY*CCWWLLLLPPPPHHQQRRRRIIIMTTTTNNNKSSSSVVVVAAAADDEEGGGG",\n+        "-----------------------------------M----------------------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG"),\n+\n+    GeneticCode(15, "Blepharisma Nuclear",\n+        "FFLLSSSSYY*QCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",\n+        "-----------------------------------M----------------------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG"),\n+\n+    GeneticCode(16, "Chlorophycean Mitochondrial",\n+        "FFLLSSSSYY*LCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",\n+        "-----------------------------------M----------------------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG"),\n+\n+    GeneticCode(21, "Trematode Mitochondrial",\n+        "FFLLSSSSYY**CCWWLLLLPPPPHHQQRRRRIIMMTTTTNNNKSSSSVVVVAAAADDEEGGGG",\n+        "-----------------------------------M---------------M------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG"),\n+\n+    GeneticCode(22, "Scenedesmus obliquus Mitochondrial",\n+        "FFLLSS*SYY*LCC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",\n+        "-----------------------------------M----------------------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG"),\n+\n+    GeneticCode(23,"Thraustochytrium Mitochondrial",\n+        "FF*LSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",\n+        "--------------------------------M--M---------------M------------",\n+        "TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG",\n+        "TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG",\n+        "TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG",),\n+    )\n+    \n+          \n+        \n+           \n\\ No newline at end of file\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/utils/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/utils/__init__.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,470 @@\n+\n+ \n+#  Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+#\n+\n+\n+"""Extra utilities and core classes not in standard python.\n+"""\n+\n+\n+__all__ = (\'isblank\', \'isfloat\', \'isint\', \'fcmp\', \'remove_whitespace\', \n+            \'invert_dict\',\'update\', \'stdrepr\', \'Token\', \'Struct\', \'Reiterate\',\n+             \'deoptparse\', \'crc32\', \'crc64\', \'FileIndex\', \'find_command\',\n+             \'ArgumentError\', \'frozendict\')\n+\n+import os.path\n+import math\n+\n+def isblank( string) :\n+    """Is this whitespace or an empty string?"""\n+    if string == \'\' : return True\n+    return string.isspace()\n+\n+def isfloat(s):\n+    """Does this object represent a floating point number? """\n+    try: \n+        float(s)\n+        return True\n+    except (ValueError, TypeError): \n+        return False\n+\n+def isint(s):\n+    """Does this object represent an integer?"""\n+    try: \n+        int(s)\n+        return True\n+    except (ValueError, TypeError): \n+        return False\n+        \n+def fcmp(x, y, precision):\n+    """Floating point comparison."""\n+    # TODO: Doc string, default precision. Test\n+    if math.fabs(x-y) < precision:\n+        return 0\n+    elif x < y:\n+        return -1\n+    return 1\n+\n+def remove_whitespace( astring) :\n+    """Remove all whitespace from a string."""\n+    # TODO: Is this horrible slow?   \n+    return "".join(astring.split())\n+\n+\n+def invert_dict( dictionary) :\n+    """Constructs a new dictionary with inverted mappings so that keys become \n+    values and vice versa. If the values of the original dictionary are not\n+    unique then only one of the original kesys will be included in the new\n+    dictionary.\n+    """\n+    return dict( [(value, key) for key, value in dictionary.iteritems()] )\n+\n+\n+\n+def update(obj, **entries):\n+    """Update an instance with new values. \n+\n+    >>> update({\'a\': 1}, a=10, b=20)\n+    {\'a\': 10, \'b\': 20}\n+    """\n+    if hasattr(obj, \'update\') :\n+        obj.update( entries) \n+    else :\n+        for k, v in entries.iteritems() :\n+            setattr(obj, k, v)\n+    return obj\n+\n+\n+\n+def stdrepr( obj,  attributes=None, name=None) :\n+    """Create a standard representation of an object."""\n+    if name==None : name = obj.__class__.__name__\n+    if attributes==None: attributes = obj.__class__.__slots__\n+    args = []\n+    for a in attributes :\n+        args.append( \'%s=%s\' % ( a, repr( getattr(obj, a) ) ) )\n+    args = \',\\n\'.join(args).replace(\'\\n\', \'\\n    \')\n+    return \'%s(\\n    %s\\n)\' % (name, args)\n+   \n+\n+class Token(object):\n+    """Represents the items returned by a file scanner, normally processed\n+    by a parser.\n+    \n+    Attributes :\n+    o typeof    -- a string describing the kind of token\n+    o data      -- the value of the token\n+    o lineno    -- the line of the file '..b'em."""\n+        self.indexedfile.seek(self.tell(item))\n+    \n+    def __iter__(self) :\n+        for i in range(0, len(self)) :\n+            yield self[i]\n+                \n+    def __len__(self) :\n+        return len(self._positions)\n+         \n+    def __getitem__(self, item) :\n+        self.indexedfile.seek(self.tell(item))\n+        return self._parser(self.indexedfile)\n+    \n+    def __contains__(self, item) :\n+        try:\n+            self.tell(item) \n+            return True\n+        except KeyError :\n+            return False\n+        except IndexError :\n+            return False            \n+            \n+# End class FileIndex   \n+    \n+\n+def find_command(command, path=None):\n+    """Return the full path to the first match of the given command on\n+    the path.\n+    \n+    Arguments:\n+    - command -- is a the name of the executable to search for.\n+    - path -- is an optional alternate path list to search. The default it\n+        to use the COREBIOPATH environment variable, if it exists, else the \n+        PATH environment variable.\n+        \n+    Raises:\n+    - EnvironmentError -- If no match is found for the command.\n+    \n+    By default the COREBIO or PATH environment variable is searched (as well\n+    as, on Windows, the AppPaths key in the registry), but a specific \'path\'\n+    list to search may be specified as well.  \n+        \n+    Author: Adapted from code by Trent Mick (TrentM@ActiveState.com)\n+    See: http://trentm.com/projects/which/\n+    """\n+    import _which\n+    if path is None :\n+        path = os.environ.get("COREBIOPATH", "").split(os.pathsep)\n+        if path==[\'\']: path = None   \n+\n+    try :\n+        match =_which.whichgen(command, path).next()\n+    except StopIteration, _which.WhichError:\n+        raise EnvironmentError("Could not find \'%s\' on the path." % command)\n+    return match\n+\n+\n+\n+class ArgumentError(ValueError) :\n+    """ A subclass of ValueError raised when a function receives an argument\n+    that has the right type but an inappropriate value, and the situation is not\n+    described by a more precise exception such as IndexError. The name of the   \n+    argument or component at fault and (optionally) the value are also stored.\n+    """\n+    \n+    def __init__(self, message, key, value=None) :\n+        """ Args:\n+        - message -- An error message.\n+        - key -- The name of the argument or component at fault.\n+        - value -- Optional value of the argument.\n+        """ \n+        ValueError.__init__(self, message)\n+        self.key = key\n+        self.value = value\n+# end class ArgumentError\n+\n+\n+class frozendict(dict):\n+    """A frozendict is a dictionary that cannot be modified after being created\n+     -  but it is hashable and may serve as a member of a set or a key in a\n+    dictionary.\n+    # Author: Adapted from code by Oren Tirosh\n+    """\n+    # See: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/414283\n+    \n+    def _blocked_attribute(obj):\n+        raise AttributeError, "A frozendict cannot be modified."\n+    _blocked_attribute = property(_blocked_attribute)\n+\n+    __delitem__ =   _blocked_attribute\n+    __setitem__ =   _blocked_attribute\n+    clear =         _blocked_attribute\n+    pop =           _blocked_attribute\n+    popitem =       _blocked_attribute\n+    setdefault =    _blocked_attribute\n+    update =        _blocked_attribute\n+    \n+    def __new__(cls, *args, **kw):\n+        new = dict.__new__(cls)\n+        dict.__init__(new, *args, **kw)\n+        return new\n+\n+    def __init__(self, *args, **kw):\n+        pass\n+    \n+    def __hash__(self):\n+        try:\n+            return self._cached_hash\n+        except AttributeError:\n+            # Hash keys, not items, since items can be mutable and unhasahble.\n+            h = self._cached_hash = hash(tuple(sorted(self.keys())))\n+            return h\n+\n+    def __repr__(self):\n+        return "frozendict(%s)" % dict.__repr__(self)    \n+# end class frozendict   \n+          \n\\ No newline at end of file\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/utils/_which.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/utils/_which.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,335 @@\n+#!/usr/bin/env python\n+# Copyright (c) 2002-2005 ActiveState Corp.\n+# See LICENSE.txt for license details.\n+# Author:\n+#   Trent Mick (TrentM@ActiveState.com)\n+# Home:\n+#   http://trentm.com/projects/which/\n+\n+r"""Find the full path to commands.\n+\n+which(command, path=None, verbose=0, exts=None)\n+    Return the full path to the first match of the given command on the\n+    path.\n+\n+whichall(command, path=None, verbose=0, exts=None)\n+    Return a list of full paths to all matches of the given command on\n+    the path.\n+\n+whichgen(command, path=None, verbose=0, exts=None)\n+    Return a generator which will yield full paths to all matches of the\n+    given command on the path.\n+    \n+By default the PATH environment variable is searched (as well as, on\n+Windows, the AppPaths key in the registry), but a specific \'path\' list\n+to search may be specified as well.  On Windows, the PATHEXT environment\n+variable is applied as appropriate.\n+\n+If "verbose" is true then a tuple of the form\n+    (<fullpath>, <matched-where-description>)\n+is returned for each match. The latter element is a textual description\n+of where the match was found. For example:\n+    from PATH element 0\n+    from HKLM\\SOFTWARE\\...\\perl.exe\n+"""\n+\n+_cmdlnUsage = """\n+    Show the full path of commands.\n+\n+    Usage:\n+        which [<options>...] [<command-name>...]\n+\n+    Options:\n+        -h, --help      Print this help and exit.\n+        -V, --version   Print the version info and exit.\n+\n+        -a, --all       Print *all* matching paths.\n+        -v, --verbose   Print out how matches were located and\n+                        show near misses on stderr.\n+        -q, --quiet     Just print out matches. I.e., do not print out\n+                        near misses.\n+\n+        -p <altpath>, --path=<altpath>\n+                        An alternative path (list of directories) may\n+                        be specified for searching.\n+        -e <exts>, --exts=<exts>\n+                        Specify a list of extensions to consider instead\n+                        of the usual list (\';\'-separate list, Windows\n+                        only).\n+\n+    Show the full path to the program that would be run for each given\n+    command name, if any. Which, like GNU\'s which, returns the number of\n+    failed arguments, or -1 when no <command-name> was given.\n+\n+    Near misses include duplicates, non-regular files and (on Un*x)\n+    files without executable access.\n+"""\n+\n+__revision__ = "$Id: which.py 430 2005-08-20 03:11:58Z trentm $"\n+__version_info__ = (1, 1, 0)\n+__version__ = \'.\'.join(map(str, __version_info__))\n+\n+import os\n+import sys\n+import getopt\n+import stat\n+\n+\n+#---- exceptions\n+\n+class WhichError(Exception):\n+    pass\n+\n+\n+\n+#---- internal support stuff\n+\n+def _getRegisteredExecutable(exeName):\n+    """Windows allow application paths to be registered in the registry."""\n+    registered = None\n+    if sys.platform.startswith(\'win\'):\n+        if os.path.splitext(exeName)[1].lower() != \'.exe\':\n+            exeName += \'.exe\'\n+        import _winreg\n+        try:\n+            key = "SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\" +\\\n+                  exeName\n+            value = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, key)\n+            registered = (value, "from HKLM\\\\"+key)\n+        except _winreg.error:\n+            pass\n+        if registered and not os.path.exists(registered[0]):\n+            registered = None\n+    return registered\n+\n+def _samefile(fname1, fname2):\n+    if sys.platform.startswith(\'win\'):\n+        return ( os.path.normpath(os.path.normcase(fname1)) ==\\\n+            os.path.normpath(os.path.normcase(fname2)) )\n+    else:\n+        return os.path.samefile(fname1, fname2)\n+\n+def _cull(potential, matches, verbose=0):\n+    """Cull inappropriate matches. Possible reasons:\n+        - a duplicate of a previous match\n+        - not a disk file\n+        - not executable (non-Windows)\n+    If \'potential\' is approved it is returned a'..b'    if verbose:\n+                    yield match\n+                else:\n+                    yield match[0]\n+\n+\n+def which(command, path=None, verbose=0, exts=None):\n+    """Return the full path to the first match of the given command on\n+    the path.\n+    \n+    "command" is a the name of the executable to search for.\n+    "path" is an optional alternate path list to search. The default it\n+        to use the PATH environment variable.\n+    "verbose", if true, will cause a 2-tuple to be returned. The second\n+        element is a textual description of where the match was found.\n+    "exts" optionally allows one to specify a list of extensions to use\n+        instead of the standard list for this system. This can\n+        effectively be used as an optimization to, for example, avoid\n+        stat\'s of "foo.vbs" when searching for "foo" and you know it is\n+        not a VisualBasic script but ".vbs" is on PATHEXT. This option\n+        is only supported on Windows.\n+\n+    If no match is found for the command, a WhichError is raised.\n+    """\n+    try:\n+        match = whichgen(command, path, verbose, exts).next()\n+    except StopIteration:\n+        raise WhichError("Could not find \'%s\' on the path." % command)\n+    return match\n+\n+\n+def whichall(command, path=None, verbose=0, exts=None):\n+    """Return a list of full paths to all matches of the given command\n+    on the path.  \n+\n+    "command" is a the name of the executable to search for.\n+    "path" is an optional alternate path list to search. The default it\n+        to use the PATH environment variable.\n+    "verbose", if true, will cause a 2-tuple to be returned for each\n+        match. The second element is a textual description of where the\n+        match was found.\n+    "exts" optionally allows one to specify a list of extensions to use\n+        instead of the standard list for this system. This can\n+        effectively be used as an optimization to, for example, avoid\n+        stat\'s of "foo.vbs" when searching for "foo" and you know it is\n+        not a VisualBasic script but ".vbs" is on PATHEXT. This option\n+        is only supported on Windows.\n+    """\n+    return list( whichgen(command, path, verbose, exts) )\n+\n+\n+\n+#---- mainline\n+\n+def main(argv):\n+    all = 0\n+    verbose = 0\n+    altpath = None\n+    exts = None\n+    try:\n+        optlist, args = getopt.getopt(argv[1:], \'haVvqp:e:\',\n+            [\'help\', \'all\', \'version\', \'verbose\', \'quiet\', \'path=\', \'exts=\'])\n+    except getopt.GetoptError, msg:\n+        sys.stderr.write("which: error: %s. Your invocation was: %s\\n"\\\n+                         % (msg, argv))\n+        sys.stderr.write("Try \'which --help\'.\\n")\n+        return 1\n+    for opt, optarg in optlist:\n+        if opt in (\'-h\', \'--help\'):\n+            print _cmdlnUsage\n+            return 0\n+        elif opt in (\'-V\', \'--version\'):\n+            print "which %s" % __version__\n+            return 0\n+        elif opt in (\'-a\', \'--all\'):\n+            all = 1\n+        elif opt in (\'-v\', \'--verbose\'):\n+            verbose = 1\n+        elif opt in (\'-q\', \'--quiet\'):\n+            verbose = 0\n+        elif opt in (\'-p\', \'--path\'):\n+            if optarg:\n+                altpath = optarg.split(os.pathsep)\n+            else:\n+                altpath = []\n+        elif opt in (\'-e\', \'--exts\'):\n+            if optarg:\n+                exts = optarg.split(os.pathsep)\n+            else:\n+                exts = []\n+\n+    if len(args) == 0:\n+        return -1\n+\n+    failures = 0\n+    for arg in args:\n+        #print "debug: search for %r" % arg\n+        nmatches = 0\n+        for match in whichgen(arg, path=altpath, verbose=verbose, exts=exts):\n+            if verbose:\n+                print "%s (%s)" % match\n+            else:\n+                print match\n+            nmatches += 1\n+            if not all:\n+                break\n+        if not nmatches:\n+            failures += 1\n+    return failures\n+\n+\n+if __name__ == "__main__":\n+    sys.exit( main(sys.argv) )\n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc corebio/utils/deoptparse.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corebio/utils/deoptparse.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,258 @@\n+#  Copyright (c) 2004 Gavin E. Crooks <gec@compbio.berkeley.edu>\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+#\n+\n+"""Custom extensions to OptionParse for parsing command line options."""\n+# FIXME: Docstring\n+\n+# TODO: Add profiling option\n+\n+# DeOptionParser : \n+# \n+#  http://docs.python.org/lib/module-optparse.html\n+#\n+# Random_options : \n+#   Set random generator and seed. Use options.random as\n+#   source of random numbers\n+# Copyright :\n+#   print copyright information\n+\n+# Documentation :\n+#   print extended document information\n+#\n+# Additional file_in and file_out types\n+\n+import sys\n+from copy import copy\n+from optparse import Option\n+from optparse import OptionParser\n+from optparse import IndentedHelpFormatter\n+from optparse import OptionValueError\n+import random\n+\n+\n+\n+def _copyright_callback(option, opt, value, parser):\n+    if option or  opt or  value or parser: pass # Shut up lint checker\n+    print parser.copyright\n+    sys.exit()\n+\n+def _doc_callback(option, opt, value, parser):\n+    if option or  opt or  value or parser: pass # Shut up lint checker\n+    print parser.long_description\n+    sys.exit()\n+\n+\n+class DeHelpFormatter(IndentedHelpFormatter) :\n+    def __init__ (self,\n+                  indent_increment=2,\n+                  max_help_position=32, \n+                  width=78,\n+                  short_first=1):\n+        IndentedHelpFormatter.__init__(\n+            self, indent_increment, max_help_position,\n+            width, short_first)\n+\n+    def format_option_strings (self, option):\n+        """Return a comma-separated list of option strings & metavariables."""\n+        if option.takes_value():\n+            metavar = option.metavar or option.dest.upper()\n+            short_opts = option._short_opts\n+            long_opts = [lopt + " " + metavar for lopt in option._long_opts]\n+        else:\n+            short_opts = option._short_opts\n+            long_opts = option._long_opts\n+            \n+        if not short_opts : short_opts = ["  ",]\n+\n+        if self.short_first:\n+            opts = short_opts + long_opts\n+        else:\n+            opts = long_opts + short_opts\n+\n+        return " ".join(opts)\n+\n+\n+\n+def _check_file_in(option, opt, value):\n+    if option or  opt or  value : pass # Shut up lint checker \n+    try:\n+        return file(value, "r")\n+    except IOError:\n+        raise OptionValueError(\n+            "option %s: cannot open file: %s" % (opt, value) )\n+\n+def _check_file_out(option, opt, value):\n+    if option or  opt or  value : pass # Shut up lint checker \n+    try:\n+        return file(value, "w+")\n+    except IOError:\n+        raise OptionValueError(\n+            "option %s: cannot open file: %s" % (opt, value) )\n+    \n+def _check_boolean(option, opt, value) :\n+    if option or  opt or  value : pass # Shu'..b'ices for type \'dict\'")\n+            elif not isinstance(self.choices, dict):\n+                raise OptionValueError(\n+                    "choices must be a dictinary (\'%s\' supplied)"\n+                    % str(type(self.choices)).split("\'")[1])\n+            return\n+        self._check_choice()\n+ \n+    # Have to override _check_choices so that we can parse\n+    # a dict through to check_dict\n+    CHECK_METHODS = Option.CHECK_METHODS\n+    CHECK_METHODS[2] = _new_check_choice\n+    \n+\n+\n+\n+\n+class DeOptionParser(OptionParser) :\n+    def __init__(self,\n+                usage=None,\n+                option_list=None,\n+                option_class=DeOption,\n+                version=None,\n+                conflict_handler="error",\n+                description=None,\n+                long_description = None,\n+                formatter=DeHelpFormatter(),\n+                add_help_option=True,\n+                prog=None,\n+                copyright=None,\n+                add_verbose_options=True,\n+                add_random_options=False\n+                ):\n+\n+        OptionParser.__init__(self,\n+                              usage,\n+                              option_list,\n+                              option_class,\n+                              version,\n+                              conflict_handler,\n+                              description,\n+                              formatter,\n+                              add_help_option,\n+                              prog )\n+       \n+        if long_description :\n+            self.long_description = long_description\n+            self.add_option("--doc",\n+                            action="callback",\n+                            callback=_doc_callback,\n+                            help="Detailed documentation")\n+    \n+        if copyright :\n+            self.copyright = copyright\n+            self.add_option("--copyright",\n+                            action="callback",\n+                            callback=_copyright_callback,\n+                            help="") \n+               \n+        if add_verbose_options :\n+            self.add_option("-q", "--quite",\n+                action="store_false",\n+                dest="verbose",\n+                default=False,\n+                help="Run quietly (default)")\n+            \n+            self.add_option("-v", "--verbose",\n+                action="store_true",\n+                dest="verbose",\n+                default=False,\n+                help="Verbose output (Not quite)")\n+    \n+        self.random_options = False\n+        if add_random_options :\n+            self.random_options = True\n+            self.add_option("--seed",\n+                action="store",\n+                type = "int",\n+                dest="random_seed",\n+                help="Initial seed for pseudo-random number generator. (default: System time)",\n+                metavar="INTEGER" )\n+                            \n+            self.add_option("--generator",\n+                action="store",\n+                dest="random_generator",\n+                default="MersenneTwister",\n+                help="Select MersenneTwister (default) or WichmannHill pseudo-random number generator", \n+                metavar="TYPE" )\n+\n+    def parse_args(self,args, values=None) :\n+        (options, args) = OptionParser.parse_args(self, args, values)\n+        \n+        if self.random_options :\n+            if options.random_generator is None or options.random_generator =="MersenneTwister" :\n+                r = random.Random()\n+            elif options.random_generator == "WichmannHill" :\n+                r = random.WichmannHill()\n+            else :\n+                self.error("Acceptible generators are MersenneTwister (default) or WichmannHill")\n+            if options.random_seed :\n+                r.seed(options.random_seed)\n+        \n+            options.__dict__["random"] = r        \n+                \n+        \n+        return (options, args)\n+    \n+    \n\\ No newline at end of file\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc examplepriorfile.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examplepriorfile.txt Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,64 @@
+AAA 1
+AAC 1.5
+AAG 0.5
+AAT 1
+ACA 1
+ACC 1
+ACG 1
+ACT 1
+AGA 1
+AGC 1
+AGG 1
+AGT 1
+ATA 1
+ATC 1
+ATG 1
+ATT 1
+CAA 1
+CAC 1
+CAG 1
+CAT 1
+CCA 1
+CCC 1
+CCG 1
+CCT 1
+CGA 1
+CGC 1
+CGG 1
+CGT 1
+CTA 1
+CTC 1
+CTG 1
+CTT 1
+GAA 1
+GAC 1
+GAG 1
+GAT 1
+GCA 1
+GCC 1
+GCG 1
+GCT 1
+GGA 1
+GGC 1
+GGG 1
+GGT 1
+GTA 1
+GTC 1
+GTG 1
+GTT 1
+TAA 1
+TAC 1
+TAG 1
+TAT 1
+TCA 1
+TCC 1
+TCG 1
+TCT 1
+TGA 1
+TGC 1
+TGG 1
+TGT 1
+TTA 1
+TTC 1
+TTG 1
+TTT 1
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc inter.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inter.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,29 @@
+#!/usr/tmp/bin/python2.7
+
+
+import weblogolib
+from corebio.utils.deoptparse import DeOptionParser
+import sys
+
+
+#setup
+def blackboxcodonl(inputf,outputf):
+  parser = weblogolib._build_option_parser()                
+
+  (opts, args) = parser.parse_args(['--size', 'large', '--composition', 'none', '--fin',inputf,'--fout', outputf])
+
+
+  if args : parser.error("Unparsable arguments: %s " % args)
+  #best not to change anything in the try except block.
+  try:
+    data = weblogolib._build_logodata(opts)
+    format = weblogolib._build_logoformat(data, opts)
+    formatter = opts.formatter
+    formatter(data, format, opts.fout)
+  except ValueError, err :
+    print >>sys.stderr, 'Error:', err
+    sys.exit(2)
+  except KeyboardInterrupt, err:
+    sys.exit(0)
+  
+blackboxcodonl('/home/david/examples/cluster17.aln',"outfile.eps")
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc setup.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+
+import sys
+
+from distutils.core import setup
+from distutils.core import Extension
+from distutils.command.build import build
+from distutils.command.install_data import install_data
+
+# Supress warning that distutils generates for the install_requires option
+import warnings
+warnings.simplefilter('ignore', UserWarning, lineno =236)
+
+# check dependancies
+if not hasattr(sys, 'version_info') or sys.version_info < (2,3,0,'final'):
+    raise SystemExit,  \
+        "Dependancy error: CodonLogo requires Python 2.3 or later."


+from weblogolib import __version__
+
+def main() :     
+    long_description = open("README.txt").read()
+
+      
+    setup(
+        name             =  "codonlogo",
+        version          =  __version__,
+        description      = "CodonLogo: WebLogo3 messed around with",
+        long_description  = long_description,
+        maintainer       = "David Murphy",
+        maintainer_email = "Murphy.David@gmail.com",
+        classifiers      =[
+            'Development Status :: Alpha',
+            'Intended Audience :: Science/Research',
+            'License :: OSI Approved :: BSD License',
+            'Topic :: Scientific/Engineering :: Bio-Informatics',
+            'Programming Language :: Python',
+            'Natural Language :: English',
+            'Operating System :: OS Independent',
+            'Topic :: Software Development :: Libraries',
+            'Topic :: Software Development :: Libraries :: Python Modules',
+            ],
+        
+        scripts = [ 'codonlogo', ],
+        packages  = [ 'weblogolib',],
+        data_files = ['weblogolib/htdocs/*.*','weblogolib/template.eps'],
+        install_requires=['numpy', 'corebio'],        
+        
+        cmdclass= {"install_data" : _install_data},
+    )
+
+
+# Python 2.3 compatability 
+# Rework the install_data command to act like the package_data distutils
+# command included with python 2.4.
+# Adapted from biopython, which was adapted from mxtexttools
+class _install_data(install_data):
+    def finalize_options(self):
+        if self.install_dir is None:
+            installobj = self.distribution.get_command_obj('install')
+            # Use install_lib rather than install_platlib because we are
+            # currently a pure python distribution (No c extensions.)
+            self.install_dir = installobj.install_lib 
+            #print installobj.install_lib 
+        install_data.finalize_options(self)
+
+    def run (self):
+        import glob
+        import os
+        if not self.dry_run:
+            self.mkpath(self.install_dir)
+        data_files = self.get_inputs()
+        for entry in data_files:
+            if type(entry) is not type(""):
+                raise ValueError("data_files must be strings")
+            # Unix- to platform-convention conversion
+            entry = os.sep.join(entry.split("/"))
+            filenames = glob.glob(entry)
+            for filename in filenames:
+                dst = os.path.join(self.install_dir, filename)
+                dstdir = os.path.split(dst)[0]
+                if not self.dry_run:
+                    self.mkpath(dstdir)
+                    outfile = self.copy_file(filename, dst)[0]
+                else:
+                    outfile = dst
+                self.outfiles.append(outfile)
+  
+if __name__ == '__main__' :
+    main()
+    

\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc test_weblogo.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test_weblogo.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,544 @@\n+#!/usr/bin/env python\n+\n+#  Copyright (c) 2006, The Regents of the University of California, through \n+#  Lawrence Berkeley National Laboratory (subject to receipt of any required\n+#  approvals from the U.S. Dept. of Energy).  All rights reserved.\n+\n+#  This software is distributed under the new BSD Open Source License.\n+#  <http://www.opensource.org/licenses/bsd-license.html>\n+#\n+#  Redistribution and use in source and binary forms, with or without \n+#  modification, are permitted provided that the following conditions are met: \n+#\n+#  (1) Redistributions of source code must retain the above copyright notice, \n+#  this list of conditions and the following disclaimer. \n+#\n+#  (2) Redistributions in binary form must reproduce the above copyright \n+#  notice, this list of conditions and the following disclaimer in the \n+#  documentation and or other materials provided with the distribution. \n+#\n+#  (3) Neither the name of the University of California, Lawrence Berkeley \n+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors \n+#  may be used to endorse or promote products derived from this software \n+#  without specific prior written permission. \n+#\n+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" \n+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE \n+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \n+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN \n+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \n+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \n+#  POSSIBILITY OF SUCH DAMAGE. \n+\n+\n+import unittest\n+\n+import weblogolib\n+from weblogolib import  *\n+from weblogolib import  parse_prior, GhostscriptAPI\n+from weblogolib.color import *\n+from weblogolib.colorscheme import *\n+from StringIO import StringIO\n+import sys\n+\n+from numpy import array, asarray, float64, ones, zeros, int32,all,any, shape\n+import numpy as na\n+\n+from corebio import seq_io\n+from corebio.seq import *\n+\n+# python2.3 compatability\n+from corebio._future.subprocess import *\n+from corebio._future import resource_stream\n+\n+from corebio.moremath import entropy\n+from math import log, sqrt\n+codon_alphabetU=[\'AAA\', \'AAC\', \'AAG\', \'AAU\', \'ACA\', \'ACC\', \'ACG\', \'ACU\', \'AGA\', \'AGC\', \'AGG\', \'AGU\', \'AUA\', \'AUC\', \'AUG\', \'AUU\', \'CAA\', \'CAC\', \'CAG\', \'CAU\', \'CCA\', \'CCC\', \'CCG\', \'CCU\', \'CGA\', \'CGC\', \'CGG\', \'CGU\', \'CUA\', \'CUC\', \'CUG\', \'CUU\', \'GAA\', \'GAC\', \'GAG\', \'GAU\', \'GCA\', \'GCC\', \'GCG\', \'GCU\', \'GGA\', \'GGC\', \'GGG\', \'GGU\', \'GUA\', \'GUC\', \'GUG\', \'GUU\', \'UAA\', \'UAC\', \'UAG\', \'UAU\', \'UCA\', \'UCC\', \'UCG\', \'UCU\', \'UGA\', \'UGC\', \'UGG\', \'UGU\', \'UUA\', \'UUC\', \'UUG\', \'UUU\']\n+codon_alphabetT=[\'AAA\', \'AAC\', \'AAG\', \'AAT\', \'ACA\', \'ACC\', \'ACG\', \'ACT\', \'AGA\', \'AGC\', \'AGG\', \'AGT\', \'ATA\', \'ATC\', \'ATG\', \'ATT\', \'CAA\', \'CAC\', \'CAG\', \'CAT\', \'CCA\', \'CCC\', \'CCG\', \'CCT\', \'CGA\', \'CGC\', \'CGG\', \'CGT\', \'CTA\', \'CTC\', \'CTG\', \'CTT\', \'GAA\', \'GAC\', \'GAG\', \'GAT\', \'GCA\', \'GCC\', \'GCG\', \'GCT\', \'GGA\', \'GGC\', \'GGG\', \'GGT\', \'GTA\', \'GTC\', \'GTG\', \'GTT\', \'TAA\', \'TAC\', \'TAG\', \'TAT\', \'TCA\', \'TCC\', \'TCG\', \'TCT\', \'TGA\', \'TGC\', \'TGG\', \'TGT\', \'TTA\', \'TTC\', \'TTG\', \'TTT\']\n+\n+\n+def testdata_stream( name ): \n+    return resource_stream(__name__, \'tests/data/\'+name, __file__)    \n+\n+class test_logoformat(unittest.TestCase) :\n+\n+    def test_options(self) :\n+        options = LogoOptions()\n+\n+           \n+class test_ghostscript(unittest.TestCase) :\n+    def test_version(self) :\n+        version = GhostscriptAPI().version\n+    \n+\n+    \n+class test_parse_prior(unittest.TestCase) :\n+    def assertTrue(self, bool) :\n+        self.assertEquals('..b"richlet(alpha)\n+            for s in range(samples) :\n+                p = d.sample()\n+                #print p\n+                #pt +=p\n+                ent[s] = entropy(p)\n+            \n+            #print pt/samples\n+            \n+            m = mean(ent)\n+            v = var(ent)\n+            \n+            dm = d.mean_entropy()\n+            dv = d.variance_entropy()\n+\n+           #print alpha, ':', m, v, dm, dv \n+            error = 4. * sqrt(v/samples)\n+            self.assertTrue( abs(m-dm) < error)\n+            self.assertTrue( abs(v-dv) < error) # dodgy error estimate \n+\n+\n+        do_test( (1., 1.) )\n+        do_test( (2., 1.) )                                        \n+        do_test( (3., 1.) )                                        \n+        do_test( (4., 1.) )                                        \n+        do_test( (5., 1.) )                                        \n+        do_test( (6., 1.) )                                        \n+\n+        do_test( (1., 1.) )\n+        do_test( (20., 20.) )\n+        do_test( (1., 1., 1., 1., 1., 1., 1., 1., 1., 1.) )\n+        do_test( (.1, .1, .1, .1, .1, .1, .1, .1, .1, .1) )\n+        do_test( (.01, .01, .01, .01, .01, .01, .01, .01, .01, .01) )\n+        do_test( (2.0, 6.0, 1.0, 1.0) )\n+    \n+    \n+    def test_mean(self) :\n+        alpha = ones( ( 10,), float64 ) * 23.\n+        d = Dirichlet(alpha)\n+        m = d.mean()\n+        self.assertAlmostEqual( m[2], 1./10)\n+        self.assertAlmostEqual( sum(m), 1.0)\n+    \n+    def test_covariance(self) :\n+        alpha = ones( ( 4,), float64 ) \n+        d = Dirichlet(alpha)\n+        cv = d.covariance()\n+        self.assertEqual( cv.shape, (4,4)  )\n+        self.assertAlmostEqual( cv[0,0], 1.0 * (1.0 - 1./4.0)/ (4.0 * 5.0)  )\n+        self.assertAlmostEqual( cv[0,1],  - 1 / ( 4. * 4. * 5.) )\n+\n+    def test_mean_x(self) :\n+        alpha = (1.0, 2.0, 3.0, 4.0)\n+        xx = (2.0, 2.0, 2.0, 2.0)\n+        m = Dirichlet(alpha).mean_x(xx)\n+        self.assertEquals( m, 2.0)\n+        \n+        alpha = (1.0, 1.0, 1.0, 1.0)\n+        xx = (2.0, 3.0, 4.0, 3.0)\n+        m = Dirichlet(alpha).mean_x(xx)\n+        self.assertEquals( m, 3.0)        \n+\n+    def test_variance_x(self) :\n+        alpha = (1.0, 1.0, 1.0, 1.0)\n+        xx = (2.0, 2.0, 2.0, 2.0)\n+        v = Dirichlet(alpha).variance_x(xx)\n+        self.assertAlmostEquals( v, 0.0)        \n+\n+        alpha = (1.0, 2.0, 3.0, 4.0)\n+        xx = (2.0, 0.0, 1.0, 10.0)\n+        v = Dirichlet(alpha).variance_x(xx)\n+        #print v\n+        # TODO: Don't actually know if this is correct\n+        \n+    def test_relative_entropy(self):\n+        alpha = (2.0, 10.0, 1.0, 1.0)\n+        d = Dirichlet(alpha)\n+        pvec = (0.1, 0.2, 0.3, 0.4)\n+        \n+        rent = d.mean_relative_entropy(pvec)\n+        vrent = d.variance_relative_entropy(pvec)\n+        low, high = d.interval_relative_entropy(pvec, 0.95)\n+        \n+        #print\n+        #print '> ', rent, vrent, low, high\n+     \n+        # This test can fail randomly, but the precision form a few\n+        # thousand samples is low. Increasing samples, 1000->2000\n+        samples = 2000\n+        sent = zeros( (samples,), float64) \n+        \n+        for s in range(samples) :\n+            post = d.sample()\n+            e = -entropy(post)\n+            for k in range(4) :\n+                e += - post[k] * log(pvec[k])\n+            sent[s] = e\n+        sent.sort()\n+        self.assertTrue( abs(sent.mean() - rent) < 4.*sqrt(vrent) )\n+        self.assertAlmostEqual( sent.std(), sqrt(vrent), 1 )\n+        self.assertTrue( abs(low-sent[ int( samples *0.025)])<0.2 )\n+        self.assertTrue( abs(high-sent[ int( samples *0.975)])<0.2 )\n+        \n+        #print '>>', mean(sent), var(sent), sent[ int( samples *0.025)] ,sent[ int( samples *0.975)] \n+       \n+       \n+   \n+def mean( a) :\n+    return sum(a)/ len(a)\n+    \n+def var(a) :\n+    return (sum(a*a) /len(a) ) - mean(a)**2\n+       \n+       \n+\n+        \n+if __name__ == '__main__':\n+    unittest.main()\n"
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc tests/data/Rv3829c.fasta
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/data/Rv3829c.fasta Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,13 @@
+>Rv3829c
+MTGYDAIVIGAGHNGLTAAVLLQRAGLRTACLDAKRYAGGMASTVELFDG
+YRFEIAGSVQFPTSSAVSSELGLDSLPTVDLEVMSVALRGVGDDPVVQFT
+DPTKMLTHLHRVHGADAVTGMAGLLAWSQAPTRALGRFEAGTLPKSFDEM
+YACATNEFERSAIDDMLFGSVTDVLDRHFPDREKHGALRGSMTVLAVNTL
+YRGPATPGSAAALAFGLGVPEGDFVRWKKLRGGIGALTTHLSQLLERTGG
+EVRLRSKVTEIVVDNSRSSARVRGVRTAAGDTLTSPIVVSAIAPDVTINE
+LIDPAVLPSEIRDRYLRIDHRGSYLQMHFALAQPPAFAAPYQALNDPSMQ
+ASMGIFCTPEQVQQQWEDCRRGIVPADPTVVLQIPSLHDPSLAPAGKQAA
+SAFAMWFPIEGGSKYGGYGRAKVEMGQNVIDKITRLAPNFKGSILRYTTF
+TPKHMGVMFGAPGGDYCHALLHSDQIGPNRPGPKGFIGQPIPIAGLYLGS
+AGCHGGPGITFIPGYNAARQALADRRAANCCVLSGR
+*
\ No newline at end of file
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc tests/data/cap.fa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/data/cap.fa Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,98 @@
+>aldB -18->4
+attcgtgatagctgtcgtaaag
+>ansB 103->125
+ttttgttacctgcctctaactt
+>araB1 109->131
+aagtgtgacgccgtgcaaataa
+>araB2 147->169 
+tgccgtgattatagacactttt
+>cdd 1 107->129
+atttgcgatgcgtcgcgcattt
+>cdd 2 57->79
+taatgagattcagatcacatat
+>crp 1 115->137
+taatgtgacgtcctttgcatac
+>crp 2
+gaaggcgacctgggtcatgctg
+>cya 151->173 
+aggtgttaaattgatcacgttt
+>cytR 1 125->147
+cgatgcgaggcggatcgaaaaa
+>cytR 2 106->128
+aaattcaatattcatcacactt
+>dadAX 1 95->117
+agatgtgagccagctcaccata
+>dadAX 2 32->54
+agatgtgattagattattattc
+>deoP2 1 75->97
+aattgtgatgtgtatcgaagtg
+>deoP2 2 128->150 
+ttatttgaaccagatcgcatta
+>fur 136->158
+aaatgtaagctgtgccacgttt
+>gal 56->78
+aagtgtgacatggaataaatta
+>glpACB (glpTQ) 1 54->76  
+ttgtttgatttcgcgcatattc
+>glpACB (glpTQ) 2 94->116
+aaacgtgatttcatgcgtcatt
+>glpACB (glpTQ) 144->166 
+atgtgtgcggcaattcacattt
+>glpD (glpE) 95->117 
+taatgttatacatatcactcta
+>glpFK 1 120->142
+ttttatgacgaggcacacacat
+>glpFK 2 95->117
+aagttcgatatttctcgttttt
+>gut (srlA) 72->94
+ttttgcgatcaaaataacactt
+>ilvB 87->109
+aaacgtgatcaacccctcaatt
+>lac 1 (lacZ) 88->110
+taatgtgagttagctcactcat
+>lac 2 (lacZ) 16->38 
+aattgtgagcggataacaattt
+>malEpKp1 110->132
+ttgtgtgatctctgttacagaa
+>malEpKp2 139->161
+TAAtgtggagatgcgcacaTAA
+>malEpKp3 173->195
+TTTtgcaagcaacatcacgAAA
+>malEpKp4 205->227
+GACctcggtttagttcacaGAA
+>malT 121->143
+aattgtgacacagtgcaaattc
+>melR 52->74
+aaccgtgctcccactcgcagtc
+>mtl 302->324
+TCTTGTGATTCAGATCACAAAG
+>nag 156->178
+ttttgtgagttttgtcaccaaa
+>nupG2 97->119
+aaatgttatccacatcacaatt
+>nupG1 47->69
+ttatttgccacaggtaacaaaa
+>ompA 166->188
+atgcctgacggagttcacactt
+>ompR 161->183
+taacgtgatcatatcaacagaa
+>ptsH A 316->338
+Ttttgtggcctgcttcaaactt
+>ptsH B 188->210
+ttttatgatttggttcaattct
+>rhaS (rhaB) 161->183 
+aattgtgaacatcatcacgttc
+>rot 1 (ppiA) 182->204 
+ttttgtgatctgtttaaatgtt
+>rot 2 (ppiA) 129->151
+agaggtgattttgatcacggaa
+>tdcA 60->82
+atttgtgagtggtcgcacatat
+>tnaL 73->95
+gattgtgattcgattcacattt
+>tsx 2 146->168
+gtgtgtaaacgtgaacgcaatc
+>tsx 1 107->129
+aactgtgaaacgaaacatattt
+>uxuAB 165->187
+TCTTGTGATGTGGTTAACCAAT
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc tests/data/capu.fa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/data/capu.fa Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,98 @@
+>aldB -18->4
+auucgugauagcugucguaaag
+>ansB 103->125
+uuuuguuaccugccucuaacuu
+>araB1 109->131
+aagugugacgccgugcaaauaa
+>araB2 147->169 
+ugccgugauuauagacacuuuu
+>cdd 1 107->129
+auuugcgaugcgucgcgcauuu
+>cdd 2 57->79
+uaaugagauucagaucacauau
+>crp 1 115->137
+uaaugugacguccuuugcauac
+>crp 2
+gaaggcgaccugggucaugcug
+>cya 151->173 
+agguguuaaauugaucacguuu
+>cyuR 1 125->147
+cgaugcgaggcggaucgaaaaa
+>cyuR 2 106->128
+aaauucaauauucaucacacuu
+>dadAX 1 95->117
+agaugugagccagcucaccaua
+>dadAX 2 32->54
+agaugugauuagauuauuauuc
+>deoP2 1 75->97
+aauugugauguguaucgaagug
+>deoP2 2 128->150 
+uuauuugaaccagaucgcauua
+>fur 136->158
+aaauguaagcugugccacguuu
+>gal 56->78
+aagugugacauggaauaaauua
+>glpACB (glpUQ) 1 54->76  
+uuguuugauuucgcgcauauuc
+>glpACB (glpUQ) 2 94->116
+aaacgugauuucaugcgucauu
+>glpACB (glpUQ) 144->166 
+augugugcggcaauucacauuu
+>glpD (glpE) 95->117 
+uaauguuauacauaucacucua
+>glpFK 1 120->142
+uuuuaugacgaggcacacacau
+>glpFK 2 95->117
+aaguucgauauuucucguuuuu
+>guu (srlA) 72->94
+uuuugcgaucaaaauaacacuu
+>ilvB 87->109
+aaacgugaucaaccccucaauu
+>lac 1 (lacZ) 88->110
+uaaugugaguuagcucacucau
+>lac 2 (lacZ) 16->38 
+aauugugagcggauaacaauuu
+>malEpKp1 110->132
+uugugugaucucuguuacagaa
+>malEpKp2 139->161
+UAAuguggagaugcgcacaUAA
+>malEpKp3 173->195
+UUUugcaagcaacaucacgAAA
+>malEpKp4 205->227
+GACcucgguuuaguucacaGAA
+>malU 121->143
+aauugugacacagugcaaauuc
+>melR 52->74
+aaccgugcucccacucgcaguc
+>mul 302->324
+UCUUGUGAUUCAGAUCACAAAG
+>nag 156->178
+uuuugugaguuuugucaccaaa
+>nupG2 97->119
+aaauguuauccacaucacaauu
+>nupG1 47->69
+uuauuugccacagguaacaaaa
+>ompA 166->188
+augccugacggaguucacacuu
+>ompR 161->183
+uaacgugaucauaucaacagaa
+>pusH A 316->338
+Uuuuguggccugcuucaaacuu
+>pusH B 188->210
+uuuuaugauuugguucaauucu
+>rhaS (rhaB) 161->183 
+aauugugaacaucaucacguuc
+>rou 1 (ppiA) 182->204 
+uuuugugaucuguuuaaauguu
+>rou 2 (ppiA) 129->151
+agaggugauuuugaucacggaa
+>udcA 60->82
+auuugugaguggucgcacauau
+>unaL 73->95
+gauugugauucgauucacauuu
+>usx 2 146->168
+guguguaaacgugaacgcaauc
+>usx 1 107->129
+aacugugaaacgaaacauauuu
+>uxuAB 165->187
+UCUUGUGAUGUGGUUAACCAAU
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc tests/data/cox2.msf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/data/cox2.msf Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,33 @@
+ mini.msf  MSF: 166  Type: N  January 01, 1776  12:00  Check: 8077 ..
+
+ Name: cox2_leita       Len:   166  Check:  2103  Weight:  1.00
+ Name: cox2_crifa       Len:   166  Check:  1179  Weight:  1.00
+ Name: cox2_trybb       Len:   166  Check:   999  Weight:  1.00
+ Name: Cox2_bsalt       Len:   166  Check:  2740  Weight:  1.00
+ Name: cox2_tborr       Len:   166  Check:  1056  Weight:  1.00
+
+//
+
+     cox2_leita  MAFILSFWMI FLLDSVIVL? ???LSFVCFV CVWICALLFS TVLLVSKLN?
+     cox2_crifa  MAFILSFWMI FLIDAVIVL? ???LSFVCFV CIWICSLFFS SFLLVSKIN?
+     cox2_trybb  MSFILTFWMI FLMDSIIVL? ???ISFSIFL SVWICALIIA TVLTVTKIN?
+     Cox2_bsalt  MSFIISF?ML FLIDSLIVL? ???LSGAIFV CIWICSLFFL CILFICKLD?
+     cox2_tborr  MLFFINQLLL LLVDTFVIL? ???EIFSLFV CVFIIVMYIL FINYNIFLK?
+
+     cox2_leita  ?NIYCTWDFT ASKFIDVYWF TIGGMFSLGL ?LLRLCLLLY FGHLN?????
+     cox2_crifa  ?NVYCTWDFT ASKFIDAYWF TIGGMFVLCL ?LLRLCLLLY FGCLN?????
+     cox2_trybb  ?NIYCTWDFI SSKFIDTYWF VLGMMFILCL ?LLRLCLLLY FSCIN?????
+     Cox2_bsalt  ?YIFCS?DFI SAKFIDLY?F TLGCLFIVCL ?LIRLCLLLY FSCLN?????
+     cox2_tborr  ?NINVYLDFI GSKYLDLYWF LIGIFFVIVL ?LIRLCLLLY YSWIS?????
+
+     cox2_leita  ???FVSFDLC KVVGFQWYWV YFIFG????? ??ETTIFSNL ILESDYMIGD
+     cox2_crifa  ???FVSFDLC KVVGFQWYWV YFIFG????? ??ETTIFSNL ILESDYLIGD
+     cox2_trybb  ???FVSFDLC KVIGFQWYWV YFLFG????? ??ETTIFSNL ILESDYLIGD
+     Cox2_bsalt  ???FVCFDLC KCIGFQ?Y?V YFIFG????? ??ETTIFSNL ILESDYLIGD
+     cox2_tborr  ???LLIFDLC KIMGFQWYWI FFVFK????? ??ENVIFSNL LIESDYWIGD
+
+     cox2_leita  LR???????? ??????
+     cox2_crifa  LR???????? ??????
+     cox2_trybb  LR???????? ??????
+     Cox2_bsalt  LR???????? ??????
+     cox2_tborr  LR???????? ??????
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/.___init__.py
b
Binary file weblogolib/.___init__.py has changed
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/__init__.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/__init__.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,2084 @@\n+#!/usr/bin/env python\n+\n+# -------------------------------- WebLogo --------------------------------\n+\n+#  Copyright (c) 2003-2004 The Regents of the University of California.\n+#  Copyright (c) 2005 Gavin E. Crooks\n+#  Copyright (c) 2006, The Regents of the University of California, through print\n+#  Lawrence Berkeley National Laboratory (subject to receipt of any required\n+#  approvals from the U.S. Dept. of Energy).  All rights reserved.\n+\n+#  This software is distributed under the new BSD Open Source License.\n+#  <http://www.opensource.org/licenses/bsd-license.html>\n+#\n+#  Redistribution and use in source and binary forms, with or without \n+#  modification, are permitted provided that the following conditions are met: \n+#\n+#  (1) Redistributions of source code must retain the above copyright notice, \n+#  this list of conditions and the following disclaimer. \n+#\n+#  (2) Redistributions in binary form must reproduce the above copyright \n+#  notice, this list of conditions and the following disclaimer in the \n+#  documentation and or other materials provided with the distribution. \n+#\n+#  (3) Neither the name of the University of California, Lawrence Berkeley \n+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors \n+#  may be used to endorse or promote products derived from this software \n+#  without specific prior written permission. \n+#\n+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" \n+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE \n+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \n+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN \n+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \n+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \n+#  POSSIBILITY OF SUCH DAMAGE. \n+\n+# Replicates README.txt\n+\n+"""\n+WebLogo (http://code.google.com/p/weblogo/) is a tool for creating sequence \n+logos from biological sequence alignments.  It can be run on the command line,\n+as a standalone webserver, as a CGI webapp, or as a python library.\n+\n+The main WebLogo webserver is located at http://bespoke.lbl.gov/weblogo/\n+\n+\n+Codonlogo is based on Weblogo. \n+\n+Please consult the manual for installation instructions and more information:\n+(Also located in the weblogolib/htdocs subdirectory.)\n+\n+For help on the command line interface run\n+    ./codonlogo --help\n+\n+To build a simple logo run\n+    ./codonlogo  < cap.fa > logo0.eps\n+    \n+To run as a standalone webserver at localhost:8080 \n+    ./codonlogo --server\n+\n+To create a logo in python code:\n+    >>> from weblogolib import *\n+    >>> fin = open(\'cap.fa\')\n+    >>> seqs = read_seq_data(fin) \n+    >>> data = LogoData.from_seqs(seqs)\n+    >>> options = LogoOptions()\n+    >>> options.title = "A Logo Title"\n+    >>> format = LogoFormat(data, options)\n+    >>> fout = open(\'cap.eps\', \'w\') \n+    >>> eps_formatter( data, format, fout)\n+\n+\n+-- Distribution and Modification --\n+This package is distributed under the new BSD Open Source License. \n+Please see the LICENSE.txt file for details on copyright and licensing.\n+The WebLogo source code can be downloaded from http://code.google.com/p/weblogo/\n+WebLogo requires Python 2.3, 2.4 or 2.5, the corebio python toolkit for computational \n+biology (http://code.google.com/p/corebio), and the python array package \n+\'numpy\' (http://www.scipy.org/Download)\n+\n+# -------------------------------- CodonLogo --------------------------------\n+\n+\n+"""\n+\n+from math import *\n+import random\n+from itertools import izip, count\n+import sys\n+import copy\n+import os\n+from '..b'def mean_x(self, x) :\n+        x = asarray(x, float64)\n+        if shape(x) != shape(self.alpha) :\n+            raise ValueError("Argument must be same dimension as Dirichlet")\n+        return sum( x * self.mean()) \n+\n+    def variance_x(self, x) :\n+        x = asarray(x, float64)\n+        if shape(x) != shape(self.alpha) :\n+            raise ValueError("Argument must be same dimension as Dirichlet")        \n+            \n+        cv = self.covariance()\n+        var = na.dot(na.dot(na.transpose( x), cv), x)\n+        return var\n+\n+\n+    def mean_entropy(self) :\n+        """Calculate the average entropy of probabilities sampled\n+        from this Dirichlet distribution. \n+        \n+        Returns:\n+            The average entropy.\n+            \n+        Ref:\n+            Wolpert & Wolf, PRE 53:6841-6854 (1996) Theorem 7\n+            (Warning: this paper contains typos.)\n+        Status:\n+            Alpha\n+        Authors:\n+            GEC 2005\n+    \n+        """\n+        # TODO: Optimize\n+        alpha = self.alpha\n+        A = float(sum(alpha))\n+        ent = 0.0\n+        for a in alpha:\n+            if a>0 : ent += - 1.0 * a * digamma( 1.0+a) # FIXME: Check\n+        ent /= A\n+        ent += digamma(A+1.0)\n+        return ent    \n+\n+\n+\n+    def variance_entropy(self):\n+        """Calculate the variance of the Dirichlet entropy. \n+\n+        Ref:\n+            Wolpert & Wolf, PRE 53:6841-6854 (1996) Theorem 8\n+            (Warning: this paper contains typos.)\n+        """\n+        alpha = self.alpha\n+        A = float(sum(alpha))\n+        A2 = A * (A+1)\n+        L = len(alpha)\n+        \n+        dg1 = zeros( (L) , float64)\n+        dg2 = zeros( (L) , float64)\n+        tg2 = zeros( (L) , float64)        \n+        \n+        for i in range(L) :\n+            dg1[i] = digamma(alpha[i] + 1.0)\n+            dg2[i] = digamma(alpha[i] + 2.0)\n+            tg2[i] = trigamma(alpha[i] + 2.0)\n+\n+        dg_Ap2 = digamma( A+2. )\n+        tg_Ap2 = trigamma( A+2. )\n+        \n+        mean = self.mean_entropy()\n+        var = 0.0\n+    \n+        for i in range(L) :\n+            for j in range(L) :\n+                if i != j :\n+                    var += (\n+                        ( dg1[i] - dg_Ap2 ) * (dg1[j] - dg_Ap2 ) - tg_Ap2 \n+                        ) * (alpha[i] * alpha[j] ) / A2\n+                else : \n+                    var += (\n+                        ( dg2[i] - dg_Ap2 ) **2 + ( tg2[i] - tg_Ap2 )\n+                        ) * ( alpha[i] * (alpha[i]+1.) ) / A2\n+\n+        var -= mean**2\n+        return var\n+        \n+        \n+        \n+    def mean_relative_entropy(self, pvec) :\n+        ln_p = na.log(pvec)\n+        return - self.mean_x(ln_p) - self.mean_entropy() \n+    \n+    \n+    def variance_relative_entropy(self, pvec) :\n+        ln_p = na.log(pvec)\n+        return self.variance_x(ln_p) + self.variance_entropy()\n+    \n+    \n+    def interval_relative_entropy(self, pvec, frac) :\n+        mean = self.mean_relative_entropy(pvec) \n+        variance = self.variance_relative_entropy(pvec) \n+        # If the variance is small, use the standard 95% \n+        # confidence interval: mean +/- 1.96 * sd\n+        if variance< 0.1 :\n+            sd = sqrt(variance)\n+            return max(0.0, mean - sd*1.96), mean + sd*1.96\n+        sd = sqrt(variance)\n+        return max(0.0, mean - sd*1.96), mean + sd*1.96\n+        \n+        g = gamma.from_mean_variance(mean, variance)\n+        low_limit = g.inverse_cdf( (1.-frac)/2.)\n+        high_limit = g.inverse_cdf( 1. - (1.-frac)/2. )\n+        \n+        return low_limit, high_limit\n+\n+\n+# Standard python voodoo for CLI\n+if __name__ == "__main__":\n+    ## Code Profiling. Uncomment these lines\n+    #import hotshot, hotshot.stats\n+    #prof = hotshot.Profile("stones.prof")\n+    #prof.runcall(main)\n+    #prof.close()\n+    #stats = hotshot.stats.load("stones.prof")\n+    #stats.strip_dirs()\n+    #stats.sort_stats(\'cumulative\', \'calls\')\n+    #stats.print_stats(40)\n+    #sys.exit()\n+\n+    main()\n+    \n+\n+\n+\n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/_cgi.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/_cgi.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,446 @@\n+#!/usr/bin/env python\n+\n+#  Copyright (c) 2003-2004 The Regents of the University of California.\n+#  Copyright (c) 2005 Gavin E. Crooks\n+#  Copyright (c) 2006, The Regents of the University of California, through \n+#  Lawrence Berkeley National Laboratory (subject to receipt of any required\n+#  approvals from the U.S. Dept. of Energy).  All rights reserved.\n+\n+#  This software is distributed under the new BSD Open Source License.\n+#  <http://www.opensource.org/licenses/bsd-license.html>\n+#\n+#  Redistribution and use in source and binary forms, with or without \n+#  modification, are permitted provided that the following conditions are met: \n+#\n+#  (1) Redistributions of source code must retain the above copyright notice, \n+#  this list of conditions and the following disclaimer. \n+#\n+#  (2) Redistributions in binary form must reproduce the above copyright \n+#  notice, this list of conditions and the following disclaimer in the \n+#  documentation and or other materials provided with the distribution. \n+#\n+#  (3) Neither the name of the University of California, Lawrence Berkeley \n+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors \n+#  may be used to endorse or promote products derived from this software \n+#  without specific prior written permission. \n+#\n+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" \n+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE \n+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \n+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN \n+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) \n+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \n+#  POSSIBILITY OF SUCH DAMAGE. \n+\n+import sys\n+import cgi as cgilib\n+import cgitb; cgitb.enable()\n+\n+#print "Content-Type: text/html\\n\\n"\n+#print "HELLO WORLD"\n+#print __name__\n+\n+from StringIO import StringIO\n+from color import *\n+from colorscheme import ColorScheme, ColorGroup\n+\n+import weblogolib\n+from corebio.utils import *\n+from corebio._future import Template\n+\n+\n+# TODO: Check units\n+\n+# TODO: In WebLogo2: why slash create.cgi? I think this was a workaround\n+# for some browser quirk\n+#<form method="post" action="/create.cgi" enctype="multipart/form-data">\n+    \n+def resource_string(resource, basefilename) :\n+    import os\n+    fn =  os.path.join(os.path.dirname(basefilename), resource)\n+    return open( fn ).read()\n+\n+mime_type = {\n+    \'eps\': \'application/postscript\', \n+    \'pdf\': \'application/pdf\',\n+    \'png\': \'image/png\',\n+    \'png_print\': \'image/png\',    \n+    \'txt\' : \'text/plain\',       \n+    \'jpeg\'  : \'image/jpeg\',\n+}\n+\n+extension = {\n+    \'eps\': \'eps\',\n+    \'pdf\': \'pdf\',\n+    \'png\': \'png\',\n+    \'png_print\': \'png\',\n+    \'txt\' : \'txt\',        \n+    \'jpeg\'  : \'png\'\n+}\n+\n+\n+alphabets = {\n+    \'alphabet_auto\': None, \n+    \'alphabet_protein\': weblogolib.unambiguous_protein_alphabet, \n+    \'alphabet_rna\': weblogolib.unambiguous_rna_alphabet,\n+    \'alphabet_dna\': weblogolib.unambiguous_dna_alphabet}\n+\n+color_schemes = {}\n+for k in weblogolib.std_color_schemes.keys():\n+    color_schemes[ \'color_\'+k.replace(\' \', \'_\')] = weblogolib.std_color_schemes[k]\n+    \n+\n+composition = {\'comp_none\' : \'none\',\n+    \'comp_auto\' : \'auto\',\n+    \'comp_equiprobable\':\'equiprobable\',\n+    \'comp_CG\': \'percentCG\',\n+    \'comp_Celegans\' : \'C. elegans\',\n+    \'comp_Dmelanogaster\' : \'D. melanogaster\',\n+    \'comp_Ecoli\' : \'E. coli\',\n+    \'comp_Hsapiens\': \'H. sapiens\',\n+    \'comp_Mmusculus\' : \'M. musculus\',\n+    \'comp_Scerevisiae\': \'S. cerevisiae\'\n+}\n+\n+class Field(object) :\n+    """ A represe'..b'comp = form["composition"].get_value()\n+        percentCG = form["percentCG"].get_value()\n+        ignore_lower_case = form_values.has_key("ignore_lower_case") \n+        seqs = weblogolib.read_seq_data(StringIO( sequences), \n+                                        alphabet=logooptions.alphabet,\n+                                        ignore_lower_case=ignore_lower_case\n+                                        )\n+        if comp==\'percentCG\': comp = str(percentCG/100)\n+        prior = weblogolib.parse_prior(comp, seqs.alphabet)\n+        data = weblogolib.LogoData.from_seqs(seqs, prior) \n+        logoformat =  weblogolib.LogoFormat(data, logooptions)\n+        format = form["format"].value        \n+        weblogolib.formatters[format](data, logoformat, logo)            \n+    except ValueError, err :\n+        errors.append( err.args )\n+    except IOError, err :\n+        errors.append( err.args)\n+    except RuntimeError, err :\n+        errors.append( err.args )\n+              \n+    if form_values.has_key("cmd_validate") or errors :\n+        send_form(controls, errors, htdocs_directory) \n+        return    \n+ \n+ \n+    #\n+    #  RETURN LOGO OVER HTTP\n+    #\n+\n+    print "Content-Type:", mime_type[format]\n+    # Content-Disposition: inline       Open logo in browser window\n+    # Content-Disposition: attachment   Download logo  \n+    if form_values.has_key("download") :\n+        print \'Content-Disposition: attachment; \' \\\n+            \'filename="logo.%s"\' % extension[format] \n+    else :       \n+        print \'Content-Disposition: inline; \' \\\n+            \'filename="logo.%s"\' % extension[format]        \n+    \n+        \n+    # Seperate header from data\n+    print \n+        \n+    # Finally, and at last, send the logo.\n+    print logo.getvalue()        \n+\n+  \n+def send_form(controls, errors=[], htdocs_directory=None) :\n+    if htdocs_directory is None :\n+        htdocs_directory = os.path.join(\n+            os.path.dirname(__file__, "htdocs") )\n+\n+    subsitutions = {}\n+    subsitutions["version"] = weblogolib.release_description \n+    \n+    for c in controls :\n+        if c.options :\n+            for opt in c.options :\n+                subsitutions[opt.replace(\'/\',\'_\')] = \'\'\n+            subsitutions[c.value.replace(\'/\',\'_\')] = \'selected\'\n+        else :\n+            value = c.value\n+            if value == None : value = \'auto\'\n+            if value==\'true\':\n+                subsitutions[c.name] = \'checked\'\n+            elif type(value)==bool :\n+                if value :\n+                    subsitutions[c.name] = \'checked\'\n+                else :\n+                    subsitutions[c.name] = \'\'\n+            else :\n+                subsitutions[c.name] = str(value)\n+        subsitutions[c.name+\'_err\']  = \'\'\n+            \n+    if errors :\n+        print >>sys.stderr, errors\n+        error_message = []\n+        for e in errors :\n+            if type(e) is str :\n+                msg = e\n+            elif len(e)==2:\n+                subsitutions[e[0]+"_err"] = "class=\'error\'"    \n+                msg = e[1]\n+            else :\n+                msg = e[0]\n+\n+\n+            error_message +=  "ERROR: " \n+            error_message +=  msg\n+            error_message += \' <br />\'\n+            \n+        error_message += \\\n+            "<input style=\'float:right; font-size:small\' type=\'submit\' name=\'cmd_validate\' value=\'Clear Error\' /> "\n+        subsitutions["error_message"] = \'\'.join(error_message)\n+    else :\n+        subsitutions["error_message"] = ""\n+    \n+        \n+    template = resource_string("create_html_template.html", htdocs_directory)\n+    html = Template(template).safe_substitute(subsitutions) #FIXME\n+\n+    print "Content-Type: text/html\\n\\n"\n+    print html\n+\n+    # DEBUG\n+    # keys = subsitutions.keys()\n+    # keys.sort()\n+    # for k in keys :\n+    #    print k,"=", subsitutions[k], " <br />" \n+\n+    #for k in controls :\n+    #    print k.name,"=", k.get_value(), " <br />" \n+\n+\n+\n+if __name__=="__main__" :\n+    main()\n+\n+\n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/color.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/color.py Fri Jan 13 07:18:19 2012 -0500
b
b'@@ -0,0 +1,324 @@\n+\n+\n+#  Copyright (c) 2005 Gavin E. Crooks\n+#\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+\n+""" Color specifications using CSS2 (Cascading Style Sheet) syntax."""\n+\n+class Color:    \n+    """ Color specifications using CSS2 (Cascading Style Sheet) syntax.\n+    \n+    http://www.w3.org/TR/REC-CSS2/syndata.html#color-units\n+\n+    Usage:\n+    \n+    red = Color(255,0,0)\n+    red = Color(1., 0., 0.)\n+    red = Color.by_name("red")\n+    red = Color.from_rgb(1.,0.,0.)\n+    red = Color.from_rgb(255,0,0)\n+    red = Color.from_hsl(0.,1., 0.5)\n+    \n+    red = Color.from_string("red") \n+    red = Color.from_string("RED") \n+    red = Color.from_string("#F00") \n+    red = Color.from_string("#FF0000") \n+    red = Color.from_string("rgb(255, 0, 0)")\n+    red = Color.from_string("rgb(100%, 0%, 0%)")\n+    red = Color.from_string("hsl(0, 100%, 50%)")\n+\n+    """\n+    def __init__(self, red, green, blue) :\n+        \n+        if ( type(red) is not type(green) ) or (type(red) is not type(blue)):\n+            raise TypeError("Mixed floats and integers?")\n+\n+        if type(red) is type(1) : red = float(red)/255.\n+        if type(green) is type(1) : green = float(green)/255.                  \n+        if type(blue) is type(1) : blue = float(blue)/255.\n+\n+        self.red = max(0., min(float(red), 1.0))\n+        self.green = max(0., min(float(green), 1.0))\n+        self.blue = max(0., min(float(blue), 1.0))\n+\n+    #@staticmethod\n+    def names():\n+        "Return a list of standard color names."\n+        return _std_colors.keys()\n+    names = staticmethod(names)\n+\n+    #@classmethod\n+    def from_rgb(cls, r, g, b):\n+        return cls(r,g,b)\n+    from_rgb = classmethod(from_rgb)\n+ \n+    #@classmethod\n+    def from_hsl(cls, hue_angle, saturation, lightness ):\n+        def hue_to_rgb( v1, v2, vH) :\n+            if vH < 0.0 : vH += 1.0\n+            if vH > 1.0 : vH -= 1.0\n+            if vH*6.0 < 1.0 : return (v1 + (v2 - v1) * 6.0 * vH)\n+            if vH*2.0 < 1.0 : return v2\n+            if vH*3.0 < 2.0 : return (v1 + (v2 - v1) * ((2.0/3.0) - vH) * 6.0)\n+            return v1      \n+    \n+        hue =  (((hue_angle % 360.) + 360.) % 360.)/360.\n+        \n+        if not (saturation >= 0.0 and saturation <=1.0) :\n+            raise ValueError("Out-of-range saturation %f"% saturation)\n+        if not (lightness >= 0.0 and lightness <=1.0) :\n+            raise ValueError("Out-of-range lightness %f"% lightness)\n+                \n+        if saturation == 0 :\n+            # greyscale\n+            return cls.from_rgb( lightness, lightness, lightness)\n+    \n+        if lightness < 0.5 :\n+            v2 = lightness * (1.0+ saturation)\n+        else :\n+            v2 = (lightness + saturation) - (saturation* lightness)       \n+\n+        v1 = 2.0 * lightness - v2\n+        r = hue_to_rgb( v'..b',245),     #fff0f5\n+    lawngreen = Color(124,252,0),     #7cfc00\n+    lemonchiffon = Color(255,250,205),     #fffacd\n+    lightblue = Color(173,216,230),     #add8e6\n+    lightcoral = Color(240,128,128),     #f08080\n+    lightcyan = Color(224,255,255),     #e0ffff\n+    lightgoldenrodyellow = Color(250,250,210),     #fafad2\n+    lightgray = Color(211,211,211),     #d3d3d3\n+    lightgreen = Color(144,238,144),     #90ee90\n+    lightgrey = Color(211,211,211),     #d3d3d3\n+    lightpink = Color(255,182,193),     #ffb6c1\n+    lightsalmon = Color(255,160,122),     #ffa07a\n+    lightseagreen = Color(32,178,170),     #20b2aa\n+    lightskyblue = Color(135,206,250),     #87cefa\n+    lightslategray = Color(119,136,153),     #778899\n+    lightslategrey = Color(119,136,153),     #778899\n+    lightsteelblue = Color(176,196,222),     #b0c4de\n+    lightyellow = Color(255,255,224),     #ffffe0\n+    lime = Color(0,255,0),     #00ff00\n+    limegreen = Color(50,205,50),     #32cd32\n+    linen = Color(250,240,230),     #faf0e6\n+    magenta = Color(255,0,255),     #ff00ff\n+    maroon = Color(128,0,0),     #800000\n+    mediumaquamarine = Color(102,205,170),     #66cdaa\n+    mediumblue = Color(0,0,205),     #0000cd\n+    mediumorchid = Color(186,85,211),     #ba55d3\n+    mediumpurple = Color(147,112,219),     #9370db\n+    mediumseagreen = Color(60,179,113),     #3cb371\n+    mediumslateblue = Color(123,104,238),     #7b68ee\n+    mediumspringgreen = Color(0,250,154),     #00fa9a\n+    mediumturquoise = Color(72,209,204),     #48d1cc\n+    mediumvioletred = Color(199,21,133),     #c71585\n+    midnightblue = Color(25,25,112),     #191970\n+    mintcream = Color(245,255,250),     #f5fffa\n+    mistyrose = Color(255,228,225),     #ffe4e1\n+    moccasin = Color(255,228,181),     #ffe4b5\n+    navajowhite = Color(255,222,173),     #ffdead\n+    navy = Color(0,0,128),     #000080\n+    oldlace = Color(253,245,230),     #fdf5e6\n+    olive = Color(128,128,0),     #808000\n+    olivedrab = Color(107,142,35),     #6b8e23\n+    orange = Color(255,165,0),     #ffa500\n+    orangered = Color(255,69,0),     #ff4500\n+    orchid = Color(218,112,214),     #da70d6\n+    palegoldenrod = Color(238,232,170),     #eee8aa\n+    palegreen = Color(152,251,152),     #98fb98\n+    paleturquoise = Color(175,238,238),     #afeeee\n+    palevioletred = Color(219,112,147),     #db7093\n+    papayawhip = Color(255,239,213),     #ffefd5\n+    peachpuff = Color(255,218,185),     #ffdab9\n+    peru = Color(205,133,63),     #cd853f\n+    pink = Color(255,192,203),     #ffc0cb\n+    plum = Color(221,160,221),     #dda0dd\n+    powderblue = Color(176,224,230),     #b0e0e6\n+    purple = Color(128,0,128),     #800080\n+    red = Color(255,0,0),     #ff0000\n+    rosybrown = Color(188,143,143),     #bc8f8f\n+    royalblue = Color(65,105,225),     #4169e1\n+    saddlebrown = Color(139,69,19),     #8b4513\n+    salmon = Color(250,128,114),     #fa8072\n+    sandybrown = Color(244,164,96),     #f4a460\n+    seagreen = Color(46,139,87),     #2e8b57\n+    seashell = Color(255,245,238),     #fff5ee\n+    sienna = Color(160,82,45),     #a0522d\n+    silver = Color(192,192,192),     #c0c0c0\n+    skyblue = Color(135,206,235),     #87ceeb\n+    slateblue = Color(106,90,205),     #6a5acd\n+    slategray = Color(112,128,144),     #708090\n+    slategrey = Color(112,128,144),     #708090\n+    snow = Color(255,250,250),     #fffafa\n+    springgreen = Color(0,255,127),     #00ff7f\n+    steelblue = Color(70,130,180),     #4682b4\n+    tan = Color(210,180,140),     #d2b48c\n+    teal = Color(0,128,128),     #008080\n+    thistle = Color(216,191,216),     #d8bfd8\n+    tomato = Color(255,99,71),     #ff6347\n+    turquoise = Color(64,224,208),     #40e0d0\n+    violet = Color(238,130,238),     #ee82ee\n+    wheat = Color(245,222,179),     #f5deb3\n+    white = Color(255,255,255),     #ffffff\n+    whitesmoke = Color(245,245,245),     #f5f5f5\n+    yellow = Color(255,255,0),     #ffff00\n+    yellowgreen = Color(154,205,50)     #9acd32\n+    )\n+    \n+    \n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/colorscheme.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/colorscheme.py Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,455 @@\n+\n+#  Copyright (c) 2003-2005 The Regents of the University of California.\n+#  Copyright (c) 2005 Gavin E. Crooks\n+\n+#  This software is distributed under the MIT Open Source License.\n+#  <http://www.opensource.org/licenses/mit-license.html>\n+#\n+#  Permission is hereby granted, free of charge, to any person obtaining a \n+#  copy of this software and associated documentation files (the "Software"),\n+#  to deal in the Software without restriction, including without limitation\n+#  the rights to use, copy, modify, merge, publish, distribute, sublicense,\n+#  and/or sell copies of the Software, and to permit persons to whom the\n+#  Software is furnished to do so, subject to the following conditions:\n+#\n+#  The above copyright notice and this permission notice shall be included\n+#  in all copies or substantial portions of the Software.\n+#\n+#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n+#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n+#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n+#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \n+#  THE SOFTWARE.\n+\n+""" Popular color codings for nucleic and amino acids. \n+\n+Classes:\n+    ColorScheme -- A color scheme\n+    ColorGroup  \n+    \n+    \n+Generic\n+    monochrome\n+\n+Nucleotides\n+    nucleotide\n+    base pairing\n+\n+Amino Acid\n+    hydrophobicity\n+    chemistry\n+    charge\n+    taylor\n+\n+Status : Beta - Needs documentation.\n+\n+"""\n+# Good online references include bioruby and the JalView alignment editor.\n+# Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), \n+# "The Jalview Java Alignment Editor," Bioinformatics, 12, 426-7\n+# http://www.jalview.org\n+\n+import sys\n+\n+from corebio import seq\n+from color import Color\n+codon_alphabetU=[\'AAA\', \'AAU\', \'AAC\', \'AAG\', \'AUA\', \'AUU\', \'AUC\', \'AUG\', \'ACA\', \'ACU\', \'ACC\', \'ACG\', \'AGA\', \'AGU\', \'AGC\', \'AGG\', \'UAA\', \'UAU\', \'UAC\', \'UAG\', \'UUA\', \'UUU\', \'UUC\', \'UUG\', \'UCA\', \'UCU\', \'UCC\', \'UCG\', \'UGA\', \'UGU\', \'UGC\', \'UGG\', \'CAA\', \'CAU\', \'CAC\', \'CAG\', \'CUA\', \'CUU\', \'CUC\', \'CUG\', \'CCA\', \'CCU\', \'CCC\', \'CCG\', \'CGA\', \'CGU\', \'CGC\', \'CGG\', \'GAA\', \'GAU\', \'GAC\', \'GAG\', \'GUA\', \'GUU\', \'GUC\', \'GUG\', \'GCA\', \'GCU\', \'GCC\', \'GCG\', \'GGA\', \'GGU\', \'GGC\', \'GGG\']\n+codon_alphabetT=[\'AAA\', \'AAT\', \'AAC\', \'AAG\', \'ATA\', \'ATT\', \'ATC\', \'ATG\', \'ACA\', \'ACT\', \'ACC\', \'ACG\', \'AGA\', \'AGT\', \'AGC\', \'AGG\', \'TAA\', \'TAT\', \'TAC\', \'TAG\', \'TTA\', \'TTT\', \'TTC\', \'TTG\', \'TCA\', \'TCT\', \'TCC\', \'TCG\', \'TGA\', \'TGT\', \'TGC\', \'TGG\', \'CAA\', \'CAT\', \'CAC\', \'CAG\', \'CTA\', \'CTT\', \'CTC\', \'CTG\', \'CCA\', \'CCT\', \'CCC\', \'CCG\', \'CGA\', \'CGT\', \'CGC\', \'CGG\', \'GAA\', \'GAT\', \'GAC\', \'GAG\', \'GTA\', \'GTT\', \'GTC\', \'GTG\', \'GCA\', \'GCT\', \'GCC\', \'GCG\', \'GGA\', \'GGT\', \'GGC\', \'GGG\']\n+\n+class ColorScheme(object):\n+    """ A coloring of an alphabet.\n+    \n+    title : string            -- A human readable description\n+    defualt_color : Color           --\n+    groups : list of color groups \n+    alphabet : string               -- The set of colored symbols\n+    color -- A map between a symbol and a Coloring\n+    \n+\n+    """\n+    \n+    def __init__(self, \n+                groups = [], \n+                title = "", \n+                description = "",\n+                default_color = "black", \n+                alphabet = seq.generic_alphabet) :\n+        """  """\n+        self.title= title\n+        self.description = description\n+        self.default_color = Color.from_string(default_color)\n+        self.groups = groups\n+        self.alphabet = alphabet\n+        #print >> sys.stderr, groups\n+\taltype="codons"\n+\t#print >> sys.stderr,altype\n+\t#if(alphabet==codon_alphabet):\n+\t  #print >> sys.stderr,"haleyulia it works"\n+\n+        color = {}\n+        #print >> sys.stderr, groups\n+        if(alphabet!=codon_alphabetT and alphabet!=codon_alphabetU):\n+\t  for'..b'FFFF\'),\n+\n+\n+ColorGroup( \'GAT\', \'#FF0000\'),\n+ColorGroup( \'GAU\', \'#FF0000\'),\n+ColorGroup( \'GAC\', \'#FF0000\'),\n+\n+ColorGroup( \'GAA\', \'#FF0000\'),\n+ColorGroup( \'GAG\', \'#FF0000\'),\n+\n+\n+ColorGroup( \'TCT\', \'#00FF00\'),\n+ColorGroup( \'UCU\', \'#00FF00\'),\n+ColorGroup( \'TCC\', \'#00FF00\'),\n+ColorGroup( \'UCC\', \'#00FF00\'),\n+ColorGroup( \'TCA\', \'#00FF00\'),\n+ColorGroup( \'UCA\', \'#00FF00\'),\n+ColorGroup( \'TCG\', \'#00FF00\'),\n+ColorGroup( \'UCG\', \'#00FF00\'),\n+ColorGroup( \'AGT\', \'#00FF00\'),\n+ColorGroup( \'AGU\', \'#00FF00\'),\n+ColorGroup( \'AGC\', \'#00FF00\'),\n+\n+ColorGroup( \'ACT\', \'#00FF00\'),\n+ColorGroup( \'ACU\', \'#00FF00\'),\n+ColorGroup( \'ACC\', \'#00FF00\'),\n+ColorGroup( \'ACA\', \'#00FF00\'),\n+ColorGroup( \'ACG\', \'#00FF00\'),\n+\n+ColorGroup( \'CAA\', \'#00FF00\'),\n+ColorGroup( \'CAG\', \'#00FF00\'),\n+\n+ColorGroup( \'AAT\', \'#00FF00\'),\n+ColorGroup( \'AAU\', \'#00FF00\'),\n+ColorGroup( \'AAC\', \'#00FF00\'),\n+\n+\n+ColorGroup( \'GCT\', \'#5555FF\'),\n+ColorGroup( \'GCU\', \'#5555FF\'),\n+ColorGroup( \'GCC\', \'#5555FF\'),\n+ColorGroup( \'GCA\', \'#5555FF\'),\n+ColorGroup( \'GCG\', \'#5555FF\'),\n+\n+ColorGroup( \'GTT\', \'#5555FF\'),\n+ColorGroup( \'GUU\', \'#5555FF\'),\n+ColorGroup( \'GTC\', \'#5555FF\'),\n+ColorGroup( \'GUC\', \'#5555FF\'),\n+ColorGroup( \'GTA\', \'#5555FF\'),\n+ColorGroup( \'GUA\', \'#5555FF\'),\n+ColorGroup( \'GTG\', \'#5555FF\'),\n+ColorGroup( \'GUG\', \'#5555FF\'),\n+\n+ColorGroup( \'CTT\', \'#5555FF\'),\n+ColorGroup( \'CUU\', \'#5555FF\'),\n+ColorGroup( \'CTC\', \'#5555FF\'),\n+ColorGroup( \'CUC\', \'#5555FF\'),\n+ColorGroup( \'CTA\', \'#5555FF\'),\n+ColorGroup( \'CUA\', \'#5555FF\'),\n+ColorGroup( \'CTG\', \'#5555FF\'),\n+ColorGroup( \'CUG\', \'#5555FF\'),\n+ColorGroup( \'TTA\', \'#5555FF\'),\n+ColorGroup( \'UUA\', \'#5555FF\'),\n+ColorGroup( \'TTG\', \'#5555FF\'),\n+ColorGroup( \'UUG\', \'#5555FF\'),\n+\n+ColorGroup( \'ATT\', \'#5555FF\'),\n+ColorGroup( \'AUU\', \'#5555FF\'),\n+ColorGroup( \'ATC\', \'#5555FF\'),\n+ColorGroup( \'AUC\', \'#5555FF\'),\n+ColorGroup( \'ATA\', \'#5555FF\'),\n+ColorGroup( \'AUA\', \'#5555FF\'),\n+\n+ColorGroup( \'ATG\', \'#5555FF\'),\n+ColorGroup( \'AUG\', \'#5555FF\'),\n+\n+\n+ColorGroup( \'TTT\', \'#FF00FF\'),\n+ColorGroup( \'UUU\', \'#FF00FF\'),\n+ColorGroup( \'TTC\', \'#FF00FF\'),\n+ColorGroup( \'UUC\', \'#FF00FF\'),\n+\n+ColorGroup( \'TAT\', \'#FF00FF\'),\n+ColorGroup( \'UAU\', \'#FF00FF\'),\n+ColorGroup( \'TAC\', \'#FF00FF\'),\n+ColorGroup( \'UAC\', \'#FF00FF\'),\n+\n+ColorGroup( \'TGG\', \'#FF00FF\'),\n+ColorGroup( \'UGG\', \'#FF00FF\'),\n+\n+\n+ColorGroup( \'GGT\', \'#996600\'),\n+ColorGroup( \'GGU\', \'#996600\'),\n+ColorGroup( \'GGC\', \'#996600\'),\n+ColorGroup( \'GGA\', \'#996600\'),\n+ColorGroup( \'GGG\', \'#996600\'),\n+\n+ColorGroup( \'CCT\', \'#996600\'),\n+ColorGroup( \'CCU\', \'#996600\'),\n+ColorGroup( \'CCC\', \'#996600\'),\n+ColorGroup( \'CCA\', \'#996600\'),\n+ColorGroup( \'CCG\', \'#996600\'),\n+\n+\n+ColorGroup( \'TGT\', \'#FFFF00\'),\n+ColorGroup( \'UGU\', \'#FFFF00\'),\n+ColorGroup( \'TGC\', \'#FFFF00\'),\n+ColorGroup( \'UGC\', \'#FFFF00\'),\n+\n+ColorGroup( \'TAA\', \'#000000\'),\n+ColorGroup( \'UAA\', \'#000000\'),\n+ColorGroup( \'TAG\', \'#000000\'),\n+ColorGroup( \'UAG\', \'#000000\'),\n+ColorGroup( \'TGA\', \'#000000\'),  \n+ColorGroup( \'UGA\', \'#000000\')],\n+  alphabet = codon_alphabetT\n+  )\n+\n+\n+\n+\n+charge = ColorScheme([\n+    ColorGroup("KRH", "blue", "Positive" ),\n+    ColorGroup( "DE", "red", "Negative") ],\n+    alphabet = seq.unambiguous_protein_alphabet\n+    )\n+\n+\n+taylor = ColorScheme([\n+    ColorGroup( \'A\', \'#CCFF00\' ),\n+    ColorGroup( \'C\', \'#FFFF00\' ),\n+    ColorGroup( \'D\', \'#FF0000\'),\n+    ColorGroup( \'E\', \'#FF0066\' ),\n+    ColorGroup( \'F\', \'#00FF66\'),\n+    ColorGroup( \'G\', \'#FF9900\'),\n+    ColorGroup( \'H\', \'#0066FF\'),\n+    ColorGroup( \'I\', \'#66FF00\'),\n+    ColorGroup( \'K\', \'#6600FF\'),\n+    ColorGroup( \'L\', \'#33FF00\'),\n+    ColorGroup( \'M\', \'#00FF00\'),\n+    ColorGroup( \'N\', \'#CC00FF\'),\n+    ColorGroup( \'P\', \'#FFCC00\'),\n+    ColorGroup( \'Q\', \'#FF00CC\'),\n+    ColorGroup( \'R\', \'#0000FF\'),\n+    ColorGroup( \'S\', \'#FF3300\'),\n+    ColorGroup( \'T\', \'#FF6600\'),\n+    ColorGroup( \'V\', \'#99FF00\'),\n+    ColorGroup( \'W\', \'#00CCFF\'),\n+    ColorGroup( \'Y\', \'#00FFCC\')],\n+    title = "Taylor",\n+    description = "W. Taylor, Protein Engineering, Vol 10 , 743-746 (1997)",\n+    alphabet = seq.unambiguous_protein_alphabet\n+    )\n+    \n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/create.cgi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/htdocs/create.cgi Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+#  Copyright (c) 2003-2004 The Regents of the University of California.
+#  Copyright (c) 2005 Gavin E. Crooks
+#  Copyright (c) 2006, The Regents of the University of California, through 
+#  Lawrence Berkeley National Laboratory (subject to receipt of any required
+#  approvals from the U.S. Dept. of Energy).  All rights reserved.
+
+#  This software is distributed under the new BSD Open Source License.
+#  <http://www.opensource.org/licenses/bsd-license.html>
+#
+#  Redistribution and use in source and binary forms, with or without 
+#  modification, are permitted provided that the following conditions are met: 
+#
+#  (1) Redistributions of source code must retain the above copyright notice, 
+#  this list of conditions and the following disclaimer. 
+#
+#  (2) Redistributions in binary form must reproduce the above copyright 
+#  notice, this list of conditions and the following disclaimer in the 
+#  documentation and or other materials provided with the distribution. 
+#
+#  (3) Neither the name of the University of California, Lawrence Berkeley 
+#  National Laboratory, U.S. Dept. of Energy nor the names of its contributors 
+#  may be used to endorse or promote products derived from this software 
+#  without specific prior written permission. 
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+#  POSSIBILITY OF SUCH DAMAGE. 
+
+import cgi
+import cgitb; cgitb.enable()
+import weblogolib
+
+if __name__=="__main__" :
+    weblogolib.cgi(__file__)
+
+
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/create_html_template.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/htdocs/create_html_template.html Fri Jan 13 07:18:19 2012 -0500
b
b'@@ -0,0 +1,350 @@\n+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"\n+    "http://www.w3.org/TR/html4/transitional.dtd">\n+<html>\n+<head>\n+<link rel="stylesheet" type="text/css" href="logo.css" >\n+\n+\n+<title>CodonLogo 1.0- Create </title>\n+<meta name="author" content="Gavin E. Crooks" >\n+\n+\n+<style type="text/css">\n+td {\n+    border-left : white solid 4pt\n+}\n+.error { \n+    color: #900;\n+    border-left: red solid +4pt;\n+}\n+\n+.err_msg { \n+    color: #900;\n+}\n+\n+</style>\n+</head>\n+\n+<body style="align:center">\n+\n+\n+\n+\n+\n+<form method="post" action="create.cgi" enctype="multipart/form-data" >\n+<table width="80%" border = \'0\' cellspacing=\'0\' cellpadding=\'1\' align="center">\n+<tr><td >\n+<h1> Codonlogo 1.0 : Create</h1>\n+\n+</td><td align = "right"> \n+    &middot; \n+  <a href="./">about</a>&nbsp;&middot;\n+  <a class="selected" href="create.cgi">create</a>&nbsp;&middot; \n+  <a href="examples.html">examples</a>&nbsp;&middot; \n+  <a href="manual.html">manual</a>&nbsp;&middot; \n+<br>\n+<span style="font-size:small">$version</span>&nbsp;&nbsp;\n+</td></tr>\n+\n+<tr><td >\n+Sequence data\n+</td><td > \n+<input type="file" name="sequences_file"   > \n+</td></tr>\n+\n+<tr><td >\n+</td><td> \n+<span style="font-size:small ">(or paste sequence data below)</span>\n+</td></tr>\n+\n+\n+\n+<tr><td colspan=\'2\' ${sequences_err} >\n+<textarea name="sequences" rows="12" cols ="100" style="width:100%">${sequences}</textarea>\n+</td></tr>\n+\n+\n+\n+<tr><td>\n+</td><td align="right">\n+<input  style="font-size:large" type="submit" name="cmd_create" value="&nbsp;Create&nbsp;Logo&nbsp;&nbsp;&nbsp;&nbsp;"  > <br>\n+<span style="font-size:small"><input type="checkbox" name="download" value="false" >Download</span>\n+</td></tr>\n+     \n+\n+<!-- Reset defaults must come after create_logo so that hitting enter creates a logo-->  \n+<!--\n+<tr><td>\n+<input type="submit" name="cmd_reset" value="Reset defaults" >\n+</td><td  class="err_msg" rowspan="2">\n+${error_message} &nbsp;\n+</td></tr>\n+<tr><td>&nbsp;</td></tr>\n+-->\n+\n+<tr><td colspan=\'2\' style="height:30pt;border-left-width:90pt;" class="err_msg">\n+${error_message}\n+</td></tr>\n+\n+    \n+     \n+<tr><td ${format_err} >\n+Output format </td><td>\n+<select name="format">\n+<option ${png} value="png">PNG (low res.)</option>\n+<option ${png_print} value="png_print">PNG (high res.)</option>\n+<option ${jpeg} value="jpeg">JPEG (low res.)</option>\n+<option ${eps} value="eps">EPS (vector)</option>\n+<option ${pdf} value="pdf">PDF (vector)</option>\n+<option ${txt} value="txt">Data (plain text)</option> \n+</select> \n+\n+</td></tr>\n+\n+<tr><td ${size_err} >\n+Logo size \n+</td><td >\n+<select name="size" >\n+<option ${small} >small</option>\n+<option ${medium}>medium</option>\n+<option ${large} >large</option>\n+</select> \n+</td></tr>\n+\n+\n+<tr><td ${stacks_per_line_err}>\n+    Stacks per line\n+</td><td>\n+<input type="text" name="stacks_per_line" value="${stacks_per_line}" size="4" maxlength="4" >\n+</td></tr>\n+\n+<tr><td ${alphabet_err}>\n+Sequence type </td><td>\n+\n+<select name="alphabet">\n+<option ${alphabet_auto} value="alphabet_auto" >auto</option>\n+<option ${alphabet_protein} value="alphabet_protein">protein</option>\n+<option ${alphabet_dna} value="alphabet_dna">dna</option>\n+<option ${alphabet_rna} value="alphabet_rna">rna</option>\n+</select> \n+</td></tr>\n+\n+<tr><td>\n+Ignore lower case\n+</td><td>\n+<input type="checkbox" name="ignore_lower_case" value="true" ${ignore_lower_case} > \n+</td></tr>\n+\n+<tr><td>\n+Use codons:\n+</td><td>\n+<input type="checkbox" name="altype" value="true" ${altype} > \n+</td></tr>\n+\n+\n+<tr><td>\n+Units </td><td>\n+<select name="unit_name"  >\n+<option ${probability} >probability</option>\n+<option ${bits} >bits</option>\n+<option ${nats} >nats</option>\n+<option ${kT} >kT</option>\n+<option ${kJ_mol} >kJ/mol</option>\n+<option ${kcal_mol} >kcal/mol</option>\n+</select> \n+\n+</td></tr>\n+\n+<tr><td ${first_index_err}>\n+First position number\n+</td><td>\n+<input  type="text" name="first_index" value="${first_index}" size="4" maxlength="80" >\n+</td></tr>\n+\n+<tr'..b'true" ${show_yaxis} > \n+Label: <input type="text" name="yaxis_label" value="${yaxis_label}" size="20" maxlength="32" >  \n+\n+</td></tr>\n+\n+<tr><td ${yaxis_scale_err} >\n+Y-axis scale:\n+</td><td>\n+<input type="text" name="yaxis_scale"  value="${yaxis_scale}" size="4" maxlength="100"  > \n+</td></tr>\n+\n+ <tr><td ${yaxis_tic_interval_err} >\n+Y-axis tic spacing:\n+</td><td>\n+<input type="text" name="yaxis_tic_interval" value="${yaxis_tic_interval}"  size="4" maxlength="100"  > \n+</td></tr>\n+\n+\n+\n+<tr><td>\n+Sequence end labels\n+</td><td>\n+<input type="checkbox" name="show_ends" value="true" ${show_ends} > \n+</td></tr>\n+  \n+<tr><td>\n+Version fineprint \n+  </td><td>\n+<input type="checkbox" name="show_fineprint" value="true" ${show_fineprint} >\n+</td></tr>\n+\n+\n+\n+\n+<tr><td  ${color_scheme_err}>Color scheme\n+</td><td>\n+<select name="color_scheme"  >\n+<option ${color_auto} value="color_auto">Auto</option>\n+<option ${color_monochrome} value="color_monochrome" >Monochrome</option>\n+<option ${color_base_pairing} value="color_base_pairing">Base pairing (NA default)</option>\n+<option ${color_classic} value="color_classic">Classic (NA)</option>\n+<option ${color_hydrophobicity} value="color_hydrophobicity">Hydrophobicity (AA default)</option>\n+<option ${color_chemistry} value="color_chemistry">Chemistry (AA)</option>\n+<option ${color_charge} value="color_charge">Charge (AA)</option>\n+<option ${color_custom} value="color_custom">Custom (Specify below)</option>\n+</select> \n+<!--&nbsp; Color key:\n+<input type="checkbox" name="show_color_key" value="true" ${show_color_key} disabled >\n+-->\n+</td></tr>\n+\n+<tr><td></td><td>\n+<table cellpadding="0" cellspacing="0"  style="font-size:small">\n+<tr>\n+<td>Symbols</td><td>Color</td> <!--<td>Description</td>-->\n+</tr>\n+\n+<tr >\n+<td ${color0_err}><input name="symbols0" type="text"  size="16" maxlength="64" value="${symbols0}"></td>\n+<td><input name="color0" type="text"  size="16" maxlength="64"  value="${color0}"></td>\n+<!--<td><input name="desc0"  size="16" maxlength="64"  value="${desc0}"></td> -->\n+</tr>\n+\n+<tr >\n+<td ${color1_err}><input name="symbols1" type="text"  size="16" maxlength="64" value="${symbols1}"></td>\n+<td><input name="color1" type="text"  size="16" maxlength="64"  value="${color1}"></td>\n+<!--<td><input name="desc1"  size="16" maxlength="64"  value="${desc1}"></td>-->\n+</tr>\n+\n+<tr>\n+<td ${color2_err}><input name="symbols2" type="text"  size="16" maxlength="64" value="${symbols2}"></td>\n+<td><input name="color2" type="text"  size="16" maxlength="64"  value="${color2}"></td>\n+<!--<td><input name="desc2"  size="16" maxlength="64"  value="${desc2}"></td>-->\n+</tr>\n+\n+<tr>\n+<td ${color3_err}><input name="symbols3" type="text"  size="16" maxlength="64" value="${symbols3}"></td>\n+<td><input name="color3" type="text"  size="16" maxlength="64"  value="${color3}"></td>\n+<!--<td><input name="desc3"  size="16" maxlength="64"  value="${desc3}"></td>-->\n+</tr>\n+\n+<tr>\n+<td ${color4_err}><input name="symbols4" type="text"  size="16" maxlength="64" value="${symbols4}"></td>\n+<td><input name="color4" type="text"  size="16" maxlength="64"  value="${color4}"></td>\n+<!--<td><input name="desc4"  size="16" maxlength="64"  value="${desc4}"></td>-->\n+</tr>\n+\n+\n+\n+</table>\n+</td></tr>\n+\n+ <tr><td>\n+&nbsp; \n+</td><td>\n+&nbsp;\n+</td></tr>\n+      \n+<tr><td>\n+<input type="submit" name="cmd_reset" value="Reset defaults" >\n+</td><td align="right">\n+<input  style="font-size:large" type="submit" name="cmd_create" value="&nbsp;Create&nbsp;Logo&nbsp;&nbsp;&nbsp;&nbsp;"  >\n+</td></tr>\n+     \n+     \n+\n+\n+</table>\n+</form>\n+\n+<script type="text/javascript">\n+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");\n+document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));\n+</script>\n+<script type="text/javascript">\n+var pageTracker = _gat._getTracker("UA-5951066-1");\n+pageTracker._trackPageview();\n+</script>\n+</body>\n+</html>\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/examples.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/htdocs/examples.html Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,2210 @@\n+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"\n+    "http://www.w3.org/TR/html4/transitional.dtd">\n+ \n+<html>\n+<head>\n+<link rel="stylesheet" type="text/css" href="logo.css" >\n+<title>CodonLogo - Examples</title>\n+<meta name="author" content="Gavin E. Crooks" >\n+<meta name="author" content="Steven E. Brenner" >\n+<meta name="ID" content="$ID:" >\n+\n+<style type="text/css">\n+img {\n+    display: block;\n+    margin-left: auto;\n+    margin-right: auto }\n+\n+</style>\n+</head>\n+\n+<body>\n+\n+<table width="80%" border = \'0\' cellspacing=\'0\' cellpadding=\'1\' align="center">\n+<tr><td >\n+<h1> CodonLogo 1.0: Examples</h1>\n+\n+</td><td align = "right"> \n+    &middot; \n+  <a href="./">about</a>&nbsp;&middot;\n+  <a href="create.cgi">create</a>&nbsp;&middot; \n+  <a class="selected" href="examples.html">examples</a>&nbsp;&middot; \n+  <a href="manual.html">manual</a>&nbsp;&middot; \n+<br>\n+&nbsp;\n+</td></tr>\n+\n+\n+<tr><td colspan="2" class="discourse" >\n+\n+<ul>\n+  <li> <a href="#CAP">CAP HTH motif</a> </li>\n+ <li>  <a href="#trans">Transcription Factors</a> </li>\n+  <li> <a href="#promoters"><i>E. coli</i> Promoters</a> </li> \n+  <li> <a href="#globins">Globins</a>  </li>\n+  <li> <a href="#HTH">HTH motif</a>  </li>\n+  <li> <a href="#splice">Splice Signals</a> </li> \n+</ul>\n+<p> \n+The <strong>Edit Logo</strong> buttons will transfer the relevant\n+sequence data to the <a class="in" href="create.cgi">Logo creation form</a>. \n+There you can examine the sequence data and recreate the logo for \n+yourself. \n+<!--Additional examples can be found at the \n+<a href="http://www.lecb.ncifcrf.gov/~toms/sequencelogo.html">Sequence Logo\n+Gallery</a>.-->\n+</p>\n+\n+\n+<!--<hr >\n+<a name="CAP"></a>\n+<a name="CAP_HTH"></a>\n+<h2>Catobolite Activator Protein (CAP)</h2>\n+\n+<img  alt="Catobolite Activator Protein (CAP) Logo"  src="examples/cap_hth.png">\n+<p>\n+The helix-turn-helix motif from the CAP family of homodimeric DNA\n+binding proteins.  CAP (Catabolite Activator Protein, also known as\n+CRP for cAMP Receptor Protein) is a transcription promoter that binds\n+at more than 100 sites within the <i>E.&nbsp;coli</i> genome.  Residues 1-7\n+form the first helix, 8-11 the turn and 12-20 form the DNA recognition\n+helix.  The glycine at position 9 appears to be\n+critical in forming the turn.  Positions 4, 8, 10, 15 and 19 are\n+partially or completely buried, and therefore tend to be populated by\n+hydrophobic amino acids, which are colored black.  Positions 11-14, 17\n+and 20 interact directly with bases in the major groove\n+and are critical to the sequence specific binding of the\n+protein.  The data for this logo consists of 100 sequences from the\n+full Pfam alignment of this family (Accession number\n+PF00325).  A few sequences with rare insertions were removed for\n+convenience.  \n+</p>-->\n+\n+<!--\n+# Pfam 7.1 crp\n+# Accession number: PF00325\n+# Bacterial regulatory proteins, crp family\n+#\n+# Description \n+# Numerous bacterial transcription regulatory\n+#  proteins bind DNA via a helix-turn-helix (HTH)\n+# motif. These proteins are very diverse, but \n+# for convenience may be grouped into subfamilies on\n+# the basis of sequence similarity. One such \n+# family groups together a range of proteins, including\n+# anr, crp, clp, cysR, fixK, flp, fnr, fnrN, hlyX and \n+# ntcA [MEDLINE:91064083], [MEDLINE:93181282], \n+# [MEDLINE:91008963]. Within this family, the HTH motif is situated\n+# towards the C-terminus.                      \n+# This is the full Pfam alignment, less a couple of inserts\n+# 102 sequences.\n+#\n+# http://pfam.wustl.edu/cgi-bin/getdesc?name=crp\n+#\n+# Introduction to protein structure, 1st edition, contains\n+# some more information.\n+# First number is sequence number is -5\n+# First Helix: 1-7, Turn: 8-11, 2nd (DNA recognition) 12-20\n+#\n+-->\n+\n+<!--\n+<form method="post" action="create.cgi">\n+<input type="submit" name="cmd_edit" value="Edit Logo" >\n+<input type="hidden" name="logo_title" value="The DNA-binding helix-turn-helix motif of the CAP family" >\n+<inp'..b'34_AB001523\n+tctcgtttctttctgtttaagCCAACACAGCTCAGAGTCC\n+> 45334_AB001523\n+tgtgtttttacttccccacagGATTTGTCCCATGCCACCA\n+> 45334_AB001523\n+actgtttgttgactttgcaagGAGGAAAAAGGCTCCACAA\n+> 45334_AB001523\n+ctccttacctctccgctccagCTACCTGCAGACCAGCAGC\n+> 45334_AB001523\n+tacgataatgtctatttacagGTCATAAGATAGTGCTACC\n+> 45334_AB001523\n+tgcctgattctttgactctagGCCAAGGAACCTGGAACGT\n+> 45334_AB001523\n+ccacgatctcttttcctttagATAGCCTTCTGGCAGGCAT\n+> 45334_AB001523\n+gactttttctgtccttcgtagAACAGTCTTCTGAGGCCGC\n+> 45334_AB001523\n+gtctttgtgcttcctcctcagGTGTCGATTGACTGCCCGT\n+> 45334_AB001523\n+ctttttgtttttccactttagGAAATATGTTCAAGTTTGT\n+> 45334_AB001523\n+gacccccaactctctttccagCCCATCTACAGCAAGCAGT\n+> 45334_AB001523\n+ttctctccctttcctgcccagACATTATACAACGTGAAGG\n+> 45334_AB001523\n+catcgcttcctctcgtttcagTTGTCGACAACAGTAGCAA\n+> 45334_AB001523\n+aacttcctgtgtgttttgcagACAGCTGGATAGAAAACGA\n+> 45335_AB001523\n+acaattttgttttcttcacagTTTTCAAATTTGCTGGGTA\n+> 45337_AB00189S\n+ttgtgtctttcgtgcttacagCATTGTGGCGACAAGAACA\n+> 45337_AB00189S\n+caccacgattccatttcttagGATTCCTACGCCAGCTACG\n+> 45337_AB00189S\n+tggttttttcctttgtttcagACACGGCACTCGTTGTGCG\n+> 45338_AB00189S\n+ttgtgtctttcgtgcttacagCATTGTGGCGACAAGAACA\n+> 45338_AB00189S\n+caccacgattccatttcttagGATTCCTACGCCAGCTACG\n+> 45338_AB00189S\n+tggttttttcctttgtttcagACACGGCACTCGTTGTGCG\n+> 45338_AB00189S\n+aatgcattctttacccattagGTGATCTTGAGACTCCTGT\n+> 45339_AB00189S\n+ttgtgtctttcgtgcttacagCATTGTGGCGACAAGAACA\n+> 45339_AB00189S\n+caccacgattccatttcttagGATTCCTACGCCAGCTACG\n+> 45339_AB00189S\n+tggttttttcctttgtttcagACACGGCACTCGTTGTGCG\n+> 45339_AB00189S\n+aatgcattctttacccattagGTGATCTTGAGACTCCTGT\n+> 45340_AB00189S\n+ttgtgtctttcgtgcttacagCATTGTGGCGACAAGAACA\n+> 45340_AB00189S\n+caccacgattccatttcttagGATTCCTACGCCAGCTACG\n+> 45340_AB00189S\n+tggttttttcctttgtttcagACACGGCACTCGTTGTGCG\n+> 45341_AB00189S\n+ttgtgtctttcgtgcttacagCATTGTGGCGACAAGAACA\n+> 45341_AB00189S\n+caccacgattccatttcttagGATTCCTACGCCAGCTACG\n+> 45341_AB00189S\n+tggttttttcctttgtttcagACACGGCACTCGTTGTGCG\n+> 45341_AB00189S\n+ctcctgcctttgctcctacagGAAGTGCGTGAGTGTGTGC\n+> 45342_AB00189S\n+ttgtgtctttcgtgcttacagCATTGTGGCGACAAGAACA\n+> 45342_AB00189S\n+caccacgattccatttcttagGATTCCTACGCCAGCTACG\n+> 45342_AB00189S\n+tggttttttcctttgtttcagACACGGCACTCGTTGTGCG\n+> 45342_AB00189S\n+-ggcaatttgcactcacacagCTCAATCCACCCCAGGCTC\n+> 45342_AB00189S\n+ctcctgcctttgctcctacagGAAGTGCGTGAGTGTGTGC\n+> 45342_AB00189S\n+aggaacggtatcttcccacagGTGTGACGAGAACTGCTTG\n+> 45342_AB00189S\n+tttcctgatgcggggccccagCTGACGAGACATTCTGCGA\n+> 45343_AB00189S\n+ttgtgtctttcgtgcttacagCATTGTGGCGACAAGAACA\n+> 45343_AB00189S\n+caccacgattccatttcttagGATTCCTACGCCAGCTACG\n+> 45343_AB00189S\n+tggttttttcctttgtttcagACACGGCACTCGTTGTGCG\n+> 45343_AB00189S\n+ctcctgcctttgctcctacagGAAGTGCGTGAGTGTGTGC\n+> 45343_AB00189S\n+aggaacggtatcttcccacagGTGTGACGAGAACTGCTTG\n+> 45343_AB00189S\n+tttcctgatgcggggccccagCTGACGAGACATTCTGCGA\n+> 45344_AB00189S\n+ttgtgtctttcgtgcttacagCATTGTGGCGACAAGAACA\n+> 45344_AB00189S\n+caccacgattccatttcttagGATTCCTACGCCAGCTACG\n+> 45344_AB00189S\n+tggttttttcctttgtttcagACACGGCACTCGTTGTGCG\n+> 45344_AB00189S\n+-ggcaatttgcactcacacagCTCAATCCACCCCAGGCTC\n+> 45344_AB00189S\n+ctcctgcctttgctcctacagGAAGTGCGTGAGTGTGTGC\n+> 45345_AB002059\n+tgcccgacttctcctccccagGTGGGCGCTCCTCGCCAAA\n+> 45345_AB002059\n+accttgagacttgcctcctagGGAGAGAACGTGTTCTTCT\n+> 45345_AB002059\n+ctgctctctctcccacctcagCACCCGTCCGTCCCACTGG\n+> 45345_AB002059\n+agttcatcttttgttttctagGTGTAAAAACAGGCCAGTG\n+> 45345_AB002059\n+tcacctcccttccacctgcagGAGGCCCCTGCTGGCCCAG\n+> 45345_AB002059\n+gacctttcccactcctcccagGTCCAATGCCTTGGAGACC\n+> 45345_AB002059\n+aaagctatgtgctatgtgcagGGTGGCTCTGTAGGCATCA\n+> 45345_AB002059\n+agccttctttcctgcccacagGACAGCCACTCACTGGTGG\n+" >\n+</form>-->-->\n+\n+</td></tr>\n+\n+\n+\n+\n+\n+</table>\n+\n+<script type="text/javascript">\n+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");\n+document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));\n+</script>\n+<script type="text/javascript">\n+var pageTracker = _gat._getTracker("UA-5951066-1");\n+pageTracker._trackPageview();\n+</script>\n+</body></html>\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/img/example.png
b
Binary file weblogolib/htdocs/img/example.png has changed
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/img/feed-icon-16x16.png
b
Binary file weblogolib/htdocs/img/feed-icon-16x16.png has changed
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/img/weblogo-fig1.png
b
Binary file weblogolib/htdocs/img/weblogo-fig1.png has changed
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/img/weblogo_create.png
b
Binary file weblogolib/htdocs/img/weblogo_create.png has changed
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/index.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/htdocs/index.html Fri Jan 13 07:18:19 2012 -0500
[
@@ -0,0 +1,135 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+    "http://www.w3.org/TR/html4/transitional.dtd">
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="logo.css" >
+<title>CodonLogo - About</title>
+<meta name="author" content="Gavin E. Crooks" >
+</head>
+
+<body style="align: center">
+
+
+
+
+<table width="80%" border = '0' cellspacing='0' cellpadding='1' align="center">
+<tr><td >
+<h1>CodonLogo 1.0</h1>
+
+</td><td align = "right"> 
+    &middot; 
+  <a class="selected" href="./">about</a>&nbsp;&middot;
+  <a href="create.cgi">create</a>&nbsp;&middot; 
+  <a href="examples.html">examples</a>&nbsp;&middot; 
+  <a href="manual.html">manual</a>&nbsp;&middot; 
+<br>
+<span style="font-size:small">&nbsp;</span>&nbsp;&nbsp;
+
+</td></tr>
+
+
+
+<tr><td colspan="2" style="font-size:small">
+   <a href="examples.html"><img
+   alt="CodonLogo" width="284" height="359"
+   src="img/Replacethis1.png" align="right" vspace="40" hspace="10"></a>
+
+
+<h3>Introduction</h3>
+<p>
+Codonlogo is based on <a href="http://weblogo.berkeley.edu/">WebLogo</a>,a web based application designed to make the 
+generation of sequence logos easy and painless.CodonLogo Extends Weblogo to allow generation of sequence logos with codons rather than amino acids or nucleotides.
+ </p>
+
+<p>
+<a href="http://www.lecb.ncifcrf.gov/~toms/sequencelogo.html">Sequence&nbsp;logos</a> are a graphical representation of an amino acid
+or nucleic acid multiple sequence alignment developed by 
+<a href="http://www.lecb.ncifcrf.gov/~toms/schneider.html">Tom Schneider</a>
+ and <a href="http://www.lecb.ncifcrf.gov/~toms/sipinfo.html">Mike
+ Stephens</a>.
+Each logo consists of stacks of symbols, one stack for each position in the
+sequence. The overall height of the stack indicates the sequence conservation
+at that position, while the height of symbols within the stack indicates the
+relative frequency of each codon at that position. In general,
+a sequence logo provides a richer and more precise description of, for example,
+a binding site, than would a consensus sequence. 
+</p>
+
+<ul> 
+<li><a href="create.cgi">Create your own logos </a>
+</li><li><a href="examples.html">View example sequence logos and input data.</a>
+</li><li><a href="manual.html">Read the User's Manual</a>
+</li><li> <a href="http://code.google.com/p/weblogo/"> Download WebLogo source code</a> 
+</li><li>  <a href="http://groups.google.com/group/WebLogo">WebLogo discussion group</a> 
+</li>
+</ul>

+
+<h3>References</h3>
+
+
+<p>
+<small>
+<a href="http://bespoke.lbl.gov/">Crooks GE</a>, 
+<a href="http://compbio.berkeley.edu/">Hon G</a>, 
+<a href="http://compbio.berkeley.edu/">Chandonia JM</a>,
+<a href="http://compbio.berkeley.edu/people/brenner/">Brenner SE</a> 
+CodonLogo: A sequence logo 
+generator, <br >
+<em>Genome Research</em>, 14:1188-1190, (2004) 
+[<a href="http://bespoke.lbl.gov/pubs/fulltext/Crooks2004a-GR-WebLogo.pdf">Full Text</a> ]
+</small>
+</p>
+
+<p>
+<small>
+Schneider TD, Stephens RM. 1990.
+<a class="out" href="http://www.lecb.ncifcrf.gov/~toms/paper/logopaper/">Sequence Logos: A New Way to Display Consensus Sequences.</a>
+<em>Nucleic Acids Res.</em> <em>18</em>:6097-6100
+</small>
+</p>
+
+
+
+
+
+<h3>Disclaimer</h3>
+
+<p>
+While no permanent records are kept of submitted sequences, we cannot 
+undertake to guarantee that data sent to CodonLogo remains secure. Moreover,
+no guarantees whatsoever are provided about data generated by CodonLogo. 
+</p>
+
+
+
+<h3>Feedback</h3>
+<p>
+Suggestions on how to improve CodonLogo are heartily welcomed! 
+Please direct questions to murphy.david@gmail.com 
+</p>
+
+</td></tr>
+
+
+
+</table>
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+var pageTracker = _gat._getTracker("UA-5951066-1");
+pageTracker._trackPageview();
+</script>a
+</body>
+</html>
+
+
+
+
+
+
+
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/logo.css
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/htdocs/logo.css Fri Jan 13 07:18:19 2012 -0500
b
@@ -0,0 +1,67 @@
+
+/*
+   Logo Cascading Style Sheet
+*/
+
+body {
+  font-family: sans-serif;
+  color: black;
+  background: white;
+}
+a:link { color: #369; background: transparent }
+a:visited { color: #066; background: transparent }
+a:active { color: #C00; background: transparent }
+
+a.selected:visited { 
+  color: #000;
+  background: #EEE;
+  text-decoration: none;
+}
+
+li {margin-bottom: 0.5em}
+
+
+th, td { /* ns 4 */
+  font-family: sans-serif;
+}
+
+h1, h2, h3, h4, h5, h6 { text-align: left }
+h1  { color: #900 }
+h1 { text-align: left }
+h1 { font: 170% sans-serif}
+h2 { font: bold 140% sans-serif }
+h3 { font: bold 120% sans-serif }
+h4 { font: bold 100% sans-serif }
+h5 { font: italic 100% sans-serif }
+h6 { font: small-caps 100% sans-serif }
+
+h2 { margin-top: 2em}
+h4 { margin-bottom: 0.2em}
+
+.discourse {
+    font-size: small
+    }
+
+
+p {text-align: justify; margin-top: 0em}
+p.copyright { font-size: small; text-align: center }
+
+pre { margin-left: 2em ; }
+
+dt, dd { margin-top: 0; margin-bottom: 0 } /* opera 3.50 */
+dt { font-weight: bold }
+
+/* navigator 4 requires this */
+pre, code { 
+            font-family: monospace ; 
+          
+} 
+
+
+
+
+
+
+
+
+
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/manual.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/htdocs/manual.html Fri Jan 13 07:18:19 2012 -0500
[
b'@@ -0,0 +1,576 @@\n+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"\n+    "http://www.w3.org/TR/html4/transitional.dtd">\n+<html>\n+<head>\n+<link rel="stylesheet" type="text/css" href="logo.css" >\n+<title>CodonLogo - User\'s Manual</title>\n+<meta name="author" content="Gavin E. Crooks" >\n+\n+<style type="text/css">\n+</style>\n+</head>\n+\n+<body style="align:center">\n+\n+<table width="80%" border = \'0\' cellspacing=\'0\' cellpadding=\'1\' align="center">\n+<tr><td >\n+<h1>CodonLogo 1.0: User\'s Manual</h1>\n+\n+</td><td align = "right" > \n+    &middot; \n+  <a href="./">about</a>&nbsp;&middot;\n+  <a href="create.cgi">create</a>&nbsp;&middot; \n+  <a href="examples.html">examples</a>&nbsp;&middot; \n+  <a class="selected" href="manual.html">manual</a>&nbsp;&middot; \n+<br>\n+<span style="font-size:small">&nbsp;</span>&nbsp;&nbsp;\n+\n+</td></tr>\n+\n+<tr><td colspan="2" class="discourse">\n+\n+<h4>Contents</h4>\n+\n+<img alt="Sequence logo example." \n+\t  src="img/example.png"  align="right" vspace="5" hspace="10">\n+<!--\n+<img alt="WebLogo: Create" width="499" height="633"\n+\t  src="img/weblogo_create.png" align="right" border=\'1\' vspace="10" hspace="10"></a>\n+-->\n+\n+<ul>\n+<li><a href="#intro">Introduction</a>\n+</li><li><a href="#create">Creating Sequences Logos using the Web interface</a>\n+</li><li><a href="#download">Downloading and Installing CodonLogo</a>\n+</li><li><a href="#CLI"> Command Line Interface (CLI)</a>\n+</li><li><a href="#API"> Application Programmer Interface (API)</a>\n+</li><li><a href="#dev"> Development and Future Features</a>\n+</li><li><a href="#misc">Miscellanea</a>\n+</li>\n+</ul>\n+\n+\n+<a name="intro" ></a><h2>Introduction</h2>\n+\n+\n+<p>\n+<strong>CodonLogo</strong>\n+is a web based application designed to make the \n+<a href="create.cgi">generation</a> of \n+codon sequence logos as easy and painless as possible.\n+It is almost entirely based on the application WebLogo.\n+</p>\n+\n+\n+<p>\n+<a href="http://www.lecb.ncifcrf.gov/~toms/sequencelogo.html">Sequence&nbsp;logos</a> \n+are a graphical representation of an amino acid\n+or nucleic acid multiple sequence alignment.\n+Each logo consists of stacks of symbols, one stack for each position in the\n+sequence. The overall height of the stack indicates the sequence conservation\n+at that position, while the height of symbols within the stack indicates the\n+relative frequency of each amino or nucleic acid at that position. The width of the stack is proportional to the fraction of valid symbols in that position. (Positions with many gasp have thin stacks.)  In general, a sequence logo provides a richer and more precise description of, for example,\n+a binding site, than would a consensus sequence. \n+</p>\n+\n+\n+\n+\n+\n+\n+\n+<!-- ============================================================== -->\n+\n+<h4>References</h4>\n+\n+\n+<p>\n+<a href="http://bespoke.lbl.gov/">Crooks GE</a>, \n+<a href="http://compbio.berkeley.edu/">Hon G</a>, \n+<a href="http://compbio.berkeley.edu/">Chandonia JM</a>,\n+<a href="http://compbio.berkeley.edu/people/brenner/">Brenner SE</a> \n+WebLogo: A sequence logo \n+generator, \n+<em>Genome Research</em>, 14:1188-1190, (2004) \n+[<a href="http://bespoke.lbl.gov/pubs/fulltext/Crooks2004a-GR-WebLogo.pdf">Full Text</a> ]\n+</p>\n+\n+<p>\n+Schneider TD, Stephens RM. 1990.\n+<a class="out" href="http://www.lecb.ncifcrf.gov/~toms/paper/logopaper/">Sequence Logos: A New Way to Display Consensus Sequences.</a>\n+<em>Nucleic Acids Res.</em> <em>18</em>:6097-6100\n+</p>\n+\n+\n+\n+\n+\n+\n+\n+<a name="create" ></a>\n+<h2>Creating Sequences Logos using the Web interface</h2>\n+\n+\n+<h4>Sequence Data</h4>\n+Enter your multiple sequence alignment here, or select a file to upload. Supported file formats include CLUSTALW, FASTA, plain flatfile, MSF, NBRF, PIR, NEXUS and PHYLIP.  All sequences must be the same length, else CodonLogo will return an error and report the first sequence that differed in length from previous sequences.\n+\n+<h4>Output format</h4>\n+\n+<ul>\n+<li> PNG : (600 DPI) Print resolution bitmap\n+</li><li> PNG :  (low res,'..b'      antialiased.\n+\t       --scale-width YES/NO     Scale the visible stack width by the fraction\n+\t                                of symbols in the column?  (i.e. columns with\n+\t                                many gaps of unknowns are narrow.)  (default:\n+\t                                yes)\n+\t       --debug YES/NO           Output additional diagnostic information.\n+\t                                (default: False)\n+\n+\t  CodonLogo Server:\n+\t    Run a standalone webserver on a local port.\n+\n+\t       --serve                  Start a standalone CodonLogo server for creating\n+\t                                sequence logos.\n+\t       --port PORT              Listen to this local port. (Default: 8080)\n+</pre >\n+<!-- ===================================================================== -->\n+<a name="API" ></a>\n+<h2>WebLogo Application Programmer Interface (API)</h2>\n+\n+The WebLogo python libraries provide even greater flexibility than the command line client. The code is split between two principle packages, <code>weblogo</code> itself, which contains specialized sequence logo generation code, and <code>corebio</code>, a package that contains code of more general utility. \n+Please consult the  <a href="http://weblogo.googlecode.com/svn/trunk/apidocs/index.html">WebLogo</a> and  <a href="http://corebio.googlecode.com/svn/tags/0.5.0/apidocs/index.html">CoreBio</a> API documentation.\n+\n+\n+\n+<!-- ================================================================== -->\n+<a name="dev" ></a>\n+<h2>WebLogo Development and Future Features</h2>\n+<p>\n+The development project is hosted at \n+<a href="http://code.google.com/p/weblogo/">http://code.google.com/p/weblogo</a>.\n+\n+If you wish to extend WebLogo or to contribute code, then you should download the full source code development package directly from the subversion repository.\n+</p>\n+<pre>\n+&gt; svn checkout http://weblogo.googlecode.com/svn/trunk/ weblogo\n+&gt;  cd weblogo\n+&gt; ./weblogo &lt; cap.fa &gt; cap.eps\n+</pre>\n+<p>\n+Please consult the developer notes, <code>DEVELOPERS.txt</code> and  software license <code>LICENSE.txt</code>\n+</p>\n+\n+<p> Outstanding bugs and feature requests are listed on the <a href="http://code.google.com/p/weblogo/issues/list">WebLogo issue tracker.</a>\n+</p>\n+\n+<a name="misc" ></a>\n+<h2>Miscellanea</h2>\n+<h4> Release Notes and Known Bugs</h4>\n+The <a href="weblogo_changelog.txt">WebLogo release notes</a> detail changes to WebLogo and known issues with particular versions.\n+\n+<h4>WebLogo 2</h4>\n+The legacy WebLogo 2 sever can be found <a href="http://weblogo.berkeley.edu/">here.</a>\n+\n+\n+\n+<h4>Acknowledgments</h4>\n+\n+<p>\n+WebLogo was created by  \n+<a href="http://threeplusone.com/">Gavin E. Crooks</a>, \n+<a href="http://compbio.berkeley.edu/">Liana Lareau</a>,\n+<a href="http://compbio.berkeley.edu/">Gary Hon</a>, \n+<a href="http://compbio.berkeley.edu/">John-Marc Chandonia</a> and\n+<a href="http://compbio.berkeley.edu/people/brenner/">Steven E. Brenner</a>.\n+<a href="weblogo_changelog.txt">Many others</a> have provided suggestions, bug fixes and moral support.\n+</p>\n+\n+<p>\n+WebLogo was originally based upon the programs \n+<a href="http://www.lecb.ncifcrf.gov/~toms/delila/alpro.html">alpro</a> and \n+<a href="http://www.lecb.ncifcrf.gov/~toms/delila/makelogo.html">makelogo</a>, \n+both of which are part of Tom Schneider\'s \n+<a href="http://www.lecb.ncifcrf.gov/~toms/delila.html">delila</a> package. Many thanks\n+are due to him for making this software freely available and for encouraging its use. \n+</p>\n+\n+\n+\n+\n+\n+</td></tr>\n+</table>\n+\n+\n+<script type="text/javascript">\n+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");\n+document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));\n+</script>\n+<script type="text/javascript">\n+var pageTracker = _gat._getTracker("UA-5951066-1");\n+pageTracker._trackPageview();\n+</script>\n+</body>\n+</html>\n+\n+\n+\n+\n+\n+\n+\n+\n+\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/htdocs/test.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/htdocs/test.html Fri Jan 13 07:18:19 2012 -0500
b
b'@@ -0,0 +1,543 @@\n+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"\n+    "http://www.w3.org/TR/html4/transitional.dtd">\n+<html>\n+<head>\n+<link rel="stylesheet" type="text/css" href="logo.css" >\n+\n+<title>CodonLogo - Tests </title>\n+<meta name="author" content="Gavin E. Crooks" >\n+<meta name="ID" content="$ID:" >\n+\n+<style type="text/css">\n+td {\n+    border-left : white solid 4pt\n+}\n+.error { \n+    color: #900;\n+    border-left: red solid +4pt;\n+}\n+\n+.err_msg { \n+    color: #900;\n+}\n+\n+</style>\n+</head>\n+\n+<body style="align:center">\n+\n+\n+<table width="80%" border = \'0\' cellspacing=\'0\' cellpadding=\'1\' align="center">\n+<tr><td >\n+<h1> CodonLogo: Tests</h1>\n+\n+</td><td align = "right"> \n+    &middot; \n+  <a href="./">about</a>&nbsp;&middot;\n+  <a href="create.cgi">create</a>&nbsp;&middot; \n+  <a href="examples.html">examples</a>&nbsp;&middot; \n+  <a href="manual.html">manual</a>&nbsp;&middot; \n+<br>\n+&nbsp;\n+</td></tr>\n+\n+<tr><td colspan=\'2\'>\n+\n+Various tests of the CodonLogo webapp. <br >\n+\n+<hr >\n+\n+<dl>\n+<dt>Relative Entropy Test</dt>\n+<dd>\n+The entropy should be 2 bits, 1 bit, 0 bits\n+(The small sample correction should be turned off.) \n+<br >\n+<form method="post" action="create.cgi">\n+<input type="submit" name="cmd_edit" value="Edit" >\n+<input type="submit" name="cmd_create" value="Create" >\n+<input type="hidden" name="show_yaxis" value="true" >\n+<input type="hidden" name="show_xaxis" value="true" >\n+<input type="hidden" name="show_fineprint" value="true" >\n+<input type="hidden" name="show_errorbars" value="true" >\n+<input type="hidden" name="download" value="true" >\n+<input type="hidden" name="composition" value="comp_none" >\n+\n+<input type="hidden" name="sequences" value=\n+">\n+GTTGTTGTTGTT\n+>\n+GTCGTCGTCGTC\n+>\n+GGGGGGGGGGGG\n+>\n+GGAGGAGGAGGA\n+" >\n+</form>\n+</dd>\n+\n+\n+<dt>Title And Labels Test</dt>\n+<dd>\n+Replace and display x-label, y-label and title. \n+<form method="post" action="create.cgi">\n+<input type="submit" name="cmd_edit" value="Edit" >\n+<input type="submit" name="cmd_create" value="Create" >\n+<input type="hidden" name="show_yaxis" value="true" >\n+<input type="hidden" name="show_xaxis" value="true" >\n+<input type="hidden" name="show_fineprint" value="true" >\n+<input type="hidden" name="show_errorbars" value="true" >\n+<input type="hidden" name="download" value="true" >\n+\n+<input type="hidden" name="yaxis_label" value="The Y-axis" > \n+<input type="hidden" name="xaxis_label" value="The X-axis" > \n+<input type="hidden" name="logo_title" value="This is the TITLE" > \n+<input type="hidden" name="sequences" value=\n+">\n+AAAGTGAAAGTGAAAGTGAAAGTG\n+>\n+AAAGCGAAAGCGAAAGCGAAAGCG\n+>\n+TGCCCTTGCCCTTGCCCTTGCCCT\n+>\n+TGCCTTTGCCTTTGCCTTTGCCTT\n+" >\n+</form>\n+\n+Same, but do not show axes\n+<form method="post" action="create.cgi">\n+<input type="submit" name="cmd_edit" value="Edit" >\n+<input type="submit" name="cmd_create" value="Create" >\n+<input type="hidden" name="show_fineprint" value="true" >\n+<input type="hidden" name="show_errorbars" value="true" >\n+<input type="hidden" name="download" value="true" >\n+\n+<input type="hidden" name="yaxis_label" value="This is the Y-axis" > \n+<input type="hidden" name="xaxis_label" value="This is the X-axis" > \n+<input type="hidden" name="logo_title" value="This is the TITLE" > \n+<input type="hidden" name="sequences" value=\n+">\n+AAAGTGAAAGTGAAAGTGAAAGTG\n+>\n+AAAGCGAAAGCGAAAGCGAAAGCG\n+>\n+TGCCCTTGCCCTTGCCCTTGCCCT\n+>\n+TGCCTTTGCCTTTGCCTTTGCCTT\n+" >\n+</form>\n+</dd>\n+\n+\n+\n+<dt>Format Test</dt>\n+<dd>\n+Ensure that this logo can be created in each of the available formats\n+<form method="post" action="create.cgi">\n+<input type="submit" name="cmd_edit" value="Edit" >\n+<input type="submit" name="cmd_create" value="Create" >\n+<input type="hidden" name="show_yaxis" value="true" >\n+<input type="hidden" name="show_xaxis" value="true" >\n+<input type="hidden" name="show_fineprint" value="true" >\n+<input type="hidden" name="show_errorbars" value="true" >\n+<input type="hidden" name="download" value="true" >\n+\n+Format: <sele'..b'e="true" >\n+<input type="hidden" name="show_errorbars" checked="checked" >\n+<input type="hidden" name="download" value="true" >\n+<input type="hidden" name="sequences" value=">\n+GGGGGGGGGGGGGG------------------\n+>\n+GGGGGGGGGGGGG-------------------\n+>\n+" >\n+</form>\n+\n+<form method="post" action="create.cgi">\n+<input type="submit" name="cmd_create" value="Fail: Malformed data" >\n+<input type="hidden" name="show_yaxis" value="true" >\n+<input type="hidden" name="show_xaxis" value="true" >\n+<input type="hidden" name="download" value="true" >\n+<input type="hidden" name="show_fineprint" value="true" >\n+<input type="hidden" name="show_errorbars" checked="checked" >\n+<input type="hidden" name="sequences" value=">\n+GGGGGGGGGGGGGG------------------\n+>\n+GGGGGGGGGGGGG------------------\n+>\n+" >\n+</form>\n+\n+\n+</dd>\n+\n+\n+\n+<dt> Logos Sizes</dt>\n+<dd>\n+Same sequences, three different sizes.\n+<form method="post" action="create.cgi">\n+<input type="submit" name="cmd_edit" value="Edit" >\n+<input type="hidden" name="download" value="true" >\n+<input type="submit" name="cmd_create" value="Create" >\n+<input type="hidden" name="show_yaxis" value="true" >\n+<input type="hidden" name="show_xaxis" value="true" >\n+<input type="hidden" name="show_fineprint" value="true" >\n+Size: \n+<select name="size" >\n+<option  selected="selected" >small</option>\n+<option >medium</option>\n+<option  >large</option>\n+</select> \n+\n+\n+<input type="hidden" name="sequences" value=\n+">aldB -18->4\n+attcgtgatagctgtcgtaaag\n+>ansB 103->125\n+ttttgttacctgcctctaactt\n+>araB1 109->131\n+aagtgtgacgccgtgcaaataa\n+>araB2 147->169 \n+tgccgtgattatagacactttt\n+>cdd 1 107->129\n+atttgcgatgcgtcgcgcattt\n+>cdd 2 57->79\n+taatgagattcagatcacatat\n+>crp 1 115->137\n+taatgtgacgtcctttgcatac\n+>crp 2\n+gaaggcgacctgggtcatgctg\n+>cya 151->173 \n+aggtgttaaattgatcacgttt\n+>cytR 1 125->147\n+cgatgcgaggcggatcgaaaaa\n+>cytR 2 106->128\n+aaattcaatattcatcacactt\n+>dadAX 1 95->117\n+agatgtgagccagctcaccata\n+>dadAX 2 32->54\n+agatgtgattagattattattc\n+>deoP2 1 75->97\n+aattgtgatgtgtatcgaagtg\n+>deoP2 2 128->150 \n+ttatttgaaccagatcgcatta\n+>fur 136->158\n+aaatgtaagctgtgccacgttt\n+>gal 56->78\n+aagtgtgacatggaataaatta\n+>glpACB (glpTQ) 1 54->76  \n+ttgtttgatttcgcgcatattc\n+>glpACB (glpTQ) 2 94->116\n+aaacgtgatttcatgcgtcatt\n+>glpACB (glpTQ) 144->166 \n+atgtgtgcggcaattcacattt\n+>glpD (glpE) 95->117 \n+taatgttatacatatcactcta\n+>glpFK 1 120->142\n+ttttatgacgaggcacacacat\n+>glpFK 2 95->117\n+aagttcgatatttctcgttttt\n+>gut (srlA) 72->94\n+ttttgcgatcaaaataacactt\n+>ilvB 87->109\n+aaacgtgatcaacccctcaatt\n+>lac 1 (lacZ) 88->110\n+taatgtgagttagctcactcat\n+>lac 2 (lacZ) 16->38 \n+aattgtgagcggataacaattt\n+>malEpKp1 110->132\n+ttgtgtgatctctgttacagaa\n+>malEpKp2 139->161\n+TAAtgtggagatgcgcacaTAA\n+>malEpKp3 173->195\n+TTTtgcaagcaacatcacgAAA\n+>malEpKp4 205->227\n+GACctcggtttagttcacaGAA\n+>malT 121->143\n+aattgtgacacagtgcaaattc\n+>melR 52->74\n+aaccgtgctcccactcgcagtc\n+>mtl 302->324\n+TCTTGTGATTCAGATCACAAAG\n+>nag 156->178\n+ttttgtgagttttgtcaccaaa\n+>nupG2 97->119\n+aaatgttatccacatcacaatt\n+>nupG1 47->69\n+ttatttgccacaggtaacaaaa\n+>ompA 166->188\n+atgcctgacggagttcacactt\n+>ompR 161->183\n+taacgtgatcatatcaacagaa\n+>ptsH A 316->338\n+Ttttgtggcctgcttcaaactt\n+>ptsH B 188->210\n+ttttatgatttggttcaattct\n+>rhaS (rhaB) 161->183 \n+aattgtgaacatcatcacgttc\n+>rot 1 (ppiA) 182->204 \n+ttttgtgatctgtttaaatgtt\n+>rot 2 (ppiA) 129->151\n+agaggtgattttgatcacggaa\n+>tdcA 60->82\n+atttgtgagtggtcgcacatat\n+>tnaL 73->95\n+gattgtgattcgattcacattt\n+>tsx 2 146->168\n+gtgtgtaaacgtgaacgcaatc\n+>tsx 1 107->129\n+aactgtgaaacgaaacatattt\n+>uxuAB 165->187\n+TCTTGTGATGTGGTTAACCAAT\n+" >\n+</form>\n+</dd>\n+\n+\n+\n+\n+</dl>\n+\n+\n+\n+</td></tr>\n+\n+\n+\n+\n+</table>\n+\n+<script type="text/javascript">\n+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");\n+document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));\n+</script>\n+<script type="text/javascript">\n+var pageTracker = _gat._getTracker("UA-5951066-1");\n+pageTracker._trackPageview();\n+</script>\n+</body></html>\n'
b
diff -r 09d2dac9ef73 -r 4d47ab2b7bcc weblogolib/template.eps
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/weblogolib/template.eps Fri Jan 13 07:18:19 2012 -0500
b
b"@@ -0,0 +1,669 @@\n+%!PS-Adobe-3.0 EPSF-3.0\n+%%Title:        Sequence Logo: ${logo_title}\n+%%Creator:      ${creator_text}\n+%%CreationDate: ${creation_date}\n+%%BoundingBox:  0  0  ${logo_width}  ${logo_height} \n+%%Pages: 0\n+%%DocumentFonts: \n+%%EndComments\n+\n+\n+% ---- VARIABLES ----\n+\n+/True   true def\n+/False  false def\n+\n+/debug              ${debug}        def\n+\n+/logo_height        ${logo_height}  def\n+/logo_width         ${logo_width}  def\n+/logo_title         (${logo_title}) def\n+/show_title         ${show_title} def\n+\n+/logo_margin        ${logo_margin} def\n+/xaxis_label_height ${xaxis_label_height} def\n+/title_height       ${title_height} def\n+/stroke_width       ${stroke_width} def\n+/tic_length         ${tic_length} def\n+\n+/lines_per_logo     ${lines_per_logo} def\n+/line_width         ${line_width} def\n+/line_height        ${line_height} def\n+/line_margin_left   ${line_margin_left} def\n+/line_margin_right  ${line_margin_right} def\n+/line_margin_bottom ${line_margin_bottom} def\n+/line_margin_top    ${line_margin_top} def\n+\n+/stack_width         ${stack_width} def\n+/stack_height        ${stack_height} def\n+/stacks_per_line     ${stacks_per_line} def\n+/stack_margin        ${stack_margin} def\n+\n+/show_yaxis             ${show_yaxis} def      \n+/show_yaxis_label       ${show_yaxis_label} def\n+/yaxis_label            (${yaxis_label}) def\n+/yaxis_scale          ${yaxis_scale} def              % height in units \n+/yaxis_tic_interval     ${yaxis_tic_interval} def           % in units\n+/yaxis_minor_tic_interval ${yaxis_minor_tic_interval} def   % in units\n+\n+/show_xaxis_label       ${show_xaxis_label} def             % True or False\n+/show_xaxis             ${show_xaxis} def                   % True or False\n+/xaxis_label            (${xaxis_label}) def\n+/xaxis_tic_interval     ${xaxis_tic_interval} def\n+/rotate_numbers         ${rotate_numbers} def               % True or False\n+/number_interval        ${number_interval} def\n+/show_ends              ${show_ends} def          \n+/end_type               (${end_type}) def          % d: DNA, p: PROTEIN, -: none\n+\n+/show_fineprint         ${show_fineprint} def\n+/fineprint              (${fineprint}) def\n+/logo_label             (${logo_label}) def\n+\n+/show_boxes             ${show_boxes} def    % True or False\n+/shrink                 ${shrink} def    % True or False\n+/shrink_fraction        ${shrink_fraction} def               \n+\n+/show_errorbars         ${show_errorbars} def      % True or False\n+/errorbar_fraction      ${errorbar_fraction} def\n+/errorbar_width_fraction  ${errorbar_width_fraction} def\n+/errorbar_gray          ${errorbar_gray} def\n+\n+/fontsize               ${fontsize} def\n+/small_fontsize         ${small_fontsize} def\n+/title_fontsize         ${title_fontsize} def\n+/number_fontsize        ${number_fontsize} def\n+\n+\n+/UseCIEColor true def       % Fix for issue 4\n+/default_color ${default_color} def \n+/color_dict << \n+${color_dict}\n+>> def\n+\n+\n+\n+% ---- DERIVED PARAMETERS ----\n+\n+/char_width stack_width 2 stack_margin mul sub def\n+/char_width2 char_width 2 div def\n+/char_width4 char_width 4 div def\n+\n+% movements to place 5'/N and 3'/C symbols\n+/leftEndDeltaX  fontsize neg         def\n+/leftEndDeltaY  fontsize 1.25 mul neg def\n+/rightEndDeltaX fontsize 0.25 mul     def\n+/rightEndDeltaY leftEndDeltaY        def\n+\n+\n+% ---- PROCEDURES ----\n+\n+\n+/SetTitleFont {/${title_font} findfont title_fontsize scalefont setfont} bind def\n+/SetLogoFont  {/${logo_font} findfont char_width  scalefont setfont} bind def\n+/SetStringFont{/${text_font} findfont fontsize scalefont setfont} bind def\n+/SetPrimeFont {/Symbol findfont fontsize scalefont setfont} bind def\n+/SetSmallFont {/${text_font} findfont small_fontsize scalefont setfont} bind def\n+/SetNumberFont {/${text_font} findfont number_fontsize scalefont setfont} bind def\n+\n+/DrawBox { % width height \n+    /hh exch def\n+    /ww exch def\n+    gsave\n+        0.2 setlinewidth\n+        %0.5 setgray\n+        \n+        %0 0 moveto \n+    "..b"dth mul char_height char DrawChar\n+        grestore\n+        \n+    } if\n+    0 interval yaxis_scale div stack_height mul rmoveto\n+} bind def\n+\n+\n+/DrawChar { % <width> <height> <char> ShowChar\n+    /tc exch def    % The character\n+    /ysize exch def % the y size of the character\n+    /xsize exch def % the x size of the character\n+    /xmulfactor 1 def \n+    /ymulfactor 1 def\n+    \n+    gsave\n+        SetLogoFont    \n+        tc SetColor\n+\n+        % IReplacementHack\n+        % Deal with the lack of bars on the letter 'I' in Arial and Helvetica\n+        % by replacing with 'I' from Courier.\n+        tc (I) eq {\n+            /Courier findfont char_width  scalefont setfont    \n+        } if\n+\n+\n+        shrink {\n+            xsize 1 shrink_fraction sub 2 div mul\n+            ysize 1 shrink_fraction sub 2 div mul rmoveto \n+            shrink_fraction shrink_fraction scale\n+        } if\n+        \n+        % Calculate the font scaling factors\n+        % Loop twice to catch small correction due to first scaling\n+        2 {\n+            gsave\n+            xmulfactor ymulfactor scale\n+      \n+            ysize % desired size of character in points\n+            tc CharBoxHeight \n+            dup 0.0 ne {\n+                div % factor by which to scale up the character\n+                /ymulfactor exch def\n+            } {pop pop} ifelse\n+\n+            xsize % desired size of character in points\n+            tc CharBoxWidth  \n+            dup 0.0 ne {\n+                div % factor by which to scale up the character\n+                /xmulfactor exch def\n+            } {pop pop} ifelse\n+            grestore\n+        } repeat\n+\n+\n+  \n+        % Draw the character\n+        xmulfactor ymulfactor scale\n+        % Move lower left corner of character to start point\n+        tc CharBox pop pop % llx lly : Lower left corner\n+        exch neg exch neg\n+        rmoveto\n+        \n+        tc show    \n+\n+    grestore\n+} bind def\n+\n+/SetColor{ % <char> SetColor\n+  dup color_dict exch known {\n+    color_dict exch get aload pop setrgbcolor\n+  } {\n+    pop\n+    default_color aload pop setrgbcolor\n+  } ifelse \n+} bind def\n+\n+\n+/DrawErrorbar{ % interval_down interval_up DrawErrorbar\n+    \n+    gsave\n+    /points_per_unit stack_height yaxis_scale div def \n+    /height_up   exch points_per_unit mul def \n+    /height_down exch points_per_unit mul def\n+    \n+    show_errorbars {\n+    \n+    stroke_width setlinewidth\n+    errorbar_gray setgray     \n+    stack_width 2 div 0 rmoveto\n+    \n+    /errorbar_width char_width errorbar_width_fraction mul def\n+    /errorbar_width2 errorbar_width 2 div def\n+    \n+    gsave \n+        0 height_down neg rmoveto\n+        errorbar_width2 neg 0 rlineto\n+        errorbar_width 0 rlineto\n+        errorbar_width2 neg 0 rlineto\n+        0 height_down errorbar_fraction mul rlineto \n+        stroke\n+    grestore\n+\n+    gsave \n+        0 height_up  rmoveto\n+        errorbar_width2 neg 0 rlineto\n+        errorbar_width 0 rlineto\n+        errorbar_width2 neg 0 rlineto\n+        0 height_up neg errorbar_fraction mul rlineto \n+        stroke\n+    grestore\n+    } if\n+           \n+    grestore\n+    \n+} bind def\n+\n+/DrawErrorbarFirst{ % interval_down interval_up center DrawErrorbarFirst\n+    gsave\n+    /points_per_unit stack_height yaxis_scale div def \n+    /center   exch points_per_unit mul def \n+\n+    0 center rmoveto\n+    DrawErrorbar\n+    grestore\n+} bind def\n+\n+%%EndProlog\n+\n+%%Page: 1 1\n+\n+% Example Data\n+%StartLogo\n+%    StartLine\n+%        (1) StartStack\n+%            1.2 (C) ShowSymbol\n+%            2.2 (I) ShowSymbol\n+%            0.5 0.5 DrawErrorbar\n+%        EndStack\n+%        (2) StartStack\n+%            0.5 (I) ShowSymbol\n+%            0.9 (L) ShowSymbol\n+%            1.0 (G) ShowSymbol\n+%            \n+%            0.5 0.5 DrawErrorbar        \n+%        EndStack\n+%        (234) StartStack\n+%        EndStack\n+%        (235) StartStack\n+%        EndStack\n+%    EndLine\n+%EndLogo\n+\n+StartLogo\n+\n+${logo_data}\n+\n+EndLogo\n+\n+\n+%%EOF\n"