これまでのところ、Perl についてもう少し理解を深めることができました。これは安心です。皆さんに感謝します。私は現在、.fasta ファイルを読み取り、すべての G および C ヌクレオチドを見つけてから、タブ区切りファイルを作成する必要がある別の側面に取り組んでいます。
これらは、過去数日間の私の投稿で、時系列順です。
- タブ区切りのデータから列の値を平均するにはどうすればよいですか... (解決済み)
- 出力ファイルに計算結果が表示されないのはなぜですか? (解決済み)
- .fasta ファイルを使用してシーケンスの相対コンテンツを計算する
- .fasta シーケンスを読み取ってヌクレオチド データを抽出し、次に... (この前の投稿)
最後のクエリはまだ作業中ですが、ある程度の進歩がありました。
背景として、.fasta ファイルは次のようになります。
>label
sequence
>label
sequence
>label
sequence
.fasta ファイルを開く方法がわからないので、どのラベルがどのラベルに適用されるかはわかりませんが、遺伝子にはgag
、pol
、またはenv
. 何をしているのかを知るために .fasta ファイルを開く必要がありますか、それとも上記の形式を使用して「盲目的に」行うことができますか?
とにかく、私が持っている現在のコードは次のとおりです。
#!/usr/bin/perl -w
# This script reads several sequences and computes the relative content of G+C of each sequence.
use strict;
my $infile = "Lab1_seq.fasta"; # This is the file path
open INFILE, $infile or die "Can't open $infile: $!"; # This opens file, but if file isn't there it mentions this will not open
my $outfile = "Lab1_SeqOutput.txt"; # This is the file's output
open OUTFILE, ">$outfile" or die "Cannot open $outfile: $!"; # This opens the output file, otherwise it mentions this will not open
my $sequence = (); # This sequence variable stores the sequences from the .fasta file
my $GC = 0; # This variable checks for G + C content
my $line; # This reads the input file one-line-at-a-time
while ($line = <INFILE>) {
chomp $line; # This removes "\n" at the end of each line (this is invisible)
if($line =~ /^\s*$/) { # This finds lines with whitespaces from the beginning to the ending of the sequence. Removes blank line.
next;
} elsif($line =~ qr(^\s*\#/)) { # This finds lines with spaces before the hash character. Removes .fasta comment
next;
} elsif($line =~ /^>/) { # This finds lines with the '>' symbol at beginning of label. Removes .fasta label
next;
} else {
$sequence = $line;
}
$sequence =~ s/\s//g; # Whitespace characters are removed
print OUTFILE $sequence;
}
コードは、空白なしでシーケンス全体をテキスト ファイルに出力するようになりました。唯一の問題は、シーケンスがどこで開始または終了したかがわからないため、各遺伝子にどのシーケンスが適用されるかがわからないことです. 停止/開始コドンは私に指示を与えるはずですが. それを考慮して、コードを変更/追加して、シーケンス内の G + C の量を計算し、それぞれの G/C コンテンツに関連付けられた遺伝子の名前を含むタブ区切りファイルに出力する方法を教えてください。 ?
G / Cを見つけてそれぞれの数を集計する方法に関して、上記のコードと同様の方法でガイダンスを提供できる人からの連絡を楽しみにしています.