snippet for selecting only differing residues based on an alignment: run the one-liner below on a file “seq” containing the alignment lines only, with all newline characters removed:
export j=0; cat seq | while read -n 1 char; do export j=$((j+1)); if [ "$char" != "*" ]; then echo -n "${j},"; fi; done; echo
in pseudocode, that's:
-
set up a counter starting at 0
-
feed me the contents of a file called "seq"
-
for every character in that input:
3a. increment the counter
3b. if the character is an asterisk (*), print the counter with no newline character
- print a new line at the end
example seq file contents:
***.**************::.**:***:*:***.****:********:***********.
expected output:
13,14,21,25,31,40,42,60,61,
Chimera wants this output in something like the form:
color red #0:324,2461,2345,1233
so in addition to adding any relevant commands up front, be sure to remove the last comma from the output or it will color the whole thing :(