Mercurial > repos > iuc > hyphy_summary
annotate scripts/strike-ambigs.bf @ 0:f304c108aa1f draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
author | iuc |
---|---|
date | Wed, 09 Jun 2021 07:03:54 +0000 |
parents | |
children |
rev | line source |
---|---|
0
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
1 RequireVersion ("2.5.20"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
2 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
3 LoadFunctionLibrary ("libv3/tasks/alignments.bf"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
4 LoadFunctionLibrary ("libv3/tasks/trees.bf"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
5 LoadFunctionLibrary ("libv3/UtilityFunctions.bf"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
6 LoadFunctionLibrary ("libv3/IOFunctions.bf"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
7 LoadFunctionLibrary ("libv3/convenience/math.bf"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
8 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
9 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
10 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
11 filter.analysis_description = {terms.io.info : |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
12 " |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
13 Read an alignment of coding sequences and replace any ambiguous codons with ---. Write results to a new file in FASTA format, and report changed sequences to stdout |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
14 ", |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
15 terms.io.version : "0.1", |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
16 terms.io.reference : "TBD", |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
17 terms.io.authors : "Sergei L Kosakovsky Pond", |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
18 terms.io.contact : "spond@temple.edu", |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
19 terms.io.requirements : "An MSA" |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
20 }; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
21 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
22 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
23 io.DisplayAnalysisBanner (filter.analysis_description); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
24 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
25 utility.SetEnvVariable ("NORMALIZE_SEQUENCE_NAMES", FALSE); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
26 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
27 KeywordArgument ("code", "Which genetic code should be used", "Universal"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
28 KeywordArgument ("alignment", "An in-frame codon alignment in one of the formats supported by HyPhy"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
29 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
30 filter.in = alignments.PromptForGeneticCodeAndAlignment ("filter.dataset", "filter.input"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
31 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
32 KeywordArgument ("output", ".fasta for compressed data", None); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
33 filter.out = io.PromptUserForFilePath(".fasta for filtered data"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
34 fprintf (filter.out, CLEAR_FILE, KEEP_OPEN); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
35 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
36 GetDataInfo (filter.site_patterns, filter.input); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
37 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
38 filter.patter2site = {}; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
39 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
40 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
41 for (i,j,v; in; filter.site_patterns) { |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
42 index = i+j; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
43 if (filter.patter2site / v == FALSE ) { |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
44 filter.patter2site [v] = {}; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
45 } |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
46 filter.patter2site [v] + index; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
47 } |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
48 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
49 GET_DATA_INFO_RETURNS_ONLY_THE_INDEX = TRUE; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
50 COUNT_GAPS_IN_FREQUENCIES = FALSE; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
51 filter.unique_patterns = utility.Array1D (filter.input.site_freqs); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
52 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
53 for (seq = 0; seq < filter.input.species; seq += 1) { |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
54 io.ReportProgressBar ("filter","Processing sequence " + (1+seq)); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
55 codons = {1, filter.input.sites}; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
56 codons [0] = ""; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
57 GetString (seq_name, filter.input, seq); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
58 GetDataInfo (seq_chars, filter.input, seq); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
59 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
60 filter.ambigs = 0; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
61 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
62 for (pattern = 0; pattern < filter.unique_patterns; pattern += 1) { |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
63 GetDataInfo (pattern_info, filter.input, seq, pattern); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
64 if (pattern_info >= 0) { |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
65 codon_start = (filter.patter2site[pattern])[0] * 3; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
66 codon = seq_chars [codon_start][codon_start+2]; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
67 } else { |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
68 codon = "---"; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
69 filter.ambigs += Abs (filter.patter2site [pattern]) |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
70 } |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
71 for (c; in; filter.patter2site [pattern] ) { |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
72 codons[c] = codon; |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
73 } |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
74 } |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
75 if (filter.ambigs > 0) { |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
76 fprintf (stdout, "\nStriking ", filter.ambigs, " codons that are incompletely resolved from " + seq_name + "\n"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
77 } |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
78 fprintf (filter.out,">",seq_name,"\n",Join ("", codons), "\n"); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
79 } |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
80 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
81 fprintf (filter.out,CLOSE_FILE); |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
82 |
f304c108aa1f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hyphy/ commit 00684bab4c9e740cfa6a39abc444380e6818fd97"
iuc
parents:
diff
changeset
|
83 |