Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/tip/utils/make_homologies.py
Дата изменения: Unknown
Дата индексирования: Wed Apr 13 08:27:17 2016
Кодировка:
allpy: b556c96c6719 utils/make_homologies.py

allpy

view utils/make_homologies.py @ 1168:b556c96c6719

blocks3d/www Makefile: never check certificates of github, they are too confusing for wget
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Mon, 26 May 2014 17:20:29 +0400
parents 3312472eb920
children
line source
1 #!/usr/bin/python
2 import sys
3 from glob import glob
4 import optparse
5 from allpy import protein
6 from allpy.homology import MonomerHomology
7 from allpy import markups
11 if len(sys.argv) == 1:
12 print("Makes homology files from (case sensitive by request) input alignments")
13 print("Type 'python make_homologies.py -h' for parameters")
14 exit()
16 parser = optparse.OptionParser()
18 parser.add_option("-c", "--case", action="store_true", help="Case sensitive interpretation of input alignment (False if -c missed)", dest="case")
19 parser.add_option("-n", "--file_names", help="File with alignment fasta files names", dest="file_names")
20 parser.add_option("-g", "--files-glob", help="Glob expression for alignment file names")
22 parser.add_option("-d", "--base_in", help="Name of directory with alignment files (default=\"\")", dest="base_in", default="")
23 parser.add_option("-s", "--suffix", help="Suffix for out files", dest="suffix", default = "hom")
24 parser.add_option("-o", "--base_out", help="Name of directory for outfiles (default=\"\")", dest="base_out", default="")
25 parser.add_option("-f", "--format", help="Format of input file: 'markup' or 'fasta' (default)", dest="format", default = "fasta")
28 # FOR ONE INPUT ALIGNMENT
29 #parser.add_option("-i", "--in_file", help="File with an alignment in fasta", dest="in_file")
30 #parser.add_option("-o", "--result", help="Output file with monomer homology classes (default: result.xls)", dest="out_file", default = "result.xls")
32 options, args = parser.parse_args()
33 vars().update(vars(options))
35 if files_glob:
36 alignment_names = glob(files_glob)
38 else:
40 try:
41 f = open(file_names)
42 except:
43 raise Exception("File %s does not exists! Use python make_homologies.py -h for parameters" % file_names)
45 alignment_names = []
46 for line in f:
47 line = line.strip()
48 if len(line) == 0:
49 continue
50 line = line.strip().split("#")[0]
51 if len(line) == 0:
52 continue
53 alignment_names.append(line.split()[0])
56 if len(base_in) > 0:
57 if base_in[-1]!= "/":
58 base_in = base_in + "/"
60 if len(base_out) > 0:
61 if base_out[-1]!= "/":
62 base_out = base_out + "/"
65 print("Wait...")
67 for alignment_name in alignment_names:
68 in_file_name = base_in + alignment_name
69 out_file_name = base_out + alignment_name.partition(".fasta")[0] + ".xls"
71 classes_number = MonomerHomology.case_homology(in_file_name,out_file_name, case, format)
72 print ("File %s: %s monomer homology classes stored" % (out_file_name,classes_number))
74 print("...Done")
78 # vim: set et ts=4 sts=4 sw=4: