Mercurial > repos > abims-sbr > pairwise
annotate scripts/S06_post_processing_of_pairwise.py @ 4:6709645eff5d draft
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit cf1b9c905931ca2ca25faa4844d45c908756472f
| author | abims-sbr |
|---|---|
| date | Wed, 17 Jan 2018 08:53:53 -0500 |
| parents | c8af52875b0f |
| children |
| rev | line source |
|---|---|
|
1
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
1 #!/usr/bin/env python |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
2 ## AUTHOR: Eric Fontanillas |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
3 ## LAST VERSION: 14/08/14 by Julie BAFFARD |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
4 |
|
4
6709645eff5d
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit cf1b9c905931ca2ca25faa4844d45c908756472f
abims-sbr
parents:
1
diff
changeset
|
5 MINIMUM_LENGTH = 1 |
|
1
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
6 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
7 ####################### |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
8 ##### RUN RUN RUN ##### |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
9 ####################### |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
10 import string, os, time, re, sys |
|
4
6709645eff5d
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit cf1b9c905931ca2ca25faa4844d45c908756472f
abims-sbr
parents:
1
diff
changeset
|
11 from functions import get_pairs, extract_length, filter_redondancy |
|
1
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
12 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
13 ## 1 ## INPUT/OUTPUT |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
14 SHORT_FILE = sys.argv[1] #short-name-query_short-name-db |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
15 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
16 F_IN = "%s/06_PairwiseMatch_%s.fasta" %(SHORT_FILE, SHORT_FILE) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
17 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
18 F_OUT = "%s/09_PairwiseMatch_filtered_%s.fasta" %(SHORT_FILE, SHORT_FILE) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
19 File_OUT = open(F_OUT, "w") |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
20 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
21 F_OUT2 = "%s/09_onlyMatch_filtered_%s.fasta" %(SHORT_FILE, SHORT_FILE) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
22 File_OUT2 = open(F_OUT2, "w") |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
23 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
24 ## 2 ## RUN |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
25 list_pairwises = get_pairs(F_IN) ### DEF1 ### |
|
4
6709645eff5d
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit cf1b9c905931ca2ca25faa4844d45c908756472f
abims-sbr
parents:
1
diff
changeset
|
26 list_pairwises_filtered1 = filter_redondancy(list_pairwises, MINIMUM_LENGTH) ### DEF3 ### |
|
1
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
27 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
28 i = 0 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
29 for pair in list_pairwises_filtered1: |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
30 i = i+1 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
31 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
32 ## Write pairwise alignment |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
33 File_OUT.write("%s\n" %pair[0]) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
34 File_OUT.write("%s\n" %pair[1]) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
35 File_OUT.write("%s\n" %pair[2]) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
36 File_OUT.write("%s\n" %pair[3]) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
37 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
38 ## Write only "matches" [AND UNGAP THEM: needed before the 2nd run of blast] |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
39 File_OUT2.write("%s\n" %pair[2]) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
40 seq_match = pair[3] |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
41 seq_match_ungapped = string.replace(seq_match, "-", "") |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
42 File_OUT2.write("%s\n" %seq_match_ungapped) |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
43 |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
44 File_OUT.close() |
|
c8af52875b0f
planemo upload for repository https://github.com/abims-sbr/adaptsearch commit ab76075e541dd7ece1090f6b55ca508ec0fde39d
lecorguille
parents:
diff
changeset
|
45 File_OUT2.close() |
