*
D;c    
   s`    d  Z    d k T d k Z  d k Z  d g Z $ d k l Z % d k l Z & d k l Z ' d k l	 Z	 ( d k
 T) d k l Z + d	 f  d
     YZ G d f  d     YZ t d f  d     YZ  d e f d     YZ  d f  d     YZ  d f  d     YZ  d e f d     YZ d e f d     YZ 8e d  Z d S(   s  Fasta package

This module provides code to work with FASTA-formatted sequences.


Classes:
Record             Holds FASTA sequence data.
Iterator           Iterates over sequence data in a FASTA file.
Dictionary         Accesses a FASTA file using a dictionary interface.
RecordParser       Parses FASTA sequence data into a Record object.
SequenceParser     Parses FASTA sequence data into a Sequence object.

_Scanner           Scans a FASTA-format stream.
_RecordConsumer    Consumes FASTA data to a Record object.
_SequenceConsumer  Consumes FASTA data to a Sequence object.


Functions:
index_file         Index a FASTA file for a Dictionary.

(   s   *Ns
   FastaAlign(   s   File(   s   Index(   s   Seq(   s	   SeqRecord(   s   Alphabets   Recordc      s)   + d  Z  2 3 d d  Z > d   Z RS(   s   Holds information from a FASTA record.

    Members:
    title       Title line ('>' character not included).
    sequence    The sequence.
    
    i<   c    s.   3 9 : d |  _ ; d |  _ < | |  _ d S(   s   __init__(self, colwidth=60)

        Create a new Record.  colwidth specifies the number of residues
        to put on each line when generating FASTA format.

        s    N(   s   selfs   titles   sequences   colwidths	   _colwidth(   s   selfs   colwidth(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __init__3 s   c    s   > ? g  } @ | i d |  i  A d } B xO B | t |  i  j  o5 C | i |  i | | |  i ! D | |  i } q2 WE t i	 | d  Sd  S(   Ns   >%si    s   
(
   s   ss   appends   selfs   titles   is   lens   sequences	   _colwidths   strings   join(   s   selfs   ss   i(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __str__> s   		 !(   s   __doc__s   __init__s   __str__(    (    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   Record+ s   	s   Iteratorc      s)   G d  Z  M N e d  Z [ d   Z RS(   s   Returns one record at a time from a FASTA file.

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

    c    sd   N U V t  |  t j	 o t  |  t j	 o W t d  n X t i |  |  _ Y | |  _
 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(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __init__N s
   )c    s   [ a b g  } c xz c d oo d |  i i   } e | o f Pn g | d d j o | o h |  i i |  i Pn j | i |  q Wl | o m t Sn o t i	 | d  } p |  i t j	 o  q |  i i t i |   Sn r | Sd S(   s}   next(self) -> object

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

        i   i    s   >s    N(   s   liness   selfs   _uhandles   readlines   lines   savelines   appends   Nones   strings   joins   datas   _parsers   parses   Files   StringHandle(   s   selfs   datas   liness   line(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   next[ s"   	 
 (   s   __doc__s   Nones   __init__s   next(    (    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   IteratorG s   	s
   Dictionaryc      sV   t d  Z  w x d Z z e d  Z  d   Z  d   Z  d   Z  d   Z RS(   s9   Accesses a FASTA file using a dictionary interface.

    s
   __filenamec    sG   z   t  i  |  |  _  t |  i t i  |  _  | |  _	 d S(   s  __init__(self, indexname, parser=None)

        Open a Fasta Dictionary.  indexname is the name of the
        index for the dictionary.  The index should have been created
        using the index_file function.  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.

        N(
   s   Indexs	   indexnames   selfs   _indexs   opens
   Dictionarys   _Dictionary__filename_keys   _handles   parsers   _parser(   s   selfs	   indexnames   parser(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __init__z s   	c    s     t  |  i  Sd  S(   N(   s   lens   selfs   _index(   s   self(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __len__ s   c    s     |  i | \ } }  |  i i |   |  i i |  }  |  i	 t
 j	 o   |  i	 i t i |   Sn  | Sd  S(   N(   s   selfs   _indexs   keys   starts   lens   _handles   seeks   reads   datas   _parsers   Nones   parses   Files   StringHandle(   s   selfs   keys   lens   datas   start(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __getitem__ s    c    s     t  |  i |  Sd  S(   N(   s   getattrs   selfs   _indexs   name(   s   selfs   name(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __getattr__ s   c    s      |  i i   }  g  }  x; | d  r. }  | d  d j o  | i |  n q- W x# | d  r }  | i |  qn W | Sd S(   s   Override keys to return only valid keys.

        The keys which is called normally on this dictionary will return
        internal values such as '__filename'. This just strips those out
        before returning.
        i    i   s   __N(   s   selfs   _indexs   keyss   all_keyss	   to_removes   keys   appends   remove(   s   selfs   keys	   to_removes   all_keys(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   keys s   	 	 	(   s   __doc__s   _Dictionary__filename_keys   Nones   __init__s   __len__s   __getitem__s   __getattr__s   keys(    (    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys
   Dictionaryt s   		s   RecordParserc      s&    d  Z    d   Z  d   Z RS(   s6   Parses FASTA sequence data into a Record object.

    c    s%     t    |  _  t   |  _ d  S(   N(   s   _Scanners   selfs   _scanners   _RecordConsumers	   _consumer(   s   self(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __init__ s   c    s-     |  i i | |  i   |  i i Sd  S(   N(   s   selfs   _scanners   feeds   handles	   _consumers   data(   s   selfs   handle(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   parse s   (   s   __doc__s   __init__s   parse(    (    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   RecordParser s   	s   SequenceParserc      s/    d  Z    e i e d  Z  d   Z RS(   s8   Parses FASTA sequence data into a Sequence object.

    c    s.      t    |  _  t | |  |  _ d S(   s  Initialize a Scanner and Sequence Consumer.

        Arguments:
        o alphabet - The alphabet of the sequences to be parsed. If not
        passed, this will be set as generic_alphabet.
        o title2ids - A function that, when given the title of the FASTA
        file (without the beginning >), will return the name, id and
        description (in that order) for the record. If this is not given,
        then the entire title line will be used as the description.
        N(   s   _Scanners   selfs   _scanners   _SequenceConsumers   alphabets	   title2idss	   _consumer(   s   selfs   alphabets	   title2ids(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __init__ s   
c    s-     |  i i | |  i   |  i i Sd  S(   N(   s   selfs   _scanners   feeds   handles	   _consumers   data(   s   selfs   handle(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   parse s   (   s   __doc__s   Alphabets   generic_alphabets   Nones   __init__s   parse(    (    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   SequenceParser s   	s   _Scannerc      s>    d  Z    d   Z  d   Z  d   Z  d   Z RS(   sV   Scans a FASTA-formatted file.

    Methods:
    feed   Feed in one FASTA record.

    c    sf      t  | t i  o  | } n  t i |  }  | i   o  |  i | |  n d S(   s   feed(self, handle, consumer)

        Feed in FASTA data for scanning.  handle is a file-like object
        containing FASTA data.  consumer is a Consumer object that will
        receive events as the FASTA data is scanned.

        N(	   s
   isinstances   handles   Files
   UndoHandles   uhandles   peeklines   selfs   _scan_records   consumer(   s   selfs   handles   consumers   uhandle(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   feed s   c    sG     | i    |  i | |   |  i | |   | i   d  S(   N(   s   consumers   start_sequences   selfs   _scan_titles   uhandles   _scan_sequences   end_sequence(   s   selfs   uhandles   consumer(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   _scan_record s   c    s      t  | | i d d d  S(   Ns   starts   >(   s   read_and_calls   uhandles   consumers   title(   s   selfs   uhandles   consumer(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   _scan_title s   c    s     xr  d og  | i   }  t |  o  Pn-  | d d j o  | i |   Pn  | i |  q	 Wd  S(   Ni   i    s   >(   s   uhandles   readlines   lines   is_blank_lines   savelines   consumers   sequence(   s   selfs   uhandles   consumers   line(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   _scan_sequence s    
(   s   __doc__s   feeds   _scan_records   _scan_titles   _scan_sequence(    (    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   _Scanner s
   	s   _RecordConsumerc      sJ    d  Z    d   Z  d   Z d   Z d   Z 
d   Z RS(   su   Consumer that converts a FASTA record to a Record object.

    Members:
    data    Record with FASTA data.
    
    c    s     t  |  _ d  S(   N(   s   Nones   selfs   data(   s   self(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __init__ s   c    s    t    |  _ d  S(   N(   s   Records   selfs   data(   s   self(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   start_sequence s   c    s
   d  S(   N(    (   s   self(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   end_sequences   c    sE   t  o | d d j p t  t i | d  |  i _ d  S(   Ni    s   >i   (   s	   __debug__s   lines   AssertionErrors   strings   rstrips   selfs   datas   title(   s   selfs   line(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   titles   "c    s2   
t  i |  } |  i i | |  i _ d  S(   N(   s   strings   rstrips   lines   seqs   selfs   datas   sequence(   s   selfs   lines   seq(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   sequence
s   (   s   __doc__s   __init__s   start_sequences   end_sequences   titles   sequence(    (    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   _RecordConsumer s   	s   _SequenceConsumerc      sS   d  Z  e i e d  Z "d   Z &d   Z )d   Z 3d   Z RS(   su   Consumer that converts a FASTA record to a Sequence object.

    Members:
    data    Sequence with FASTA data.

    c    s.   t  |  _ | |  _  | |  _ d S(   s  Initialize the Consumer.

        Arguments:
        o alphabet - The alphabet of the sequences we will be creating.
        o title2ids - A function that will convert the title of a FASTA
        record into the id, name and description information.
        N(   s   Nones   selfs   datas   alphabets	   title2ids(   s   selfs   alphabets	   title2ids(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   __init__s   c    s4   "#t  i  d |  i  } $t i |  |  _ d  S(   Ns    (   s   Seqs   selfs   alphabets   seqs	   SeqRecords   data(   s   selfs   seq(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   start_sequence"s   c    s
   &'d  S(   N(    (   s   self(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   end_sequence&s   c    s   )*t  o | d d j p t  +|  i oY ,|  i t i | d   \ } } } -| |  i
 _ .| |  i
 _ /| |  i
 _ n 1t i | d  |  i
 _ d  S(   Ni    s   >i   (   s	   __debug__s   lines   AssertionErrors   selfs	   title2idss   strings   rstrips   ids   names   descrs   datas   description(   s   selfs   lines   ids   descrs   name(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   title)s   "(c    sA   35t  i  t i |  |  i  } 6|  i i | |  i _ d  S(   N(   s   Seqs   strings   rstrips   lines   selfs   alphabets   seqs   data(   s   selfs   lines   seq(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   sequence3s   !(	   s   __doc__s   Alphabets   generic_alphabets   Nones   __init__s   start_sequences   end_sequences   titles   sequence(    (    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   _SequenceConsumers   	
c 	   sc  8ABt  i i |   o Ct d |   n Et i | d d } F|  | t i	 <Ht
 t |   d t   } Ix Id o J| i i   } K| i   } L| i i   | } N| t j o OPn P| t j	 o Q| |  } n S| i } U| o Vt d  n( W| i |  o Xt d |  n Z| | f | | <q} Wd S(   sX  index_file(filename, indexname, rec2key=None)

    Index a FASTA file.  filename is the name of the file.
    indexname is the name of the dictionary.  rec2key is an
    optional callback that takes a Record and generates a unique key
    (e.g. the accession number) for the record.  If not specified,
    the sequence title will be used.

    s   %s does not exists   truncatei   s   parsers   empty sequence key was produceds   duplicate key %s foundN(   s   oss   paths   existss   filenames
   ValueErrors   Indexs	   indexnames   indexs
   Dictionarys   _Dictionary__filename_keys   Iterators   opens   RecordParsers   iters   _uhandles   tells   starts   nexts   recs   lengths   Nones   rec2keys   keys   titles   KeyErrors   has_key(	   s   filenames	   indexnames   rec2keys   lengths   recs   starts   iters   indexs   key(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys
   index_file8s*   	 
(   s   __doc__s   typess   strings   oss   __all__s   Bios   Files   Indexs   Seqs	   SeqRecords   Bio.ParserSupports   Alphabets   Records   Iterators
   Dictionarys   AbstractParsers   RecordParsers   SequenceParsers   _Scanners   AbstractConsumers   _RecordConsumers   _SequenceConsumers   Nones
   index_file(   s
   index_files   oss   SequenceParsers   _Scanners   Files   RecordParsers   __all__s   _RecordConsumers   Iterators   Records   _SequenceConsumers	   SeqRecords   Alphabets   Seqs   strings
   Dictionarys   Index(    (    s+   /mit/seven/lib/python/Bio/Fasta/__init__.pys   ? s&   

-5*)