dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

aln2grishin.py (1271B)


      1 #!/usr/bin/env python
      2 """
      3 Convert clustal alignment files to grishin for use in Rosetta protein
      4 simulations
      5 
      6 Author: Ed van Bruggen <edvb@uw.edu>
      7 """
      8 
      9 import argparse
     10 from argparse import RawTextHelpFormatter
     11 
     12 parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
     13 parser.add_argument('--file', type=str, required=True,
     14                     help='input clustal alignment file')
     15 parser.add_argument('--target', metavar='POS', type=int, default=1,
     16                     help='position of target protein (default: 1)')
     17 args = parser.parse_args()
     18 
     19 aln = open(args.file)
     20 proteins = []
     21 
     22 for i, line in enumerate(aln):
     23     if i == 0 or line == '\n' or line[0] == ' ':
     24         continue
     25     words = line.split()
     26     skip = 0
     27     for protein in proteins:
     28         if protein[0] == words[0]:
     29             protein[1] += words[1]
     30             skip = 1
     31             continue
     32     if not skip:
     33         proteins.append([words[0], words[1]])
     34 
     35 target = proteins[args.target - 1]
     36 
     37 for protein in proteins:
     38     if protein == target:
     39         continue
     40     grishin = open(target[0] + "_" + protein[0] + ".grishin", "w")
     41     grishin.write("## %s %s_thread\n#\nscores from program: 0\n0 %s\n0 %s\n" %
     42                   (target[0], protein[0], target[1], protein[1]))