handy_custom_functions
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| handy_custom_functions [2021/05/12 14:07] – created 168.91.18.151 | handy_custom_functions [2023/07/25 12:08] (current) – 134.190.232.186 | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| function coltab { | function coltab { | ||
| column -t -s $' | column -t -s $' | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | I will discuss here some more custom functions that I found are very useful in my daily workflow. To add these functions to your system, simply add them to your '' | ||
| + | |||
| + | |||
| + | ===Reformatting FASTA files downloaded from NCBI=== | ||
| + | |||
| + | For most of my analyses, the header format of NCBI FASTA files is very annoying. This function will convert the annoying format into ''> | ||
| + | |||
| + | < | ||
| + | # format NCBI headers to something readable | ||
| + | function reformat_ncbi_headers { | ||
| + | newfile=${1%.fasta}.hdfmt.fasta | ||
| + | cp $1 $newfile | ||
| + | sed -i -r -e '/ | ||
| + | sed -i -r -e '/ | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===Replacing work names with final names for publication=== | ||
| + | |||
| + | In my experience I do my analyses with new genomes / transcriptomes etc I work with ' | ||
| + | |||
| + | < | ||
| + | # replace taxanames in trees, fasta, etc | ||
| + | function replace_names { | ||
| + | input=$1 | ||
| + | mappingfile=$2 | ||
| + | cp $input $input.nms | ||
| + | cat $mappingfile | while read SEARCH REPLACE; do | ||
| + | sed -i -r " | ||
| + | done | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===Some other functions=== | ||
| + | |||
| + | < | ||
| + | # fasta to phylip | ||
| + | # depends on trimal | ||
| + | function fa2phy { | ||
| + | trimal -in $1 -out ${1%.*}.phylip -phylip | ||
| + | } | ||
| + | |||
| + | # reverse complement function | ||
| + | function revcomp { | ||
| + | tr " | ||
| + | } | ||
| + | |||
| + | # sum up all numbers in a list | ||
| + | function total { | ||
| + | tr ' | ||
| } | } | ||
| </ | </ | ||
handy_custom_functions.1620839222.txt.gz · Last modified: by 168.91.18.151
