Skip to content

Instantly share code, notes, and snippets.

@irisdyoung
Last active March 10, 2020 15:29
Show Gist options
  • Save irisdyoung/266427969f99f869bf9aaaf684a1497e to your computer and use it in GitHub Desktop.
Save irisdyoung/266427969f99f869bf9aaaf684a1497e to your computer and use it in GitHub Desktop.
Jiffy script to tell you the positions of residues

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:

  1. set up a counter starting at 0

  2. feed me the contents of a file called "seq"

  3. for every character in that input:

3a. increment the counter

3b. if the character is an asterisk (*), print the counter with no newline character

  1. 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 :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment