Skip to content

Instantly share code, notes, and snippets.

@cyklee
Created November 25, 2018 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyklee/4f808ebb6a10a1428621d197e3f55353 to your computer and use it in GitHub Desktop.
Save cyklee/4f808ebb6a10a1428621d197e3f55353 to your computer and use it in GitHub Desktop.
sed and shell script to find pattern from a column and replacing it with entries from another column - handy for tidying up a newick phylogenetic tree
paste Short.name.txt Proper.name.txt | while read n k; do sed -i "s/$n/$k/g" tree.nwk; done
@cyklee
Copy link
Author

cyklee commented Nov 25, 2018

If the name files contained "/", it will clash with sed. In that case, the delimiter can be replaced with other characters e.g. "s@$n@$k@g"

@cyklee
Copy link
Author

cyklee commented Nov 25, 2018

In addition, newick tree uses ":" as separator, so it can be used within the branch tip names.

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