2017年1月25日 星期三

樹莓派看溫度

樹莓派Pi 3安裝raspbian,下面的指令可以看系統溫度:
  • cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
  • cpuTemp1=$(($cpuTemp0/1000))
  • cpuTemp2=$(($cpuTemp0/100))
  • cpuTempM=$(($cpuTemp2 % $cpuTemp1))
  • echo CPU temp"="$cpuTemp1"."$cpuTempM"'C"
  • echo GPU $(/opt/vc/bin/vcgencmd measure_temp)
參考《Raspberry Pi onboard temp sensors in Raspbian》的回應

_EOF_

2017年1月17日 星期二

統計PDB中蛋白質鍊的長度

只要依序執行下面五個指令就能夠拿到所有protein chains的長度與敘述:
  • wget ftp://ftp.wwpdb.org/pub/pdb/derived_data/pdb_seqres.txt
  • grep "mol:protein" pdb_seqres.txt | sed -e's/  /!/' | cut -d'!' -f1 | sed -e's/^>//' | cut -d' ' -f1 > protein_seqres.id
  • grep "mol:protein" pdb_seqres.txt | sed -e's/  /!/' | cut -d'!' -f1 | sed -e's/^>//' | cut -d' ' -f3 | cut -d':' -f2 > protein_seqres.length
  • grep "mol:protein" pdb_seqres.txt | sed -e's/  /!/' | cut -d'!' -f2 > protein_seqres.des
  • paste -d'\t' protein_seqres.id protein_seqres.length protein_seqres.des > protein_seqres.csv

2017年1月16日 星期一

PDB裡面最長和最短的蛋白質序列

依序執行下述指令就知道PDB裡面最長與最短的序列:
  1. wget ftp://ftp.wwpdb.org/pub/pdb/derived_data/pdb_seqres.txt
  2. grep -e "mol:protein" -A 1 pdb_seqres.txt | sed '/^--$/d' | grep "^>" | cut -d' ' -f3 | cut -d':' -f2 | sort -n | head -n 1
  3. grep -e "mol:protein" -A 1 pdb_seqres.txt | sed '/^--$/d' | grep "^>" | cut -d' ' -f3 | cut -d':' -f2 | sort -n | tail -n 1
上面的Bash指令意思分別是:
  1. 抓所有PDB的序列(fasta format)
  2. 最短的序列,長度是2
  3. 最長的序列,長度是5037

2017年1月13日 星期五

Vi顯示tab與跳行字元

使用 vi 或 vim 編輯程式碼的時候,空白、tab、跳行字元在螢幕上面都是顯示空白。為了要讓程式碼更容易閱讀,參考軟體工匠 R 的筆記中《讓 vim 顯示 tab 和行末的空白字元》一文,直接設定:
  • set listchars=eol:↵,tab:»·,trail:╳,extends:»,precedes:«
  • set list
若要關閉這個功能,則是輸入
  • set nolist
上述參考文獻裡面還有讓空白用顏色等等表現方式

_EOF_