Some useful commands - 18liedan/genomics_memo GitHub Wiki
Last updated: April 9th, 2025
keyboard shortcuts
control+A 行の先頭までカーソルを移動
control + E 行の最後までカーソルを移動
control + K カーソルより後ろの文字を削除
control + L 現在の行が一番上になるように画面をスクロール(画面のクリア)
control + H 直前の1文字を削除(backspace と同じ)
control + D カーソルの位置の文字を削除(何も入力されていない時に行うとログアウト)
alt + → 単語の区切れ目までカーソルを移動
alt + ← 同上
| : "pipe". It is used to pipe one command into another. That is, it directs the output from the first command into the input for the second command.
command1 & command2: execute command2 after execution of command1 has finished
command1 && command2: execute command2 only if execution of command1 has finished successfully
command1 || command2: execute command2 only if execution of command1 has finished unsuccessfully
useful commands for frequent use
echo $UID
shows UID in ssh server
htop
checks CPU/RAM/etc. usage
free -h
checks RAM usage summary
lscpu
shows CPU details
move files without third party GUI
scp -P 22 file.ext [email protected]:~/directory
filezilla set ssh key file
- Select Edit › Settings… › Connection › SFTP
- Press the Add key file… button
- Press Command-Shift-G to bring up a path selection window and type
~/.ssh
- Select the
id_rsa
key file and click Open (this imports the key) - Click OK to close the Settings dialog
- Open File › Site Manager…
- Select the site with which you want to use the key
- Choose Protocol SFTP and select Logon Type Normal.
- If the file has a password, enter in the Password field.
- Click Connect and you see your files.
tmux for avoiding crashing
#for example
ssh a002
#make new session
tmux new -s session250203
#ctrlb then d detaches from session but runs in background
#go back to session
tmux attach-session -t session250203
nohup usage
nohup bash -c 'command here' > output.log
#e.g. combined with for loop
nohup bash -c 'for accession in $(cut -f 2 PRJDB13385-info.tsv); do printf "\n Working on: ${accession}\n\n"; fasterq-dump --split-files ${accession} -e 16 -p; done' > PRJDB13385_output.log
splitting big fasta into smaller ones
awk 'BEGIN {n_seq=0;} /^>/ {if(n_seq%1000==0){file=sprintf("myseq%d.fa",n_seq);} print >> file; n_seq++; next;} { print >> file; }' < sequences.fa
changing fastq to fasta
on a linux:
cat input.fastq | awk 'NR % 4 == 1 {print ">" $0 } NR % 4 == 2 {print $0}' > output.fasta
on a mac:
awk '(NR - 1) % 4 < 2' test.fq | sed 's/@/>/' > test.fa