@fields = split "\t", $lines[ $c ];
$id_hash{ $fields[ $key_hash{ "ID" } ] } = $fields[ $key_hash{ "SEQUENCE" } ];
-
+
$c++;
}
$first = 1;
- $i = 0;
- $c = 0;
+ $i = 0;
+ $c = 0;
while ( $line = <$fh> )
{
if ( $line =~ /^\^/ )
{
- push @index, [ $line, $i ];
+ push @index, {
+ SECTION => $line,
+ LINE_BEG => $i,
+ };
if ( not $first )
{
- push @{ $index[ $c - 1 ] }, $i - 1;
+ $index[ $c - 1 ]{ "LINE_END" } = $i - 1;
}
else
{
$i++;
}
- push @{ $index[ $c - 1 ] }, $i - 1;
+ $index[ $c - 1 ]{ "LINE_END" } = $i - 1;
close $fh;
{
# Martin A. Hansen, June 2008.
- # Given a filehandle to a SOFT file parses the platform table
+ # Given a filehandle to a SOFT file parses all the platform tables
# which is returned.
my ( $fh, # filehandle
{
@fields = split "\t", $lines[ $c ];
- $id_hash{ $fields[ $key_hash{ "ID" } ] } = $fields[ $key_hash{ "SEQUENCE" } ];
+ $id_hash{ $fields[ $key_hash{ "ID" } ] } = $fields[ $key_hash{ "SEQUENCE" } ] || $fields[ $key_hash{ "ID" } ];
$c++;
}
{
# Martin A. Hansen, June 2008.
- # Given a filehandle to a SOFT file parses the platform table
- # which is returned.
+ # Given a filehandle to a SOFT file and a platform table
+ # parses sample records which are returned.
- my ( $fh, # filehandle
- $plat_table, # hashref with platform tables
- $beg, # line number where sample table begin
- $end, # line number where sample table end
+ my ( $fh, # filehandle
+ $plat_table, # hashref with platform table
+ $beg, # line number where sample table begin
+ $end, # line number where sample table end
+ $skip, # flag indicating that this sample table should not be parsed.
) = @_;
- # Returns hashref
+ # Returns list of hashref
my ( $line, @lines, $i, $c, $platform_id, @fields, %key_hash, $num, $sample_id, $sample_title, $id, $seq, $count, @records, $record );
while ( $line = <$fh> )
{
- chomp $line;
+ if ( not $skip )
+ {
+ chomp $line;
+
+ push @lines, $line if $i >= $beg;
+ }
- push @lines, $line if $i >= $beg;
-
last if $i == $end;
$i++;
}
+ if ( $skip ) {
+ return wantarray ? () : [];
+ }
+
$i = 0;
$num = 1;