allpy
changeset 872:20d687480d83
Post-MCCMB state of blocks_finder
author | Boris Burkov <BurkovBA@gmail.com> |
---|---|
date | Fri, 29 Jul 2011 19:08:21 +0400 |
parents | e460ca5a071f |
children | 691afd37a4b7 |
files | sbbs_2009/blocks_finder.py sbbs_2009/modules/block.py sequence_based_blocks_search/blocks_finder.py sequence_based_blocks_search/test_homology.py |
diffstat | 4 files changed, 27 insertions(+), 16 deletions(-) [+] |
line diff
1.1 --- a/sbbs_2009/blocks_finder.py Mon Jul 11 22:15:50 2011 +0400 1.2 +++ b/sbbs_2009/blocks_finder.py Fri Jul 29 19:08:21 2011 +0400 1.3 @@ -78,19 +78,22 @@ 1.4 return blocks_for_print 1.5 1.6 1.7 +sys.path.append(os.path.dirname(__file__)+"/../utils") 1.8 +from timesup import * 1.9 +@timesup 1.10 def blocks2homology_file(blocks, homology_file): 1.11 sys.path.append(os.path.dirname(__file__)+"/../allpy/") 1.12 from homology import MonomerHomology 1.13 class_counter = 0 1.14 for b in blocks: 1.15 if b[0].content[0].state == "aligned": 1.16 - for sa in b[0].content[0].sequence_indexes_a: 1.17 - sequence_name = b[0].content[0].alignment.sequences[b[0].content[0].alignment.sequence_indexes_s[sa]].name 1.18 - for pa in b[0].content[0].position_indexes_a: 1.19 + for pa in b[0].content[0].position_indexes_a: 1.20 + for sa in b[0].content[0].sequence_indexes_a: 1.21 + sequence_name = b[0].content[0].alignment.sequences[b[0].content[0].alignment.sequence_indexes_s[sa]].name 1.22 if b[0].content[0].alignment.get_aa(sa,pa)!=None: 1.23 - monomer_id = (sequence_name, pa+1) 1.24 - MonomerHomology.write_monomer(homology_file, monomer_id, class_counter) 1.25 - class_counter+=1 1.26 + monomer_id = (sequence_name, b[0].content[0].alignment.body[sa][pa]+1) 1.27 + MonomerHomology.write_monomer(homology_file, monomer_id, class_counter, pa+1) 1.28 + class_counter+=1 1.29 else: 1.30 if b[0].content[0].state == "no_alignment": 1.31 #print each monomer as a separate class 1.32 @@ -98,8 +101,8 @@ 1.33 sequence_name = b[0].content[0].alignment.sequences[b[0].content[0].alignment.sequence_indexes_s[sa]].name 1.34 for pa in b[0].content[0].position_indexes_a: 1.35 if b[0].content[0].alignment.get_aa(sa, pa) != None: 1.36 - monomer_id = (sequence_name, pa+1) 1.37 - MonomerHomology.write_monomer(homology_file, monomer_id, class_counter) 1.38 + monomer_id = (sequence_name, b[0].content[0].alignment.body[sa][pa]+1) 1.39 + MonomerHomology.write_monomer(homology_file, monomer_id, class_counter, pa+1) 1.40 class_counter+=1 1.41 1.42
2.1 --- a/sbbs_2009/modules/block.py Mon Jul 11 22:15:50 2011 +0400 2.2 +++ b/sbbs_2009/modules/block.py Fri Jul 29 19:08:21 2011 +0400 2.3 @@ -376,7 +376,7 @@ 2.4 elif mode == "semiexternal": 2.5 mat = self.create_distance_matrix() 2.6 #if mat.max() == 0: return False 2.7 - f=open(os.path.dirname(__file__)+"/../jobs/temptree.dist","w") 2.8 + f=open(""+os.path.dirname(__file__)+"/../jobs/temptree.dist","w") 2.9 f.write(str(mat)) 2.10 f.close() 2.11 os.system("fneighbor "+os.path.dirname(__file__)+"/../jobs/temptree.dist -outfile "+os.path.dirname(__file__)+"/../jobs/temptree.nj -outtreefile "+os.path.dirname(__file__)+"/../jobs/temptree.tre -treetype u 2>>"+os.path.dirname(__file__)+"/../jobs/temptree.log >>"+os.path.dirname(__file__)+"/../jobs/temptree.log")
3.1 --- a/sequence_based_blocks_search/blocks_finder.py Mon Jul 11 22:15:50 2011 +0400 3.2 +++ b/sequence_based_blocks_search/blocks_finder.py Fri Jul 29 19:08:21 2011 +0400 3.3 @@ -105,12 +105,12 @@ 3.4 candidate_preblocks+=addition_to_candidate_preblocks 3.5 #remove from candidates those preblocks that share the same set of sequences with others, but are shorter and have lower scores 3.6 #print index_of_column, len(candidate_preblocks), 3.7 - print index_of_column, len(candidate_preblocks) 3.8 - if len(candidate_preblocks)>1000: 3.9 - import cProfile 3.10 - cProfile.runctx('remove_contained_preblocks(candidate_preblocks)',globals(),locals()) 3.11 - else: 3.12 - remove_contained_preblocks(candidate_preblocks) 3.13 + #print index_of_column, len(candidate_preblocks) 3.14 +# if len(candidate_preblocks)>1000: 3.15 +# import cProfile 3.16 +# cProfile.runctx('remove_contained_preblocks(candidate_preblocks)',globals(),locals()) 3.17 +# else: 3.18 + remove_contained_preblocks(candidate_preblocks) 3.19 #print len(candidate_preblocks) 3.20 #remove_bad_candidates(candidate_preblocks, index_of_column, 0.5, 10) 3.21 #for those preblocks ending with a conserved position and having the score above threshold, add new links 3.22 @@ -377,7 +377,7 @@ 3.23 created by create_links function""" 3.24 try: 3.25 markup_file = open(markup_file_name,'w') 3.26 - except E: 3.27 + except Exception as E: 3.28 print E 3.29 sys.exit() 3.30 #creating markups
4.1 --- a/sequence_based_blocks_search/test_homology.py Mon Jul 11 22:15:50 2011 +0400 4.2 +++ b/sequence_based_blocks_search/test_homology.py Fri Jul 29 19:08:21 2011 +0400 4.3 @@ -17,5 +17,13 @@ 4.4 find_links(groups_content, alignment) 4.5 create_file_with_monomer_homology(alignment, output_file_name) 4.6 4.7 +def timeout(signum, frame): 4.8 + print sys.argv[1]+" time-out!!!" 4.9 + sys.exit(1) 4.10 + 4.11 if __name__ == "__main__": 4.12 + import signal 4.13 + signal.signal(signal.SIGALRM, timeout) 4.14 + signal.alarm(90) 4.15 + print sys.argv[1] 4.16 alignment_file2homology_file(sys.argv[1], sys.argv[2])