2012-03-17 4 views
2

私が続行する前に、私はこれまでの私の以前の問題に読者を紹介したいと思っていました。ヌクレオチドデータを抽出してTabDelimitedファイルに書き込むための.fastaシーケンスを読む

これらは年代順に、過去数日間の私の記事だった:

  1. How do I average column values from a tab-separated data...(解決)
  2. Why do I see no computed results in my output file?(解決)
  3. Using a .fasta file to compute relative content of sequences

私が上で述べたように、あなた、私は最初の2つの質問を把握することができました。そして私は本当にそれから学んできました。私は本当に感謝しています。これについて何も知らず、彼がそうでないように感じる人のために、助けは実質的には神の御子でした。

最後のクエリは未解決のままであり、これが続きます。私はいくつかのおすすめのテキストを見ましたが、月曜日前にこれを完成させようとしているので、何かを完全に見落としたかどうかは分かりません。いずれにしても、私はその仕事を試してみました。

だけ知っているので、タスクはに開いており、.fastaファイル(私はハレルヤ、私は最終的にかなりよく何かを釘付けしたと思う!)、各シーケンスを読んを読んで、相対G +を計算しますCヌクレオチド含有量、次いでのTABDelimitedファイルへの書き込み、および遺伝子の名前およびそれぞれのG + C含有量

私はこれを試してみましたが、私が後になった結果を提供するためにプログラムを実行する準備ができていないことを知っています。だから私はあなた達に手を差し伸べていますもう一度いくつかのガイダンス、またはこれについてどうやって行くのかの例について説明します。私の以前の解決されたクエリと同様に、私はすでにそれをやったことと同じようなスタイルにしたいと思っています - それが最も便利で効率的な方法ではないかもしれません。それはちょうど私がそれをスパムしているように見えるにもかかわらず、私は方法の各ステップをやっていることを知ることができます!

はとにかく、.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) 

    foreach my $line ($infile) { 
     if($line = ~/^\s*$/) {   # This finds lines with whitespaces from the beginning to the ending of the sequence. Removes blank line. 
      next; 
     } elsif($line = ~/^\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 
     return $sequence; 
    } 

何の正しいここにいる場合、私はわからないんだけど、それは(最後の行を超え、構文エラーARライン35で私を残し実行し、したがってそこには何もありません!)。それは 'EOF'で語った。それは私が指摘できるすべてについてです。さもなければ、私は各シーケンス中のヌクレオチドG + Cの量をどのように計算し、次にこれを出力.txtファイルで適切に集計するかを調べようとしています。私はこれがTABDelimitedファイルの意味ですか?

いずれにしても、このクエリが長すぎると思われる場合は申し訳ありませんが、「ダム」またはリピートしていますが、この情報に直接関係する情報は見つかりませんでしたので、可能であれば各ステップの説明も!

親友。

答えて

2

最後にもう1つのブレースがあります。これはうまくいくはずです:

#!/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 =~ /^\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; 
} 

また、あなたの復帰ラインを編集しました。戻り値はループを終了します。私はあなたが望むのはそれをファイルに印刷することだと思うので、私はそれをしました。タブで区切られた形式にするには、最初にさらに変換を行う必要があります。

+0

多くのエラーが発生しているようです。それが不完全なのかどうか疑問に思います。私は現在、配列内のヌクレオチドの量をどのようにして計算するかについて読んでいます。私はこれが別のループを必要とするだろうと思うが、用語はまだ私を超えています。 – PkC

+1

ああ、申し訳ありませんが、私はforeach行の問題を逃した。 WHILEループはすでに$ infileから各行を繰り返し処理するので、foreachループは必要ありません。私は上記のコードを調整し、それが問題を解決するはずです。 – Ilion

+0

Hrmあなたの正規表現がコメントを探していると、おそらくあなたにも問題が起こっています。あなたは、elsif($ line =〜/^\ s *#/){{}〜 '} elsif($ line =〜qr(^ \ s *#/)){' qrは引用符で囲まれた正規表現を作る。 – Ilion

関連する問題