私は、サブルーチンを起動することによって、2つのスクリプトを1つのスクリプトに結合しようとしています。問題は、私が1つの下付き文字から別の下付き文字に自分の入力を向けるのに問題があることです。複数のスクリプトでこれを行う必要があります。これらは、それらのリスト全体の最初の2つのスクリプトです。サブルーチンperlを使用してスクリプトを1つのスクリプトに結合する
コード1で生成されたデータは、コード2に送信する必要があります。コード2では、生成されたファイルと元のファイルを比較する追加のステップがあります。
Code 1:
subst_head_1($infile);
sub subst_head_1
{
##this code helps organise the file in a way that it makes it more convenient for the file to be pushed into a hash for later analysis
##opening file
my $i = $_[0];
open(IN, "<$i") || die "\n Error: Cannot open the infile: $infile\n";
# open(OUT, ">op.fa");
##giving all the headers in the original file line numbers
my $lineno = 1;
while(<IN>)
{
chomp;
if ($_ =~ />/)
{
$_ = $lineno++,"\t", $_ ,"\n";
subst_head_2($_);
}
}
}
##file organised in the following format; eg., "2>CBB_deg7180000000601_1100_2101_3"
sub subst_head_2
{
##opening files with header information(result of head-subs-1) and the original sequence(submitted query file) file for further info
my $i = $_[0];
#print $i;
my $i_1 = $_[1];
##pushing file(headerinfo.txt) with the header information into a hash
open(IN, "<$i");
my @file = <IN>;
my $file2 = join('', @file);
my %hash = split(/[\t\n]/, $file2);
##opening the original file with the sequence information into an array
open(IN1, "<$i_1");
my @fila = <IN1>;
##foreach of the sequnces in the sequence file
foreach my $fila(@fila)
{
##Substituting any "*" in the file, if any, especially at the end of some of sequnces which were present in the file
$fila =~ s/\*//g;
##regex for matching with the header information in the file with all the query information
if($fila =~ /^\>(\S+).*/)
{
##putting info(eg., CBB_deg7180000000601_1100_2101_3) into a variable $user
my $user = $1;
foreach my $has(sort keys %hash)
{
##regex for the values in the key-value relationship in the headerinfo file
if($hash{$has} =~ /^\>(\S+).*/)
{
##putting info(eg., CBB_deg7180000000601_1100_2101_3) into a variable $user1
my $user1 = $1;
##is the info the same?; if it is, then substitute it in the original with key from headerinfo.txt
if($user eq $user1)
{
##substitute header in the original file with the unique number;
$fila =~ s/^\>(\S+).*\n/>$has\n/;
}
}
}
}
}
print @fila;
}
グローバル変数はどうですか?または、あるサブの結果を別のサブに渡すか? – Robert
こんにちは、それは問題です。私はどのように1つのサブから別の結果を渡すかを理解することができません。 –
'' 'subst_head_2(subst_head_1(file))' 'の行に沿って何か試してみましたか?' ' – tomc