大家。我是perl的新手,在我学习的过程中学习。我一直在研究一种读取excel格式(.csv)的qPCR数据的程序。我已设法编写它,因此它询问文件,检索它,只读取和打印数据只有一部分数据。我目前的节目有点混乱。我需要它做的是在用户输入文件名加扩展名后读取文件,读取文件,计算并打印重复样本的平均值。
这是当前的程序:
#!/usr/bin/perl -w
use strict;
print "Please input the qPCR file that you wish to have analyzed: \n";
my $pcrFile = <STDIN>;
chomp $pcrFile;
my $pcr = open_qPCR($pcrFile); # returns a reference to a list of file lines
my $ref_pcr = getFluorescence($pcr); # this will store all the qPCR record information
# print a report
foreach my $thisWell ( keys %$ref_pcr ) {
my @cycle_data = @{ $$ref_pcr{$thisWell}{'data'} }; # a way to coerce an address using @{}
my @sorted_data = sort { $a <=> $b } @cycle_data;
# print the columns of the table
print "$thisWell\t";
print $$ref_pcr{$thisWell}{'detector'}, "\t";
print $#cycle_data+ 1, "\t\t"; # top cycle number
printf "%3.1f \t\t", $sorted_data[0]; # minimum
print $sorted_data[-1], "\n"; # maximum
}
print "\n";
sub open_qPCR {
my $filename = shift @_;
open PCR, "<", $filename or die "\n\nI couldn't find the file $filename\n\n";
my @bigList = <PCR>; # Pick up the entire file in one string
my $wholefile = join '', @bigList;
close PCR;
$wholefile =~ s/\r\n/\n/g; # convert CRLF to just LF, to convert Windows case to Unix
$wholefile =~ s/\r/\n/g;
my @pcrLines = split "\n", $wholefile;
return \@pcrLines;
}
sub getFluorescence {
my $pcr = shift @_; # reference to list of file lines
my $wholeFile = join( "\n", @$pcr );
my @dividedFile = split( "End\n", $wholeFile );
print "My divided file has ", $#dividedFile + 1, " parts, and the first part has length ",
length( $dividedFile[0] ), "\n";
my @dataPart = split( "\n", $dividedFile[1] );
print "the lines of the second part of the divided file are ", join( "\n", @dataPart ), "\n";
exit();
my %wells;
my $titleLine = shift @$pcr;
foreach my $thisLine (@$pcr) { # these are data lines now
if ($thisLine) {
my @fields = split ",", $thisLine; # this is a comma delimited file
my $wellNumber = shift @fields; # this is the qPCR well information
$wells{$wellNumber}{'detector'} = shift @fields; # this is the amplicon name
$wells{$wellNumber}{'sample'} = shift @fields; # this is the sample description
$wells{$wellNumber}{'data'} = \@fields; # save a memory reference
}
}
return \%wells;
}
一团糟......我知道。
试图找出如何附加excel文件,以便我可以获得一些反馈。我真的可以使用这个帮助。感谢您对noobie的耐心。