
そこで、私は RNA シーケンス データ分析に「tuxedo」というプロトコルを使用しています。これは、シェル スクリプトに関連する技術的な質問です。これはコマンド ラインで実行できますが、特に問題はありません。クラスターで実行しているので、タスクを自動化できるスクリプトを使用したいと思います。
したがって、プロトコル コマンドは次のようになります。
トップハット
カフスボタン
カフマージ
カフディフ
最初のコマンドは、すべてのアライメントを実行し、次のコマンドで使用する必要があるファイルを生成し
cufflinks
ます。cuffmerge
cuffdiff
これらの各コマンドを呼び出してタスクを実行できる簡単なシェル スクリプトの作成を手伝ってくれる人はいませんか。
どのような助けでも大歓迎です。
議論
tophat -p 8 -G genes.gtf -o C1_R1_thout genome C1_R1_1.fq C1_R1_2.fq
cufflinks -p 8 -o C1_R1_clout C1_R1_thout/accepted_hits.bam
cuffmerge -g genes.gtf -s genome.fa -p 8 assemblies.txt
cuffdiff -o diff_out -b genome.fa -p 8 –L C1,C2 -u merged_asm/merged.gtf \
./C1_R1_thout/accepted_hits.bam,./C1_R2_thout/accepted_hits.bam,./C1_R3_thout/accepted_hits.bam \
./C2_R1_thout/accepted_hits.bam,./C2_R3_thout/accepted_hits.bam,./C2_R2_thout/accepted_hits.bam
ここで、「p」はプロセッサの数に対応し、「-o」は出力ディレクトリに対応し、残り「-g」は、アライメントされる RAW 読み取りに注釈を付けるために使用される注釈ファイルに対応します。
答え1
シンプルで脆弱な解決策
hailmary.shという簡単なスクリプトを書いてみましょう。
#!/bin/bash
#The first line should always be just as it is above
#This script is called hailmary.sh
#because we run this script and we need to pray
#that all four commands will run correctly
#If one of them fail, you may not get the results
tophat -p 8 -G genes.gtf -o C1_R1_thout genome C1_R1_1.fq C1_R1_2.fq
cufflinks -p 8 -o C1_R1_clout C1_R1_thout/accepted_hits.bam
cuffmerge -g genes.gtf -s genome.fa -p 8 assemblies.txt
cuffdiff -o diff_out -b genome.fa -p 8 –L C1,C2 -u merged_asm/merged.gtf ./C1_R1_thout/accepted_hits.bam,./C1_R2_thout/accepted_hits.bam,./C1_R3_thout/accepted_hits.bam ./C2_R1_thout/accepted_hits.bam,./C2_R3_thout/accepted_hits.bam,./C2_R2_thout/accepted_hits.bam
上記の行すべてを「#」で始まる行も含めてコピーしてgeditに貼り付け、hailmary.shとして保存します。
Nautilusで、作成したファイルを右クリックして選択します
Properties
。Permissions
タブに移動して、 ファイルをプログラムとして実行できるようにする。あるいは、ターミナルで次のように入力します。
chmod +x hailmary.sh
ターミナルでスクリプトを実行するには、次のように入力します。
./ヘイルマリー.sh
名前の前の は./
必須であり、ファイルが現在のディレクトリの場所にあることを前提としています。 などのパスにあるフォルダにファイルを配置する場合、/home/<userid>/bin
は必要ありません./
。別の場所に配置する場合は、次のようにパス全体を記述する必要があります。
/home/<userid>/myspecialfolder/hailmary.sh
4 つのコマンドとその引数は 4 つの別々の行にあることに注意してください。これらを 1 行にまとめる場合は、 または で区切る必要があります&&
。別々の行にある場合は;
は必要ありません。;
いずれの場合も、最初のコマンドが完了する (またはクラッシュする) まで、2 番目のコマンドは開始されません。
このアプローチの問題点は、2 番目のコマンドを実行する前に最初のコマンドが正常に実行されたかどうかをチェックしないことです。そのため、tophat
何らかの理由で失敗した場合、スクリプトは cufflink、cuffmerge、cuffdiff のシーケンスを続行します。これが、このスクリプトを scrip と呼ぶ理由ですhailmary.sh
。
tophat の出力をチェックするスクリプト
#!/bin/bash
#The first line should always be just as it is above
#This script is called hailmary2.sh
#This script runs tophat
#then checks for the existance of the output file
#If the output is found, it runs the rest
tophat -p 8 -G genes.gtf -o C1_R1_thout genome C1_R1_1.fq C1_R1_2.fq
if [[ -f "./C1_R1_thout/accepted_hits.bam" ]]; then
echo "tophat finished. Proceeding with the rest"
cufflinks -p 8 -o C1_R1_clout C1_R1_thout/accepted_hits.bam
cuffmerge -g genes.gtf -s genome.fa -p 8 assemblies.txt
cuffdiff -o diff_out -b genome.fa -p 8 –L C1,C2 -u merged_asm/merged.gtf ./C1_R1_thout/accepted_hits.bam,./C1_R2_thout/accepted_hits.bam,./#C1_R3_thout/accepted_hits.bam ./C2_R1_thout/accepted_hits.bam,./C2_R3_thout/accepted_hits.bam,./C2_R2_thout/accepted_hits.bamfi
else echo "tophat did not complete"
fi
他の誰かがより洗練された答えを提供するまで、これが役立つことを願っています。