Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/6190c12fcb45
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 01:08:33 2012
Кодировка:
allpy: 6190c12fcb45

allpy

changeset 707:6190c12fcb45

Makes (case sensitive by request) homology classes for a number of input fasta alignments
author Andrei <aba@belozersky.msu.ru>
date Thu, 07 Jul 2011 21:21:29 +0400
parents f3d5e237be5e
children 55bb5aa2c929
files utils/make_homologies.py
diffstat 1 files changed, 72 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/utils/make_homologies.py	Thu Jul 07 21:21:29 2011 +0400
     1.3 @@ -0,0 +1,72 @@
     1.4 +import sys 
     1.5 +
     1.6 +from allpy import protein
     1.7 +from allpy.homology import MonomerHomology
     1.8 +from allpy import markups
     1.9 +
    1.10 +import optparse
    1.11 +import sys
    1.12 +
    1.13 +
    1.14 +if len(sys.argv) == 1:                                                     
    1.15 +    print("Makes homology files from (case sensitive by request) input alignments")
    1.16 +    print("Type 'python make_homologies.py -h' for parameters")                                                                                                       
    1.17 +    exit()                                                                                                                                             
    1.18 +                                                                                                                                                       
    1.19 +parser = optparse.OptionParser()                                                                                                                       
    1.20 +
    1.21 +parser.add_option("-c", "--case", action="store_true", help="Case sensitive interpretation of input alignment (False if -c missed)", dest="case")
    1.22 +parser.add_option("-n", "--file_names", help="File with alignment fasta files names", dest="file_names")
    1.23 +
    1.24 +parser.add_option("-d", "--base_in", help="Name of directory with alignment files (default=\"\")", dest="base_in", default="")
    1.25 +parser.add_option("-s", "--suffix", help="Suffix for out files", dest="suffix", default = "hom")                                                           
    1.26 +parser.add_option("-o", "--base_out", help="Name of directory for outfiles (default=\"\")", dest="base_out", default="")
    1.27 +
    1.28 +# FOR ONE INPUT ALIGNMENT
    1.29 +#parser.add_option("-i", "--in_file", help="File with an alignment in fasta", dest="in_file")                                                           
    1.30 +#parser.add_option("-o", "--result", help="Output file with monomer homology classes (default: result.xls)", dest="out_file", default = "result.xls")
    1.31 +
    1.32 +options, args = parser.parse_args()                                                                                                                    
    1.33 +vars().update(vars(options))                              
    1.34 +                                                                                        
    1.35 +
    1.36 +try: 
    1.37 +    f = open(file_names)
    1.38 +except:
    1.39 +    raise Exception("File %s does not exists! Use python make_homologies.py -h for parameters" % file_names)
    1.40 +
    1.41 +
    1.42 +
    1.43 +alignment_names = []
    1.44 +for line in f:
    1.45 +    line = line.strip()
    1.46 +    if len(line) == 0:
    1.47 +        continue
    1.48 +    line = line.strip().split("#")[0]
    1.49 +    if len(line) == 0:
    1.50 +        continue
    1.51 +    alignment_names.append(line.split()[0])
    1.52 +
    1.53 +
    1.54 +if len(base_in) > 0:
    1.55 +    if base_in[-1]!= "/":
    1.56 +        base_in = base_in + "/"
    1.57 +
    1.58 +if len(base_out) > 0:
    1.59 +    if base_out[-1]!= "/":
    1.60 +        base_out = base_out + "/"
    1.61 +
    1.62 +
    1.63 +print("Wait...")
    1.64 +
    1.65 +for alignment_name in alignment_names:
    1.66 +    in_file_name = base_in + alignment_name
    1.67 +    out_file_name = base_out + alignment_name.partition(".fasta")[0] + ".xls"
    1.68 +
    1.69 +    classes_number = MonomerHomology.case_homology(in_file_name,out_file_name, case)
    1.70 +    print ("File %s: %s monomer homology classes stored" % (out_file_name,classes_number))
    1.71 +
    1.72 +print("...Done")
    1.73 +
    1.74 +
    1.75 +