<s> '''<STR_LIT>''' <EOL> USAGE = """<STR_LIT>""" <EOL> import sys , string , os , getopt , re <EOL> from Pairsdb import * <EOL> import alignlib <EOL> import Experiment , Dots , Fasta <EOL> param_format = "<STR_LIT>" <EOL> param_seqres = <NUM_LIT:1> <EOL> param_atoms = None <EOL> param_chain = None <EOL> param_filename_sequence = None <EOL> MAP_MODELLER = { '<STR_LIT>' : '<STR_LIT:A>' , <EOL> '<STR_LIT>' : '<STR_LIT:R>' , <EOL> '<STR_LIT>' : '<STR_LIT:N>' , <EOL> '<STR_LIT>' : '<STR_LIT:D>' , <EOL> '<STR_LIT>' : '<STR_LIT:C>' , <EOL> '<STR_LIT>' : '<STR_LIT:X>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:E>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:H>' , <EOL> '<STR_LIT>' : '<STR_LIT:H>' , <EOL> '<STR_LIT>' : '<STR_LIT:H>' , <EOL> '<STR_LIT>' : '<STR_LIT:H>' , <EOL> '<STR_LIT>' : '<STR_LIT:H>' , <EOL> '<STR_LIT>' : '<STR_LIT:H>' , <EOL> '<STR_LIT>' : '<STR_LIT:H>' , <EOL> '<STR_LIT>' : '<STR_LIT:I>' , <EOL> '<STR_LIT>' : '<STR_LIT:L>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:M>' , <EOL> '<STR_LIT>' : '<STR_LIT:X>' , <EOL> '<STR_LIT>' : '<STR_LIT:X>' , <EOL> '<STR_LIT>' : '<STR_LIT:F>' , <EOL> '<STR_LIT>' : '<STR_LIT:P>' , <EOL> '<STR_LIT>' : '<STR_LIT:S>' , <EOL> '<STR_LIT>' : '<STR_LIT:T>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:Y>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:X>' , <EOL> '<STR_LIT>' : '<STR_LIT:X>' , <EOL> '<STR_LIT>' : '<STR_LIT:X>' , <EOL> '<STR_LIT>' : '<STR_LIT:X>' , <EOL> '<STR_LIT>' : '<STR_LIT:M>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> MAP_IUPAC = { '<STR_LIT>' : '<STR_LIT:A>' , <EOL> '<STR_LIT>' : '<STR_LIT:R>' , <EOL> '<STR_LIT>' : '<STR_LIT:N>' , <EOL> '<STR_LIT>' : '<STR_LIT:D>' , <EOL> '<STR_LIT>' : '<STR_LIT:C>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:E>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:H>' , <EOL> '<STR_LIT>' : '<STR_LIT:I>' , <EOL> '<STR_LIT>' : '<STR_LIT:L>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:M>' , <EOL> '<STR_LIT>' : '<STR_LIT:F>' , <EOL> '<STR_LIT>' : '<STR_LIT:P>' , <EOL> '<STR_LIT>' : '<STR_LIT:S>' , <EOL> '<STR_LIT>' : '<STR_LIT:T>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:Y>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> param_map_amino_acids = MAP_MODELLER <EOL> def PrintAlignedSequences ( sequence1 , sequence2 , chain = None , format = "<STR_LIT>" ) : <EOL> seq_row = alignlib . makeSequence ( sequence1 ) <EOL> seq_col = alignlib . makeSequence ( sequence2 ) <EOL> alignator = alignlib . makeAlignatorFullDP ( - <NUM_LIT:0.0> , - <NUM_LIT:0.0> ) <EOL> map_row2col = alignlib . makeAlignataVector ( ) <EOL> alignator . Align ( seq_row , seq_col , map_row2col ) <EOL> lines = string . split ( alignlib . writePairAlignment ( seq_row , seq_col , map_row2col ) , "<STR_LIT:\n>" ) <EOL> if format == "<STR_LIT>" : <EOL> first_res , sequence , last_res = string . split ( lines [ <NUM_LIT:0> ] , "<STR_LIT:\t>" ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" % ( "<STR_LIT>" , first_res , "<STR_LIT>" , last_res , "<STR_LIT>" ) <EOL> print "<STR_LIT>" % sequence <EOL> first_res , sequence , last_res = string . split ( lines [ <NUM_LIT:1> ] , "<STR_LIT:\t>" ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" % ( "<STR_LIT>" , first_res , "<STR_LIT>" , last_res , "<STR_LIT>" ) <EOL> print "<STR_LIT>" % sequence <EOL> else : <EOL> print lines <EOL> def PrintSequence ( sequence , chain = None , format = "<STR_LIT>" , alignment_sequence = None ) : <EOL> if alignment_sequence : <EOL> PrintAlignedSequences ( sequence , alignment_sequence , chain , format ) <EOL> else : <EOL> if format == "<STR_LIT>" : <EOL> print sequence <EOL> elif format == "<STR_LIT>" : <EOL> print "<STR_LIT>" % ( chain , len ( sequence ) , sequence ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> try : <EOL> optlist , args = getopt . getopt ( sys . argv [ <NUM_LIT:1> : ] , <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> except getopt . error , msg : <EOL> print USAGE <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> for o , a in optlist : <EOL> if o in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> param_format = a <EOL> elif o == "<STR_LIT>" : <EOL> param_seqres = <NUM_LIT:1> <EOL> param_atoms = None <EOL> elif o in ( "<STR_LIT:-c>" , "<STR_LIT>" ) : <EOL> param_chain = a <EOL> elif o in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> param_atoms = <NUM_LIT:1> <EOL> param_seqres = None <EOL> elif o in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> param_map_amino_acids = MAP_IUPAC <EOL> elif o in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> infile = open ( a , "<STR_LIT:r>" ) <EOL> infile . readline ( ) <EOL> alignment_sequence = "<STR_LIT>" <EOL> for line in infile : <EOL> alignment_sequence += re . sub ( "<STR_LIT>" , "<STR_LIT>" , line ) <EOL> if param_chain and len ( param_chain ) > <NUM_LIT:1> : <EOL> if string . find ( param_chain , "<STR_LIT:->" ) != - <NUM_LIT:1> : <EOL> param_chain = param_chain [ - <NUM_LIT:1> ] <EOL> else : <EOL> param_chain = None <EOL> sequence = None <EOL> last_chain = None <EOL> last_residue_number = None <EOL> for line in sys . stdin : <EOL> if param_seqres and line [ : <NUM_LIT:6> ] == "<STR_LIT>" : <EOL> chain = line [ <NUM_LIT:11> ] <EOL> if chain != last_chain : <EOL> if sequence : <EOL> if not param_chain or param_chain == last_chain : <EOL> PrintSequence ( sequence , last_chain , param_format , alignment_sequence ) <EOL> sequence = "<STR_LIT>" <EOL> last_chain = chain <EOL> for residue in string . split ( string . strip ( line [ <NUM_LIT> : - <NUM_LIT:1> ] ) , "<STR_LIT:U+0020>" ) : <EOL> if not param_map_amino_acids . has_key ( residue ) : <EOL> print "<STR_LIT>" % residue <EOL> else : <EOL> c = param_map_amino_acids [ residue ] <EOL> if c : sequence += param_map_amino_acids [ residue ] <EOL> if param_atoms and line [ : <NUM_LIT:6> ] in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> chain = line [ <NUM_LIT> ] <EOL> residue_number = line [ <NUM_LIT> : <NUM_LIT> ] <EOL> residue = line [ <NUM_LIT> : <NUM_LIT:20> ] <EOL> if chain != last_chain : <EOL> if sequence : <EOL> if not param_chain or param_chain == last_chain : <EOL> PrintSequence ( sequence , last_chain , sequence ) <EOL> sequence = "<STR_LIT>" <EOL> last_chain = chain <EOL> if residue_number != last_residue_number : <EOL> if param_map_amino_acids . has_key ( residue ) : <EOL> c = param_map_amino_acids [ residue ] <EOL> if c : sequence += param_map_amino_acids [ residue ] <EOL> last_residue_number = residue_number <EOL> if sequence : <EOL> if not param_chain or param_chain == last_chain : <EOL> PrintSequence ( sequence , last_chain , param_format , alignment_sequence ) </s>
