[BioPython] biopython clustalw command line take 2

Brad Chapman chapmanb at uga.edu
Wed Jul 30 13:10:50 EDT 2003


Hi Ashleigh;

> Hello biopython experts.  At the risk of seeming like a pest, I'm
> reposting a question I asked a couple of days ago to see if I can get a
> bite this time.

Sorry to be so slow in responding. I've been beyond swamped
recently. Grad school is very evil.

> I'm trying to use clustalw through biopython for the first
> time.  I'm following the tutorial but it doesn't show the syntax for
> setting the multiple alignment parameters.  From the __init__ I figured
> out that it is something like gap_open_pen=desired value so I tried
> cline.gap_open_pen=20 but when I try to show that command line string I
> get an error:
[...]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.2/site-packages/Bio/Clustalw/__init__.py", line
> 420, in __str__
>     cline = cline + " -GAPOPEN=" + self.gap_open_pen
> TypeError: cannot concatenate 'str' and 'int' objects

As Michiel pointed out, this isn't an error in how you are using it,
but rather an error in my ugly code. I've attached a patch which
fixes all of these types of potential problems (the patch is also
checked into CVS). This should be applied to
Bio/Clustalw/__init__.py if you (or anyone else) wants to use it.

As Larry pointed out, you can work around my bug and save yourself
from having to patch the Biopython code by passing in strings
instead of integers. 

Sorry about the bug. Thanks much for reporting it!
Brad
-------------- next part --------------
Index: __init__.py
===================================================================
RCS file: /home/repository/biopython/biopython/Bio/Clustalw/__init__.py,v
retrieving revision 1.6
diff -c -r1.6 __init__.py
*** __init__.py	13 Jun 2003 03:25:17 -0000	1.6
--- __init__.py	30 Jul 2003 17:16:11 -0000
***************
*** 388,394 ****
  
          # general options
          if self.type:
!             cline = cline + " -TYPE=" + self.type
          if self.is_quick == 1:
              cline = cline + " -INTERACTIVE"
          if self.allow_negative == 1:
--- 388,394 ----
  
          # general options
          if self.type:
!             cline = cline + " -TYPE=%s" % self.type
          if self.is_quick == 1:
              cline = cline + " -INTERACTIVE"
          if self.allow_negative == 1:
***************
*** 396,429 ****
  
          # output options
          if self.output_file:
!             cline = cline + " -OUTFILE=" + self.output_file
          if self.output_type:
!             cline = cline + " -OUTPUT=" + self.output_type
          if self.output_order:
!             cline = cline + " -OUTORDER=" + self.output_order
          if self.change_case:
!             cline = cline + " -CASE=" + self.change_case
          if self.add_seqnos:
!             cline = cline + " -SEQNOS=" + self.add_seqnos
          if self.new_tree:
              # clustal does not work if -align is written -ALIGN
!             cline = cline + " -NEWTREE=" + self.new_tree + " -align"
  
          # multiple alignment options
          if self.guide_tree:
!             cline = cline + " -USETREE=" + self.guide_tree
          if self.protein_matrix:
!             cline = cline + " -MATRIX=" + self.protein_matrix
          if self.dna_matrix:
!             cline = cline + " -DNAMATRIX=" + self.dna_matrix
          if self.gap_open_pen:
!             cline = cline + " -GAPOPEN=" + self.gap_open_pen
          if self.gap_ext_pen:
!             cline = cline + " -GAPEXT=" + self.gap_ext_pen
          if self.is_no_end_pen == 1:
              cline = cline + " -ENDGAPS"
          if self.gap_sep_range:
!             cline = cline + " -GAPDIST=" + self.gap_sep_range
          if self.is_no_pgap == 1:
              cline = cline + " -NOPGAP"
          if self.is_no_hgap == 1:
--- 396,429 ----
  
          # output options
          if self.output_file:
!             cline = cline + " -OUTFILE=%s" % self.output_file
          if self.output_type:
!             cline = cline + " -OUTPUT=%s" % self.output_type
          if self.output_order:
!             cline = cline + " -OUTORDER=%s" % self.output_order
          if self.change_case:
!             cline = cline + " -CASE=%s" % self.change_case
          if self.add_seqnos:
!             cline = cline + " -SEQNOS=%s" % self.add_seqnos
          if self.new_tree:
              # clustal does not work if -align is written -ALIGN
!             cline = cline + " -NEWTREE=%s -align" % self.new_tree
  
          # multiple alignment options
          if self.guide_tree:
!             cline = cline + " -USETREE=%s" % self.guide_tree
          if self.protein_matrix:
!             cline = cline + " -MATRIX=%s" % self.protein_matrix
          if self.dna_matrix:
!             cline = cline + " -DNAMATRIX=%s" % self.dna_matrix
          if self.gap_open_pen:
!             cline = cline + " -GAPOPEN=%s" % self.gap_open_pen
          if self.gap_ext_pen:
!             cline = cline + " -GAPEXT=%s" % self.gap_ext_pen
          if self.is_no_end_pen == 1:
              cline = cline + " -ENDGAPS"
          if self.gap_sep_range:
!             cline = cline + " -GAPDIST=%s" % self.gap_sep_range
          if self.is_no_pgap == 1:
              cline = cline + " -NOPGAP"
          if self.is_no_hgap == 1:
***************
*** 433,443 ****
              residue_list = ''
              for residue in self.h_gap_residues:
                  residue_list = residue_list + residue
!             cline = cline + " -HGAPRESIDUES=" + residue_list
          if self.max_div:
!             cline = cline + " -MAXDIV=" + self.max_div
          if self.trans_weight:
!             cline = cline + " -TRANSWEIGHT=" + self.trans_weight
  
          return cline
  
--- 433,443 ----
              residue_list = ''
              for residue in self.h_gap_residues:
                  residue_list = residue_list + residue
!             cline = cline + " -HGAPRESIDUES=%s" % residue_list
          if self.max_div:
!             cline = cline + " -MAXDIV=%s" % self.max_div
          if self.trans_weight:
!             cline = cline + " -TRANSWEIGHT=%s" % self.trans_weight
  
          return cline
  


More information about the BioPython mailing list