*
o/;c       s,    d  Z  " $ d k Z % d k Z & d k Z ' d k Z ( d k T* d k l Z + d k T, d k	 l
 Z
 / d e f d     YZ : d f  d     YZ d	 e f d
     YZ d e f d     YZ Cd e f d     YZ Qd f  d     YZ ~d f  d     YZ d f  d     YZ nd f  d     YZ d f  d     YZ d f  d     YZ d e e e e e e e f d     YZ d e e e e e e e f d     YZ d f  d      YZ Bd!   Z d"   Z "d#   Z (e h  d$  Z  <d%   Z! Kd&   Z" d S('   sR  NCBIStandalone.py

This module provides code to work with the standalone version of
BLAST, either blastall or blastpgp, provided by the NCBI.
http://www.ncbi.nlm.nih.gov/BLAST/

Classes:
LowQualityBlastError     Except that indicates low quality query sequences.
BlastParser              Parses output from blast.
BlastErrorParser         Parses output and tries to diagnose possible errors.
PSIBlastParser           Parses output from psi-blast.
Iterator                 Iterates over a file of blast results.

_Scanner                 Scans output from standalone BLAST.
_BlastConsumer           Consumes output from blast.
_PSIBlastConsumer        Consumes output from psi-blast.
_HeaderConsumer          Consumes header information.
_DescriptionConsumer     Consumes description information.
_AlignmentConsumer       Consumes alignment information.
_HSPConsumer             Consumes hsp information.
_DatabaseReportConsumer  Consumes database report information.
_ParametersConsumer      Consumes parameters information.

Functions:
blastall        Execute blastall.
blastpgp        Execute blastpgp.

