unix_shell
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| unix_shell [2021/10/06 09:31] – created 38.20.199.40 | unix_shell [2022/06/23 10:21] (current) – 134.190.232.106 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | upcoming | + | The commonly used scripts collected from previous Github page and course materials. |
| + | |||
| + | 1.How to set up timer for specific script run? | ||
| + | |||
| + | < | ||
| + | # | ||
| + | # Twosday.sh | ||
| + | |||
| + | while true; | ||
| + | do | ||
| + | DATE=`date | cut -d' ' -f4` | ||
| + | #echo $DATE | ||
| + | if [[ $DATE == " | ||
| + | then | ||
| + | echo "this is a test program" | ||
| + | qrsh | ||
| + | sleep 1s | ||
| + | fi | ||
| + | done | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # | ||
| + | # | ||
| + | while true; do echo -ne " | ||
| + | # | ||
| + | while true; do echo -ne "`date +%H: | ||
| + | </ | ||
| + | |||
| + | |||
| + | 2.Here' | ||
| + | |||
| + | < | ||
| + | u Undoes the last change | ||
| + | U Undoes changes to current line | ||
| + | p " | ||
| + | P " | ||
| + | 1p " | ||
| + | 2p " | ||
| + | </ | ||
| + | |||
| + | Multiple FASTA seqeunces into one line https:// | ||
| + | < | ||
| + | awk '/ | ||
| + | |||
| + | </ | ||
| + | |||
| + | Yield the mega FASTA file with each the sequence ID as the file name (linearised FASTA) https:// | ||
| + | |||
| + | < | ||
| + | #split.sh | ||
| + | |||
| + | numseqs=$(grep -c ">" | ||
| + | numlines=$(wc -l < " | ||
| + | if (( " | ||
| + | echo "The fasta file needs to be linearised before this function will work."; | ||
| + | return 1; | ||
| + | fi; | ||
| + | |||
| + | while read line; do | ||
| + | if [ " | ||
| + | header=" | ||
| + | filename=$(echo " | ||
| + | touch " | ||
| + | echo " | ||
| + | else | ||
| + | seq=" | ||
| + | echo " | ||
| + | fi; | ||
| + | done < $1 | ||
| + | |||
| + | #usage: ./split.sh test.fasta | ||
| + | </ | ||
| + | |||
| + | |||
| + | Speed up the script running after chopping the input files (applicable for any scripts) | ||
| + | < | ||
| + | # | ||
| + | |||
| + | while read line | ||
| + | do | ||
| + | |||
| + | / | ||
| + | |||
| + | done <$1 | ||
| + | |||
| + | # usage: ./ | ||
| + | # note:must leave extra line break for gene_id.txt | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | < | ||
| + | #Remove duplicates in fasta file based on ID | ||
| + | |||
| + | https:// | ||
| + | |||
| + | awk '/ | ||
| + | |||
| + | https:// | ||
| + | |||
| + | awk '/ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | https:// | ||
| + | # To install python2 version | ||
| + | pip install pyfasta | ||
| + | # To install python3 version | ||
| + | pip3 install pyfasta | ||
| + | |||
| + | #split a fasta file into 6 new files of relatively even size: | ||
| + | pyfasta split -n 6 original.fasta | ||
| + | </ | ||
| + | |||
| + | Rename file name with the one user wanted https:// | ||
| + | https:// | ||
| + | < | ||
| + | |||
| + | for i in *; do -- mv " | ||
| + | for f in *; do mv " | ||
| + | |||
| + | for i in chr* | ||
| + | do | ||
| + | mv -- " | ||
| + | done | ||
| + | or | ||
| + | |||
| + | for i in chr* | ||
| + | do | ||
| + | NEWNAME=" | ||
| + | mv -- " | ||
| + | done | ||
| + | The " | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | Usage: | ||
| + | rename [ -h|-m|-V ] [ -v ] [ -n ] [ -f ] [ -e|-E perlexpr]*|perlexpr | ||
| + | [ files ] | ||
| + | </ | ||
| + | |||
| + | |||
| + | How to use sort in linux, especially ignore the header to sort special col? | ||
| + | < | ||
| + | (head -n 1 all.txt && tail -n +2 all.txt| sort -n -r -k2) > 123.txt | ||
| + | |||
| + | # sort -n | ||
| + | #sort -r | ||
| + | #sort -k | ||
| + | https:// | ||
| + | </ | ||
| + | |||
| + | <Last updated by Xi Zhang on Oct 6th, | ||
unix_shell.1633523515.txt.gz · Last modified: by 38.20.199.40