N(   s   *(   s   File(   s   Records   LowQualityBlastErrorc      s   / d  Z  7 8 RS(   so  Error caused by running a low quality sequence through BLAST.

    When low quality sequences (like GenBank entries containing only
    stretches of a single nucleotide) are BLASTed, they will result in
    BLAST generating an error and not being able to perform the BLAST.
    search. This error should be raised for the BLAST reports produced
    in this case.
    (   s   __doc__(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   LowQualityBlastError/ s   	s   _Scannerc      s   : d  Z  B C d   Z X d   Z ~ d   Z  d   Z  d   Z d   Z d   Z d   Z 1d	   Z	 7d
   Z
 Fd   Z \d   Z pd   Z d   Z RS(   s   Scan BLAST output from blastall or blastpgp.

    Tested with blastall and blastpgp v2.0.10, v2.0.11

    Methods:
    feed     Feed data into the scanner.
    
    c    s   C J K t  | t i  o L | } n N t i |  } Q t | | i d d S |  i	 | |  T |  i
 | |  U |  i | |  V |  i | |  d S(   s   S.feed(handle, consumer)

        Feed in a BLAST report for scanning.  handle is a file-like
        object that contains the BLAST report.  consumer is a Consumer
        object that will receive events as the report is scanned.

        s   containss   BLASTN(   s
   isinstances   handles   Files
   UndoHandles   uhandles   read_and_call_untils   consumers   noevents   selfs   _scan_headers   _scan_roundss   _scan_database_reports   _scan_parameters(   s   selfs   handles   consumers   uhandle(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   feedC s   c    s4  X h | i   j t | | i d d k t | | i d d n t | | i d d o t | | i d d p t | | i d d s t | | i	 d d t t | | i	 d d u t | | i d d x t | | i
 d d	 y t | | i
 d d
 z t | | i d d | | i   d  S(   Ns   containss   BLASTs   blanki   s   starts	   References   Query=s   ends   total letterss	   sequences(   s   consumers   start_headers   read_and_calls   uhandles   versions   read_and_call_whiles   noevents	   references   read_and_call_untils
   query_infos   database_infos
   end_header(   s   selfs   uhandles   consumer(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_headerX s   c    s   ~  x  d o  t  |  }  | d  d j o/ t i | d  d j  o t i | d  d j  o  Pn  |  i | |   |  i | |  q	 Wd  S(   Ni   i	   s	   Searchings   Score     Ei    s   No hits found(	   s   safe_peeklines   uhandles   lines   strings   finds   selfs   _scan_descriptionss   consumers   _scan_alignments(   s   selfs   uhandles   consumers   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_rounds~ s    
Fc    s    | i    t | | i d d  | i   o  t d d  n  t | | i d d  t | | i d d o  t | | i d d n  t | | i	 d d	 o  t | | i
  d d
  t | | i d d  t | | i  d d oR  t | | i d d  t | | i  d d
  t | | i d d n  | i    d  Sn  t | | i	  d d  t | | i  d d  t | | i d d  | i   d  d j o6  t | | i d d  t | | i d d n  t | | i  d d om  t | | i d d  t |  d  d j o6  t | | i d d  t | | i d d n n  t | | i d d  | i   d  S(   Ns   starts	   Searchings!   Unexpected end of blast report.  s*   Looks suspiciously like a PSI-BLAST crash.s   blanki   s   Resultss   containss   Score     Es   No hits founds   Sequences producings   Sequences used in modeli   s   Sequences not foundi	   s	   CONVERGED(   s   consumers   start_descriptionss   attempt_read_and_calls   uhandles   noevents   peeklines   SyntaxErrors   read_and_call_whiles   rounds   description_headers   no_hitss   read_and_calls   end_descriptionss   model_sequencess   read_and_call_untils   descriptions   nonmodel_sequencess   safe_peeklines	   converged(   s   selfs   uhandles   consumer(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_descriptions sF   	!c    ss     t  |  }  | d  d j o  d  Sn?  | d d j o |  i | |  n |  i | |  d  S(   Ni
   s
     Databasei    s   >(   s   safe_peeklines   uhandles   lines   selfs   _scan_pairwise_alignmentss   consumers   _scan_masterslave_alignment(   s   selfs   uhandles   consumers   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_alignments s   c    sZ   xM d oB 	t  |  } 
| d d j o Pn |  i | |  q	 Wd  S(   Ni   i    s   >(   s   safe_peeklines   uhandles   lines   selfs   _scan_one_pairwise_alignments   consumer(   s   selfs   uhandles   consumers   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_pairwise_alignmentss    
c    s   | i   |  i | |  xM d oB t |  } | d  d j o Pn |  i | |  q) W| i   d  S(   Ni   i   s    Score(	   s   consumers   start_alignments   selfs   _scan_alignment_headers   uhandles   safe_peeklines   lines	   _scan_hsps   end_alignment(   s   selfs   uhandles   consumers   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_one_pairwise_alignments    
c    s    t  | | i d d !x !d ox "t |  } #t i |  d  d j o $| i |  %Pn! &t	 |  o (t
 d  n )| i |  q" W-t | | i .d d o /t  | | i d d n d  S(	   Ns   starts   >i   i   s   Length =s*   I missed the Length in an alignment headers
             s   blank(   s   read_and_calls   uhandles   consumers   titles   safe_readlines   lines   strings   lstrips   lengths   is_blank_lines   SyntaxErrors   attempt_read_and_calls   noevent(   s   selfs   uhandles   consumers   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_alignment_headers    
c    sG   12| i   3|  i | |  4|  i | |  5| i   d  S(   N(   s   consumers	   start_hsps   selfs   _scan_hsp_headers   uhandles   _scan_hsp_alignments   end_hsp(   s   selfs   uhandles   consumer(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   _scan_hsp1s   c    s   7>t  | | i d d ?t  | | i d d At | | i d d Ct | | i d d Dt  | | i d d d  S(   Ns   starts    Scores    Identitiess    Strands    Frames   blanki   (	   s   read_and_calls   uhandles   consumers   scores
   identitiess   attempt_read_and_calls   strands   frames   noevent(   s   selfs   uhandles   consumer(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_hsp_header7s
   c    s   FPx Pd o Rt  | | i d d St | | i d d Tt | | i d d Ut | | i d d Vt | | i d d Wt	 |  } Y| d  d j o | d  d j o ZPn q	 Wd  S(   Ni   s   starts        s   Querys   Sbjcts   blanki   (   s   attempt_read_and_calls   uhandles   consumers   noevents   read_and_calls   querys   aligns   sbjcts   read_and_call_whiles   safe_peeklines   line(   s   selfs   uhandles   consumers   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_hsp_alignmentFs   
 
%c    s   \]| i   ^x ^d o _t |  } c| d  d j o d| i |  ePna f| d  d j o g| i |  hPn5 it |  o j| i |  n l| i |  q Wmt	 | | i d d n| i
   d  S(   Ni   i	   s	   Searchingi
   s
     Databases   blank(   s   consumers   start_alignments   safe_readlines   uhandles   lines   savelines   is_blank_lines   noevents	   multaligns   read_and_call_whiles   end_alignment(   s   selfs   uhandles   consumers   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_masterslave_alignment\s    
c    s  p~| i   x d o t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i	 d d t
 |  } | i |  t i | d  d	 j o Pn q Wt | | i	 d d t | | i  t | | i	 d
 d t | | i d d t | | i	 d d o t | | i  n t | | i	 d
 d | i   d  S(   Ni   s   starts
     Databases
       Posteds     Number of letterss     Number of sequencess     s   Lambdai    s   blanks   Gapped(   s   consumers   start_database_reports   read_and_calls   uhandles   databases   read_and_call_untils   posted_dates   num_letters_in_databases   num_sequences_in_databases   noevents   safe_readlines   lines   savelines   strings   finds	   ka_paramss   attempt_read_and_calls   gappeds   ka_params_gaps   read_and_call_whiles   end_database_report(   s   selfs   uhandles   consumers   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_database_reportps.    
c    s  | i   t | | i d d t | | i d d t | | i d d t | | i d d t | | i	 d d t | | i
 d d t | | i d d t | | i d d	 oX t | | i d d
 t | | i d d t | | i d d n t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d t | | i d d | i   d  S(   Ns   starts   Matrixs   Gaps   Number of Hitss   Number of Sequencess   Number of extensionss   Number of successfuls   Number of sequencess   Number of HSP's betters   Number of HSP's successfullys   Number of HSP's thats   Number of HSP's gappeds   length of querys   length of databases   effective HSPs   effective length of querys   effective length of databases   effective search spaces   effective search space useds
   frameshifts   Ts   As   X1s   X2s   X3s   S1s   S2(    s   consumers   start_parameterss   read_and_calls   uhandles   matrixs   attempt_read_and_calls   gap_penaltiess   num_hitss   num_sequencess   num_extendss   num_good_extendss   num_seqs_better_es   hsps_no_gaps   hsps_prelim_gappeds   hsps_prelim_gap_attempteds   hsps_gappeds   query_lengths   database_lengths   effective_hsp_lengths   effective_query_lengths   effective_database_lengths   effective_search_spaces   effective_search_space_useds
   frameshifts	   thresholds   window_sizes   dropoff_1st_passs   gap_x_dropoffs   gap_x_dropoff_finals   gap_triggers   blast_cutoffs   end_parameters(   s   selfs   uhandles   consumer(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _scan_parameterssZ   (   s   __doc__s   feeds   _scan_headers   _scan_roundss   _scan_descriptionss   _scan_alignmentss   _scan_pairwise_alignmentss   _scan_one_pairwise_alignments   _scan_alignment_headers	   _scan_hsps   _scan_hsp_headers   _scan_hsp_alignments   _scan_masterslave_alignments   _scan_database_reports   _scan_parameters(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _Scanner: s   	&m,s   BlastParserc      s&   d  Z  d   Z d   Z RS(   s3   Parses BLAST data into a Record.Blast object.

    c    s(   t    |  _ t   |  _ d S(   s   __init__(self)N(   s   _Scanners   selfs   _scanners   _BlastConsumers	   _consumer(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   __init__s   c    s0   |  i i | |  i  |  i i Sd S(   s   parse(self, handle)N(   s   selfs   _scanners   feeds   handles	   _consumers   data(   s   selfs   handle(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   parses   (   s   __doc__s   __init__s   parse(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   BlastParsers   	s   BlastErrorParserc      s5   d  Z  e d  Z d   Z 1d   Z RS(   s  Attempt to catch and diagnose BLAST errors while parsing.

    This utilizes the BlastParser module but adds an additional layer
    of complexity on top of it by attempting to diagnose SyntaxError's
    that may actually indicate problems during BLAST parsing.

    Current BLAST problems this detects are:
    o LowQualityBlastError - When BLASTing really low quality sequences
    (ie. some GenBank entries which are just short streches of a single
    nucleotide), BLAST will report an error with the sequence and be
    unable to search with this. This will lead to a badly formatted
    BLAST report that the parsers choke on. The parser will convert the
    SyntaxError to a LowQualityBlastError and attempt to provide useful
    information.
    c    s%   | |  _ t   |  _ d S(   s]  Initialize a parser that tries to catch BlastErrors.

        Arguments:
        o bad_report_handle - An optional argument specifying a handle
        where bad reports should be sent. This would allow you to save
        all of the bad reports to a file, for instance. If no handle
        is specified, the bad reports will not be saved.
        N(   s   bad_report_handles   selfs   _bad_report_handles   BlastParsers	   _b_parser(   s   selfs   bad_report_handle(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   __init__s   c    s   | i   } !y  "|  i i t i |   SWnm #t j
 o^ } %|  i
 o '|  i
 i |  n *|  i t i |  |  i i i  /t |  n Xd S(   s7   Parse a handle, attempting to diagnose errors.
        N(   s   handles   reads   resultss   selfs	   _b_parsers   parses   Files   StringHandles   SyntaxErrors   msgs   _bad_report_handles   writes   _diagnose_errors	   _consumers   data(   s   selfs   handles   resultss   msg(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   parses    %c    sm   178| i   } :xN :| oC >| d  d j o ?t d @| i   n A| i   } q Wd S(   s   Attempt to diagnose an error in the passed handle.

        Arguments:
        o handle - The handle potentially containing the error
        o data_record - The data record partially created by the consumer.
        i   s   Searchingdones    Blast failure occured on query: N(   s   handles   readlines   lines   LowQualityBlastErrors   data_records   query(   s   selfs   handles   data_records   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _diagnose_error1s    
	(   s   __doc__s   Nones   __init__s   parses   _diagnose_error(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   BlastErrorParsers   	s   PSIBlastParserc      s&   Cd  Z  FGd   Z Ld   Z RS(   s6   Parses BLAST data into a Record.PSIBlast object.

    c    s(   GHIt    |  _ Jt   |  _ d S(   s   __init__(self)N(   s   _Scanners   selfs   _scanners   _PSIBlastConsumers	   _consumer(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   __init__Gs   c    s0   LMN|  i i | |  i  O|  i i Sd S(   s   parse(self, handle)N(   s   selfs   _scanners   feeds   handles	   _consumers   data(   s   selfs   handle(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   parseLs   (   s   __doc__s   __init__s   parse(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   PSIBlastParserCs   	s   _HeaderConsumerc      sM   QRd   Z  Ud   Z [d   Z ad   Z ld   Z yd   Z RS(   Nc    s   RSt  i   |  _ d  S(   N(   s   Records   Headers   selfs   _header(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   start_headerRs   c    sZ   UVt  i |  } W| d |  i _ X| d |  i _ Y| d d d !|  i _ d  S(   Ni    i   i   (	   s   strings   splits   lines   cs   selfs   _headers   applications   versions   date(   s   selfs   lines   c(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   versionUs   c    sK   [\| d  d j o ]| d |  i _ n _|  i i | |  i _ d  S(   Ni   s   Reference: (   s   lines   selfs   _headers	   reference(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   reference[s   c    s   ab| d  d j o c| d |  i _ nf d| d  d j o e|  i i | |  i _ n5 gt d | id |  \ } jt |  |  i _ d  S(   Ni   s   Query= s          s   (\d+) letterss1   I could not find the number of letters in line
%s(   s   lines   selfs   _headers   querys
   _re_searchs   letterss	   _safe_ints   query_letters(   s   selfs   lines   letters(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys
   query_infoas   c    s   lmt  i |  } n| d  d j o o| d |  i _ n p| d d j o& q|  i i t  i |  |  i _ nM st d | ud |  \ } } vt
 |  |  i _ wt
 |  |  i _ d  S(   Ni
   s
   Database: i   s   total letterss,   ([0-9,]+) sequences; ([0-9,]+) total letterss5   I could not find the sequences and letters in line
%s(   s   strings   rstrips   lines   selfs   _headers   databases   strips
   _re_searchs	   sequencess   letterss	   _safe_ints   database_sequencess   database_letters(   s   selfs   lines	   sequencess   letters(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   database_infols   &c    sC   y{t  i |  i i  |  i _ |t  i |  i i  |  i _ d  S(   N(   s   strings   rstrips   selfs   _headers	   references   query(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys
   end_headerys   (   s   start_headers   versions	   references
   query_infos   database_infos
   end_header(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _HeaderConsumerQs   s   _DescriptionConsumerc      s}   ~d   Z  d   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z d
   Z	 RS(   Nc    s[   g  |  _ g  |  _ g  |  _ d |  _ t |  _ t |  _ d |  _ d  S(   Ni    (	   s   selfs   _descriptionss   _model_sequencess   _nonmodel_sequencess
   _convergeds   Nones   _types	   _roundnums   _DescriptionConsumer__has_n(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   start_descriptionss   c    sV   | d  d j o; t i |  } | d d j o d |  _ n n d  S(   Ni   s   Sequences producingi   s   N(   s   lines   strings   splits   colss   selfs   _DescriptionConsumer__has_n(   s   selfs   lines   cols(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   description_headers   c    s   |  i |  } |  i d j o |  i i |  n> |  i d j o |  i i |  n |  i i |  d  S(   Ns   models   nonmodel(	   s   selfs   _parses   lines   dhs   _types   _model_sequencess   appends   _nonmodel_sequencess   _descriptions(   s   selfs   lines   dh(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   descriptions   c    s   d |  _ d  S(   Ns   model(   s   selfs   _type(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   model_sequencess   c    s   d |  _ d  S(   Ns   nonmodel(   s   selfs   _type(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   nonmodel_sequencess   c    s   d |  _ d  S(   Ni   (   s   selfs
   _converged(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   convergeds   c    s
   d  S(   N(    (   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   no_hitss   c    sN   | d  d j o t d |  n t t i | d   |  _ d  S(   Ni   s   Results from rounds%   I didn't understand the round line
%s(   s   lines   SyntaxErrors	   _safe_ints   strings   strips   selfs	   _roundnum(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   rounds   c    s
   d  S(   N(    (   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_descriptionss   c    s  | } t i   } t i |  } t |  d j  o t	 d |  n |  i o^ t i | | d  } t i | | d d |  } t i | | d d |  } n; t i | | d  } t i | | d d |  } |  i oM t i | |   | d | d | d f \ | _ | _ | _ | _ nE t i | |   | d | d d f \ | _ | _ | _ | _ t | i  | _ t | i  | _ t | i  | _ | Sd  S(   Ni   s/   Line does not appear to contain description:
%si   i   i    (   s   description_lines   lines   Records   Descriptions   dhs   strings   splits   colss   lens   SyntaxErrors   selfs   _DescriptionConsumer__has_ns   rfinds   is   rstrips   titles   scores   es   num_alignmentss	   _safe_ints   _safe_float(   s   selfs   description_lines   lines   colss   is   dh(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _parses$   		 $ MD(
   s   start_descriptionss   description_headers   descriptions   model_sequencess   nonmodel_sequencess	   convergeds   no_hitss   rounds   end_descriptionss   _parse(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _DescriptionConsumer~s   
	s   _AlignmentConsumerc      sA   d   Z  d   Z d   Z d   Z Ld   Z RS(   Nc    s+   t  i   |  _ t  i   |  _ d  S(   N(   s   Records	   Alignments   selfs
   _alignments   MultipleAlignments   _multiple_alignment(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   start_alignments   c    s)   |  i i t i |  |  i _ d  S(   N(   s   selfs
   _alignments   titles   strings   lstrips   line(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   titles   c    s>   t  i |  d |  i _ t |  i i  |  i _ d  S(   Ni   (   s   strings   splits   lines   selfs
   _alignments   lengths	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   lengths   c    s?  | d  d j p | d  d j o y" t i |  \ } } } } Wn& t j
 o t d |  n Xt i	 | | t
 |   |  _ t i	 | | |  i t
 |   |  _ |  i d |  _ |  i |  i d |  _ t i | |  |  i d |  _ n t i | |  i   } t i | |  i |  i |  i ! } | o t |  } n t i | |  i |  i  } | o t |  } n t i | |  i |  i |  i ! } t
 |  |  i j  o" | d |  i t
 |  } n |  i i } | i | | | | f  d  S(   Ni   s   QUERYi	   s	   blast_tmps   I do not understand the line
%si   s    (   s   lines   strings   splits   names   starts   seqs   ends
   ValueErrors   SyntaxErrors   indexs   lens   selfs   _start_indexs
   _seq_indexs   _name_lengths   _start_lengths   rfinds   _seq_lengths   rstrips	   _safe_ints   _multiple_alignments	   alignments   aligns   append(   s   selfs   lines   names   starts   seqs   ends   align(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   multaligns.   %"!'
&
 
&"c    s   LN|  i o" Ot i |  i i  |  i _ n ey1 f|  ` g|  ` h|  ` i|  ` j|  `	 Wn kt
 j
 o
 ln Xd  S(   N(   s   selfs
   _alignments   strings   rstrips   titles
   _seq_indexs   _seq_lengths   _start_indexs   _start_lengths   _name_lengths   AttributeError(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_alignmentLs   "				(   s   start_alignments   titles   lengths	   multaligns   end_alignment(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _AlignmentConsumers
   os   _HSPConsumerc      s   nod   Z  rd   Z d   Z d   Z d   Z e i d  Z d   Z d   Z	 d	   Z
 d
   Z RS(   Nc    s   opt  i   |  _ d  S(   N(   s   Records   HSPs   selfs   _hsp(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   start_hspos   c    s   rst  d | ud |  \ |  i _ |  i _ vt |  i i  |  i _ wt |  i i  |  i _ yt  d | {d |  \ } } || o }t	 |  |  i _
 n d |  i _
 t |  |  i _ d  S(   Ns'   Score =\s*([0-9.e+]+) bits \(([0-9]+)\)s%   I could not find the score in line
%ss    Expect\(?(\d*)\)? = +([0-9.e-]+)s&   I could not find the expect in line
%si   (   s
   _re_searchs   lines   selfs   _hsps   scores   bitss   _safe_floats   xs   ys	   _safe_ints   num_alignmentss   expect(   s   selfs   lines   xs   y(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   scorers   "
c    s  t  d | d |  \ } } t |  t |  f |  i _ t i	 | d  d j oG t  d | d |  \ } } t |  t |  f |  i _
 n t i	 | d  d j oG t  d | d |  \ } } t |  t |  f |  i _ n d  S(	   Ns   Identities = (\d+)\/(\d+)s*   I could not find the identities in line
%ss	   Positivesi    s   Positives = (\d+)\/(\d+)s)   I could not find the positives in line
%ss   Gapss   Gaps = (\d+)\/(\d+)(   s
   _re_searchs   lines   xs   ys	   _safe_ints   selfs   _hsps
   identitiess   strings   finds	   positivess   gaps(   s   selfs   lines   ys   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys
   identitiess   !%c    s)   t  d | d |  |  i _ d  S(   Ns   Strand = (\w+) / (\w+)s&   I could not find the strand in line
%s(   s
   _re_searchs   lines   selfs   _hsps   strand(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   strands   c    sk   t  i | d  d j o& t d | d |  |  i _ n# t d | d |  |  i _ d  S(   Ns   /i    s!   Frame = ([-+][123]) / ([-+][123])s%   I could not find the frame in line
%ss   Frame = ([-+][123])(   s   strings   finds   lines
   _re_searchs   selfs   _hsps   frame(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   frames
   s   Query: (\d+)\s+(.+) \dc    s   |  i i |  } | t j o t d |  n | i   \ } } |  i
 i | |  i
 _ |  i
 i t j o t |  |  i
 _ n | i d  |  _ t |  |  _ d  S(   Ns%   I could not find the query in line
%si   (   s   selfs	   _query_res   searchs   lines   ms   Nones   SyntaxErrors   groupss   starts   seqs   _hsps   querys   query_starts	   _safe_ints   _query_start_indexs   lens
   _query_len(   s   selfs   lines   ms   seqs   start(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   querys   c    s   t  i | |  i  } t |  |  i j  o" | d |  i t |  } n. t |  |  i j  o t d |  n |  i	 i
 | |  i	 _
 d  S(   Ns    s)   Match is longer than the query in line
%s(   s   strings   rstrips   lines   selfs   _query_start_indexs   seqs   lens
   _query_lens   SyntaxErrors   _hsps   match(   s   selfs   lines   seq(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   aligns   "c    s   t  d | d |  \ } } t i |  o d |  i } n |  i i	 | |  i _	 |  i i
 t j o t |  |  i _
 n t |  |  i j o t d |  n |  ` |  ` d  S(   Ns   Sbjct: (\d+)\s*(.+) \ds%   I could not find the sbjct in line
%ss    s7   QUERY and SBJCT sequence lengths don't match in line
%s(   s
   _re_searchs   lines   starts   seqs   strings   strips   selfs
   _query_lens   _hsps   sbjcts   sbjct_starts   Nones	   _safe_ints   lens   SyntaxErrors   _query_start_index(   s   selfs   lines   seqs   start(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   sbjcts   	c    s
   d  S(   N(    (   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_hsps   (   s	   start_hsps   scores
   identitiess   strands   frames   res   compiles	   _query_res   querys   aligns   sbjcts   end_hsp(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _HSPConsumerns   
s   _DatabaseReportConsumerc      sq   d   Z  d   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z RS(
   Nc    s   t  i   |  _ d  S(   N(   s   Records   DatabaseReports   selfs   _dr(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   start_database_reports   c    s   t  i d |  } | o# |  i i i | i d   nJ |  i i o9 |  i i d t	 i
 |  } | |  i i d <n d  S(   Ns   Database: (.+)$i   (   s   res   searchs   lines   ms   selfs   _drs   database_names   appends   groups   strings   strips   x(   s   selfs   lines   ms   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   databases   
#!c    s0   |  i i i t d | d |   d  S(   Ns   Posted date:\s*(.+)$s+   I could not find the posted date in line
%s(   s   selfs   _drs   posted_dates   appends
   _re_searchs   line(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   posted_dates   c  
  sZ   t  | d f d d d h  d d <d d <\ } |  i i i t |   d  S(	   Ni   s   ncolsi   s   expecteds   lettersi   s	   database:i   (   s	   _get_colss   lines   letterss   selfs   _drs   num_letters_in_databases   appends	   _safe_int(   s   selfs   lines   letters(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   num_letters_in_databases   7c  
  sZ   t  | d f d d d h  d d <d d <\ } |  i i i t |   d  S(	   Ni   s   ncolsi   s   expecteds	   sequencesi   s	   database:i   (   s	   _get_colss   lines	   sequencess   selfs   _drs   num_sequences_in_databases   appends	   _safe_int(   s   selfs   lines	   sequences(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   num_sequences_in_databases   7c    s1   t  i |  } t t |  |  i _ d  S(   N(	   s   strings   splits   lines   xs   maps   _safe_floats   selfs   _drs	   ka_params(   s   selfs   lines   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   ka_paramss   c    s   d |  i _ d  S(   Ni   (   s   selfs   _drs   gapped(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   gappeds   c    s1   t  i |  } t t |  |  i _ d  S(   N(	   s   strings   splits   lines   xs   maps   _safe_floats   selfs   _drs   ka_params_gap(   s   selfs   lines   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   ka_params_gaps   c    s
    d  S(   N(    (   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_database_reports   (	   s   start_database_reports   databases   posted_dates   num_letters_in_databases   num_sequences_in_databases	   ka_paramss   gappeds   ka_params_gaps   end_database_report(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _DatabaseReportConsumers   	s   _ParametersConsumerc      sU  d   Z  d   Z 	d   Z d   Z d   Z d   Z &d   Z .d   Z 4d	   Z 9d
   Z	 ?d   Z
 Ed   Z Jd   Z Od   Z Td   Z Zd   Z `d   Z fd   Z ld   Z rd   Z vd   Z {d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   Nc    s   t  i   |  _ d  S(   N(   s   Records
   Parameterss   selfs   _params(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   start_parameterss   c    s#   t  i | d  |  i _ d  S(   Ni   (   s   strings   rstrips   lines   selfs   _paramss   matrix(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   matrixs   c  
  sU   	
t  | d d f d d d h  d d <d d	 <} t t |  |  i _ d  S(
   Ni   i   s   ncolsi   s   expecteds
   Existence:i   s
   Extension:i   (   s	   _get_colss   lines   xs   maps   _safe_floats   selfs   _paramss   gap_penalties(   s   selfs   lines   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   gap_penalties	s   6c  
  s   t  i | d  d j oG t | d f d d d h  d d <\ } t |  |  i _ nD t | d	 f d d
 d h  d d <\ } t |  |  i _ d  S(   Ns   1st passi    i   s   ncolsi   s   expecteds   Hitsi   i   i   (	   s   strings   finds   lines	   _get_colss   xs	   _safe_ints   selfs   _paramss   num_hits(   s   selfs   lines   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   num_hitss
   ..c  
  s   t  i | d  d j oG t | d f d d d h  d d <\ } t |  |  i _ nD t | d	 f d d d h  d d <\ } t |  |  i _ d  S(
   Ns   1st passi    i   s   ncolsi	   s   expecteds
   Sequences:i   i   (	   s   strings   finds   lines	   _get_colss   xs	   _safe_ints   selfs   _paramss   num_sequences(   s   selfs   lines   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   num_sequencess
   ..c  
  s   t  i | d  d j oG  t | d f d d d h  d d <\ } !t |  |  i _ nD #t | d	 f d d d h  d d <\ } $t |  |  i _ d  S(
   Ns   1st passi    i   s   ncolsi	   s   expecteds   extensions:i   i   (	   s   strings   finds   lines	   _get_colss   xs	   _safe_ints   selfs   _paramss   num_extends(   s   selfs   lines   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   num_extendss
   ..c  
  s   &'t  i | d  d j oG (t | d f d d d h  d d <\ } )t |  |  i _ nD +t | d	 f d d
 d h  d d <\ } ,t |  |  i _ d  S(   Ns   1st passi    i   s   ncolsi
   s   expecteds   extensions:i   i   i   (	   s   strings   finds   lines	   _get_colss   xs	   _safe_ints   selfs   _paramss   num_good_extends(   s   selfs   lines   x(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   num_good_extends&s
   ..c  
  sV   ./t  | d f d d d h  d d <\ |  i _ 1t |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds	   sequencesi   (   s	   _get_colss   lines   selfs   _paramss   num_seqs_better_es	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   num_seqs_better_e.s   4c  
  s_   45t  | d f d d d h  d d <d d <\ |  i _ 7t |  i i  |  i _ d  S(	   Ni   s   ncolsi	   s   expecteds   betteri   s   gapping:i   (   s	   _get_colss   lines   selfs   _paramss   hsps_no_gaps	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   hsps_no_gap4s   =c  
  s_   9:t  | d f d d d h  d d <d d <\ |  i _ <t |  i i  |  i _ d  S(	   Ni   s   ncolsi	   s   expecteds   gappedi   s   prelimi   (   s	   _get_colss   lines   selfs   _paramss   hsps_prelim_gappeds	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   hsps_prelim_gapped9s   =c  
  s_   ?@t  | d f d d d h  d d <d d <\ |  i _ Bt |  i i  |  i _ d  S(	   Ni   s   ncolsi
   s   expecteds	   attemptedi   s   prelimi   (   s	   _get_colss   lines   selfs   _paramss   hsps_prelim_gapped_attempteds	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   hsps_prelim_gapped_attempted?s   =c  
  sV   EFt  | d f d d d h  d d <\ |  i _ Ht |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds   gappedi   (   s	   _get_colss   lines   selfs   _paramss   hsps_gappeds	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   hsps_gappedEs   4c  
  s_   JKt  | d f d d d h  d d <d d <\ |  i _ Mt |  i i  |  i _ d  S(	   Ni   s   ncolsi   s   expecteds   lengthi    s   query:i   (   s	   _get_colss   lines   selfs   _paramss   query_lengths	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   query_lengthJs   =c  
  s_   OPt  | d f d d d h  d d <d d <\ |  i _ Rt |  i i  |  i _ d  S(	   Ni   s   ncolsi   s   expecteds   lengthi    s	   database:i   (   s	   _get_colss   lines   selfs   _paramss   database_lengths	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   database_lengthOs   =c  
  s_   TUt  | d f d d d h  d d <d d <\ |  i _ Wt |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds   HSPs   length:i   (   s	   _get_colss   lines   selfs   _paramss   effective_hsp_lengths	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   effective_hsp_lengthTs   =c  
  s_   Z[t  | d f d d d h  d d <d d <\ |  i _ ]t |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds   lengths   query:i   (   s	   _get_colss   lines   selfs   _paramss   effective_query_lengths	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   effective_query_lengthZs   =c  
  s_   `at  | d f d d d h  d d <d d <\ |  i _ ct |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds   lengths	   database:i   (   s	   _get_colss   lines   selfs   _paramss   effective_database_lengths	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   effective_database_length`s   =c  
  sV   fgt  | d f d d d h  d d <\ |  i _ it |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds   search(   s	   _get_colss   lines   selfs   _paramss   effective_search_spaces	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   effective_search_spacefs   4c  
  s_   lmt  | d f d d d h  d d <d d <\ |  i _ ot |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds   searchs   used:i   (   s	   _get_colss   lines   selfs   _paramss   effective_search_space_useds	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   effective_search_space_usedls   =c  
  sC   rst  | d d f d d d h  d d <d d	 <|  i _ d  S(
   Ni   i   s   ncolsi   s   expecteds
   frameshifti    s   decayi   (   s	   _get_colss   lines   selfs   _paramss
   frameshift(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys
   frameshiftrs   c  
  sU   vwt  | d f d d d h  d d <\ |  i _ yt |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds   T:i    (   s	   _get_colss   lines   selfs   _paramss	   thresholds	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   thresholdvs   3c  
  sU   {|t  | d f d d d h  d d <\ |  i _ ~t |  i i  |  i _ d  S(   Ni   s   ncolsi   s   expecteds   A:i    (   s	   _get_colss   lines   selfs   _paramss   window_sizes	   _safe_int(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   window_size{s   3c    sJ   t  d | d |  \ } } t |  t |  f |  i _ d  S(   Ns    X1: (\d+) \(\s*([0-9,.]+) bits\)s'   I could not find the dropoff in line
%s(	   s
   _re_searchs   lines   scores   bitss	   _safe_ints   _safe_floats   selfs   _paramss   dropoff_1st_pass(   s   selfs   lines   bitss   score(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   dropoff_1st_passs   c    sJ   t  d | d |  \ } } t |  t |  f |  i _ d  S(   Ns    X2: (\d+) \(\s*([0-9,.]+) bits\)s+   I could not find the gap dropoff in line
%s(	   s
   _re_searchs   lines   scores   bitss	   _safe_ints   _safe_floats   selfs   _paramss   gap_x_dropoff(   s   selfs   lines   bitss   score(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   gap_x_dropoffs   c    sJ   t  d | d |  \ } } t |  t |  f |  i _ d  S(   Ns    X3: (\d+) \(\s*([0-9,.]+) bits\)s1   I could not find the gap dropoff final in line
%s(	   s
   _re_searchs   lines   scores   bitss	   _safe_ints   _safe_floats   selfs   _paramss   gap_x_dropoff_final(   s   selfs   lines   bitss   score(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   gap_x_dropoff_finals   c    sJ   t  d | d |  \ } } t |  t |  f |  i _ d  S(   Ns    S1: (\d+) \(\s*([0-9,.]+) bits\)s+   I could not find the gap trigger in line
%s(	   s
   _re_searchs   lines   scores   bitss	   _safe_ints   _safe_floats   selfs   _paramss   gap_trigger(   s   selfs   lines   bitss   score(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   gap_triggers   c    sJ   t  d | d |  \ } } t |  t |  f |  i _ d  S(   Ns    S2: (\d+) \(\s*([0-9,.]+) bits\)s,   I could not find the blast cutoff in line
%s(	   s
   _re_searchs   lines   scores   bitss	   _safe_ints   _safe_floats   selfs   _paramss   blast_cutoff(   s   selfs   lines   bitss   score(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   blast_cutoffs   c    s
   d  S(   N(    (   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_parameterss   (   s   start_parameterss   matrixs   gap_penaltiess   num_hitss   num_sequencess   num_extendss   num_good_extendss   num_seqs_better_es   hsps_no_gaps   hsps_prelim_gappeds   hsps_prelim_gapped_attempteds   hsps_gappeds   query_lengths   database_lengths   effective_hsp_lengths   effective_query_lengths   effective_database_lengths   effective_search_spaces   effective_search_space_useds
   frameshifts	   thresholds   window_sizes   dropoff_1st_passs   gap_x_dropoffs   gap_x_dropoff_finals   gap_triggers   blast_cutoffs   end_parameters(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _ParametersConsumers8   s   _BlastConsumerc      sq   d   Z  d   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z RS(
   Nc    s   t  |  _ d  S(   N(   s   Nones   selfs   data(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   __init__s   c    s   t  d  d  S(   Ns+   This consumer doesn't handle PSI-BLAST data(   s
   ValueError(   s   selfs   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   rounds   c    s)   t  i   |  _ t i |   d  S(   N(   s   Records   Blasts   selfs   datas   _HeaderConsumers   start_header(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   start_headers   c    s3   t  i |   |  i i i |  i i  d  S(   N(   s   _HeaderConsumers
   end_headers   selfs   datas   __dict__s   updates   _header(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys
   end_headers   c    s   |  i |  i _ d  S(   N(   s   selfs   _descriptionss   datas   descriptions(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_descriptionss   c    sj   t  i |   |  i i o |  i i i |  i  n |  i i	 o |  i |  i _
 n d  S(   N(   s   _AlignmentConsumers   end_alignments   selfs
   _alignments   hspss   datas
   alignmentss   appends   _multiple_alignments	   alignments   multiple_alignment(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_alignments
   c    s\   t  i |   y |  i i i |  i  Wn" t j
 o t d  n Xd  S(   Ns    Found an HSP before an alignment(	   s   _HSPConsumers   end_hsps   selfs
   _alignments   hspss   appends   _hsps   AttributeErrors   SyntaxError(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_hsps
   c    s3   t  i |   |  i i i |  i i  d  S(   N(   s   _DatabaseReportConsumers   end_database_reports   selfs   datas   __dict__s   updates   _dr(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_database_reports   c    s3   t  i |   |  i i i |  i i  d  S(   N(   s   _ParametersConsumers   end_parameterss   selfs   datas   __dict__s   updates   _params(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_parameterss   (	   s   __init__s   rounds   start_headers
   end_headers   end_descriptionss   end_alignments   end_hsps   end_database_reports   end_parameters(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _BlastConsumers   s   _PSIBlastConsumerc      sq   d   Z  d   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z RS(
   Nc    s   t  |  _ d  S(   N(   s   Nones   selfs   data(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   __init__s   c    s)   t  i   |  _ t i |   d  S(   N(   s   Records   PSIBlasts   selfs   datas   _HeaderConsumers   start_header(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   start_headers   c    s3   t  i |   |  i i i |  i i  d  S(   N(   s   _HeaderConsumers
   end_headers   selfs   datas   __dict__s   updates   _header(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys
   end_headers   c    sB   t  i   |  _ |  i i i |  i  t i |   d  S(   N(	   s   Records   Rounds   selfs   _rounds   datas   roundss   appends   _DescriptionConsumers   start_descriptions(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   start_descriptionss   c    s   t  i |   |  i |  i _ |  i o |  i i i |  i  n |  i i	 i |  i
  |  i i i |  i  |  i o d |  i _ n d  S(   Ni   (   s   _DescriptionConsumers   end_descriptionss   selfs	   _roundnums   _rounds   numbers   _descriptionss   new_seqss   extends   reused_seqss   _model_sequencess   _nonmodel_sequencess
   _convergeds   datas	   converged(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_descriptionss   c    sg   t  i |    |  i i o |  i i i |  i  n |  i o |  i |  i _	 n d  S(   N(
   s   _AlignmentConsumers   end_alignments   selfs
   _alignments   hspss   _rounds
   alignmentss   appends   _multiple_alignments   multiple_alignment(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_alignments
   c    s\   t  i |   y |  i i i |  i  Wn" 	t j
 o 
t d  n Xd  S(   Ns    Found an HSP before an alignment(	   s   _HSPConsumers   end_hsps   selfs
   _alignments   hspss   appends   _hsps   AttributeErrors   SyntaxError(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_hsps
   c    s3   t  i |   |  i i i |  i i  d  S(   N(   s   _DatabaseReportConsumers   end_database_reports   selfs   datas   __dict__s   updates   _dr(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_database_reports   c    s3   t  i |   |  i i i |  i i  d  S(   N(   s   _ParametersConsumers   end_parameterss   selfs   datas   __dict__s   updates   _params(   s   self(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   end_parameterss   (	   s   __init__s   start_headers
   end_headers   start_descriptionss   end_descriptionss   end_alignments   end_hsps   end_database_reports   end_parameters(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _PSIBlastConsumers   
s   Iteratorc      s)   d  Z  e d  Z (d   Z RS(   s   Iterates over a file of multiple BLAST results.

    Methods:
    next   Return the next record from the stream, or None.

    c    sd   "#t  |  t j	 o t  |  t j	 o $t d  n %t i |  |  _ &| |  _
 d S(   s  __init__(self, handle, parser=None)

        Create a new iterator.  handle is a file-like object.  parser
        is an optional Parser object to change the results into another form.
        If set to None, then the raw contents of the file will be returned.

        s,   I expected a file handle or file-like objectN(   s   types   handles   FileTypes   InstanceTypes
   ValueErrors   Files
   UndoHandles   selfs   _uhandles   parsers   _parser(   s   selfs   handles   parser(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   __init__s
   )c    s  (./g  } 0x 0d o 1|  i i   } 2| o 3Pn 5| o" | d  d j p | d d !d j o 6|  i i |  7Pn 8| i |  q W:| o ;t Sn =t i	 | d  } >|  i t j	 o  ?|  i i t i |   Sn @| Sd S(   s}   next(self) -> object

        Return the next Blast record from the file.  If no more records,
        return None.

        i   i   s   BLASTi   s    N(   s   liness   selfs   _uhandles   readlines   lines   savelines   appends   Nones   strings   joins   datas   _parsers   parses   Files   StringHandle(   s   selfs   datas   liness   line(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   next(s"   	 
/ (   s   __doc__s   Nones   __init__s   next(    (    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   Iterators   	c    s4  Brsh  d d <d d <d d <d d <d	 d
 <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d  <d! d" <d# d$ <d% d& <d' d( <d) d* <d+ d, <d- d. <d/ d0 <d1 d2 <d3 d4 <d5 d6 <d7 d8 <d9 d: <d; d< <}	 t i i |   o t d= |   n g  } | i |	 d$ | g  | i |	 d& | g  | i |	 d( | g  x= | i   d> r* }
 | i |	 |
 t | |
  g  qWt i |  g |  \ } } } | i   t i |  t i |  f Sd? S(@   sY  blastall(blastcmd, program, database, infile, **keywds) ->
    read, error Undohandles
    
    Execute and retrieve data from blastall.  blastcmd is the command
    used to launch the 'blastall' executable.  program is the blast program
    to use, e.g. 'blastp', 'blastn', etc.  database is the path to the database
    to search against.  infile is the path to the file containing
    the sequence to search with.

    You may pass more parameters to **keywds to change the behavior of
    the search.  Otherwise, optional values will be chosen by blastall.
    
        Scoring
    matrix              Matrix to use.
    gap_open            Gap open penalty.
    gap_extend          Gap extension penalty.
    nuc_match           Nucleotide match reward.  (BLASTN)
    nuc_mismatch        Nucleotide mismatch penalty.  (BLASTN)
    query_genetic_code  Genetic code for Query.
    db_genetic_code     Genetic code for database.  (TBLAST[NX])

        Algorithm
    gapped              Whether to do a gapped alignment. T/F (not for TBLASTX)
    expectation         Expectation value cutoff.
    wordsize            Word size.
    strands             Query strands to search against database.([T]BLAST[NX])
    keep_hits           Number of best hits from a region to keep.
    xdrop               Dropoff value (bits) for gapped alignments.
    hit_extend          Threshold for extending hits.
    region_length       Length of region used to judge hits.
    db_length           Effective database length.
    search_length       Effective length of search space.

        Processing
    filter              Filter query sequence?  T/F
    believe_query       Believe the query defline.  T/F
    restrict_gi         Restrict search to these GI's.
    nprocessors         Number of processors to use.

        Formatting
    html                Produce HTML output?  T/F
    descriptions        Number of one-line descriptions.
    alignments          Number of alignments.
    align_view          Alignment view.  Integer 0-6.
    show_gi             Show GI's in deflines?  T/F
    seqalign_file       seqalign file to output.

    s   -Ms   matrixs   -Gs   gap_opens   -Es
   gap_extends   -rs	   nuc_matchs   -qs   nuc_mismatchs   -Qs   query_genetic_codes   -Ds   db_genetic_codes   -gs   gappeds   -es   expectations   -Ws   wordsizes   -Ss   strandss   -Ks	   keep_hitss   -Xs   xdrops   -fs
   hit_extends   -Ls   region_lengths   -zs	   db_lengths   -Ys   search_lengths   -ps   programs   -ds   databases   -is   infiles   -Fs   filters   -Js   believe_querys   -ls   restrict_gis   -as   nprocessorss   -Ts   htmls   -vs   descriptionss   -bs
   alignmentss   -ms
   align_views   -Is   show_gis   -Os   seqalign_files   blastall does not exist at %si    N(   s	   att2params   oss   paths   existss   blastcmds
   ValueErrors   paramss   extends   programs   databases   infiles   keywdss   keyss   attrs   strs   popen2s   popen3s   rs   ws   es   closes   Files
   UndoHandle(   s   blastcmds   programs   databases   infiles   keywdss   rs   paramss   ws   es	   att2params   attr(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   blastallBs   0$ 	 	("c 
   st  h  d d <d d <d d <d d <d	 d
 <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d  <d! d" <d d# <d$ d% <d& d' <d( d) <d* d+ <d, d- <d. d/ <d0 d1 <d2 d3 <d4 d5 <d6 d7 <d8 d9 <d: d; <d< d= <d> d? <d@ dA <dB dC <dD dE <dF dG <dH dI <dJ dK <dL dM <dN dO <} t i i |   o t dP |   n g  } | i | d/ | g  | i | d1 | g  x= | i   dQ r* } | i | | t | |  g  qWt i |  g |  \ } } }	 | i   t i |  t i |	  f SdR S(S   s
  blastpgp(blastcmd, database, infile, **keywds) ->
    read, error Undohandles
    
    Execute and retrieve data from blastpgp.  blastcmd is the command
    used to launch the 'blastpgp' executable.  database is the path to the
    database to search against.  infile is the path to the file containing
    the sequence to search with.

    You may pass more parameters to **keywds to change the behavior of
    the search.  Otherwise, optional values will be chosen by blastpgp.

        Scoring
    matrix              Matrix to use.
    gap_open            Gap open penalty.
    gap_extend          Gap extension penalty.
    window_size         Multiple hits window size.
    npasses             Number of passes.
    passes              Hits/passes.  Integer 0-2.

        Algorithm
    gapped              Whether to do a gapped alignment.  T/F
    expectation         Expectation value cutoff.
    wordsize            Word size.
    keep_hits           Number of beset hits from a region to keep.
    xdrop               Dropoff value (bits) for gapped alignments.
    hit_extend          Threshold for extending hits.
    region_length       Length of region used to judge hits.
    db_length           Effective database length.
    search_length       Effective length of search space.
    nbits_gapping       Number of bits to trigger gapping.
    pseudocounts        Pseudocounts constants for multiple passes.
    xdrop_final         X dropoff for final gapped alignment.
    xdrop_extension     Dropoff for blast extensions.
    model_threshold     E-value threshold to include in multipass model.
    required_start      Start of required region in query.
    required_end        End of required region in query.

        Processing
    XXX should document default values
    program             The blast program to use. (PHI-BLAST)
    filter              Filter query sequence with SEG?  T/F
    believe_query       Believe the query defline?  T/F
    nprocessors         Number of processors to use.

        Formatting
    html                Produce HTML output?  T/F
    descriptions        Number of one-line descriptions.
    alignments          Number of alignments.
    align_view          Alignment view.  Integer 0-6.
    show_gi             Show GI's in deflines?  T/F
    seqalign_file       seqalign file to output.
    align_outfile       Output file for alignment.
    checkpoint_outfile  Output file for PSI-BLAST checkpointing.
    restart_infile      Input file for PSI-BLAST restart.
    hit_infile          Hit file for PHI-BLAST.
    matrix_outfile      Output file for PSI-BLAST matrix in ASCII.
    align_infile        Input alignment file for PSI-BLAST restart.
    
    s   -Ms   matrixs   -Gs   gap_opens   -Es
   gap_extends   -As   window_sizes   -js   npassess   -Ps   passess   -gs   gappeds   -es   expectations   -Ws   wordsizes   -Ks	   keep_hitss   -Xs   xdrops   -fs
   hit_extends   -Ls   region_lengths   -Zs	   db_lengths   -Ys   search_lengths   -Ns   nbits_gappings   -cs   pseudocountss   xdrop_finals   -ys   xdrop_extensions   -hs   model_thresholds   -Ss   required_starts   -Hs   required_ends   -ps   programs   -ds   databases   -is   infiles   -Fs   filters   -Js   believe_querys   -as   nprocessorss   -Ts   htmls   -vs   descriptionss   -bs
   alignmentss   -ms
   align_views   -Is   show_gis   -Os   seqalign_files   -os   align_outfiles   -Cs   checkpoint_outfiles   -Rs   restart_infiles   -ks
   hit_infiles   -Qs   matrix_outfiles   -Bs   align_infiles   blastpgp does not exist at %si    N(   s	   att2params   oss   paths   existss   blastcmds
   ValueErrors   paramss   extends   databases   infiles   keywdss   keyss   attrs   strs   popen2s   popen3s   rs   ws   es   closes   Files
   UndoHandle(
   s   blastcmds   databases   infiles   keywdss   paramss   rs   ws	   att2params   attrs   e(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   blastpgps   ;.r 	 	("c    sD   "#t  i |  |  } $| o %t |  n &| i   Sd  S(   N(   s   res   searchs   regexs   lines   ms   SyntaxErrors	   error_msgs   groups(   s   regexs   lines	   error_msgs   m(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys
   _re_search"s   c    s   ()t  i |   } ,| t j	 o t |  | j o# -t d | t |  |  f  n 1xR | i	   d 1r? } 2| | | | j o! 3t d | | | |  f  n qm W7g  } 8x' | d 8r } 9| i | |  q W:t |  Sd  S(   Ns)   I expected %d columns (got %d) in line
%si    s'   I expected '%s' in column %d in line
%s(   s   strings   splits   lines   colss   ncolss   Nones   lens   SyntaxErrors   expecteds   keyss   ks   resultss   cols_to_gets   cs   appends   tuple(   s   lines   cols_to_gets   ncolss   expecteds   ks   colss   cs   results(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   _get_cols(s   ## 	%	 	c    s   <=y >t  |   SWn. ?t j
 o Bt i |  d d  }  n XCy Et  |   SWn Ft j
 o
 Gn XIt t |    Sd  S(   Ns   ,s    (   s   ints   strs
   ValueErrors   strings   replaces   longs   float(   s   str(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys	   _safe_int<s   c    s   KLy Mt  |   SWnY Nt j
 oJ P|  d d d g j o Qd |  }  n St i |  d d  }  n XUt  |   Sd  S(   Ni    s   Es   es   1s   ,s    (   s   floats   strs
   ValueErrors   strings   replace(   s   str(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   _safe_floatKs   (#   s   __doc__s   oss   strings   res   popen2s   typess   Bios   Files   Bio.ParserSupports	   Bio.Blasts   Records	   Exceptions   LowQualityBlastErrors   _Scanners   AbstractParsers   BlastParsers   BlastErrorParsers   PSIBlastParsers   _HeaderConsumers   _DescriptionConsumers   _AlignmentConsumers   _HSPConsumers   _DatabaseReportConsumers   _ParametersConsumers   AbstractConsumers   _BlastConsumers   _PSIBlastConsumers   Iterators   blastalls   blastpgps
   _re_searchs   Nones	   _get_colss	   _safe_ints   _safe_float(   s   blastpgps   oss	   _safe_ints   _Scanners   Files   _PSIBlastConsumers   blastalls   res   _AlignmentConsumers   _HSPConsumers   BlastErrorParsers   Iterators
   _re_searchs   BlastParsers   _ParametersConsumers	   _get_colss   _DescriptionConsumers   LowQualityBlastErrors   _BlastConsumers   _safe_floats   popen2s   Records   strings   _HeaderConsumers   _DatabaseReportConsumers   PSIBlastParser(    (    s1   /mit/seven/lib/python/Bio/Blast/NCBIStandalone.pys   ?" s:   

 D-Oi++:+8.fz