Maasha::Common::error( qq(Genome $options{ $opt } not found in "$ENV{ 'BP_DATA' }/genomes/") );
}
}
- elsif ( $opt eq "terminal" and not $options{ $opt } =~ /^(svg|post|dumb)/ )
+ elsif ( $opt eq "terminal" and not $options{ $opt } =~ /^(svg|post|dumb|x11)/ )
{
Maasha::Common::error( qq(Bad --$opt argument "$options{ $opt }") );
}
# Returns nothing.
- my ( $data_in, $file, $num, $records, $record, $soft_index, $fh, @platforms, $plat_table, @samples, $sample, $old_end );
+ my ( $data_in, $file, $num, $records, $record, $soft_index, $fh, @platforms, $plat_table, @samples, $sample, $old_end, $skip );
while ( $record = get_record( $in ) ) {
put_record( $record, $out );
foreach $file ( @{ $options->{ "files" } } )
{
+ print STDERR "Creating index for file: $file\n" if $options->{ "verbose" };
+
$soft_index = Maasha::NCBI::soft_index_file( $file );
$fh = Maasha::Common::read_open( $file );
- @platforms = grep { $_->[ 0 ] =~ /PLATFORM/ } @{ $soft_index };
+ @platforms = grep { $_->{ "SECTION" } =~ /PLATFORM/ } @{ $soft_index };
+
+ print STDERR "Getting platform tables for file: $file\n" if $options->{ "verbose" };
- $plat_table = Maasha::NCBI::soft_get_platform( $fh, $platforms[ 0 ]->[ 1 ], $platforms[ -1 ]->[ 2 ] );
+ $plat_table = Maasha::NCBI::soft_get_platform( $fh, $platforms[ 0 ]->{ "LINE_BEG" }, $platforms[ -1 ]->{ "LINE_END" } );
- @samples = grep { $_->[ 0 ] =~ /SAMPLE/ } @{ $soft_index };
+ @samples = grep { $_->{ "SECTION" } =~ /SAMPLE/ } @{ $soft_index };
- $old_end = $platforms[ -1 ]->[ 2 ];
+ $old_end = $platforms[ -1 ]->{ "LINE_END" };
foreach $sample ( @samples )
{
- if ( $options->{ "samples" } ) {
- next if grep { $sample->[ 0 ] !~ $_ } @{ $options->{ "samples" } };
- }
+ $skip = 0;
+ $skip = 1 if ( $options->{ "samples" } and grep { $sample->{ "SECTION" } !~ /$_/ } @{ $options->{ "samples" } } );
+
+ print STDERR "Getting samples for dataset: $sample->{ 'SECTION' }\n" if $options->{ "verbose" } and not $skip;
- $records = Maasha::NCBI::soft_get_sample( $fh, $plat_table, $sample->[ 1 ] - $old_end - 1, $sample->[ 2 ] - $old_end - 1 );
+ $records = Maasha::NCBI::soft_get_sample( $fh, $plat_table, $sample->{ "LINE_BEG" } - $old_end - 1, $sample->{ "LINE_END" } - $old_end - 1, $skip );
foreach $record ( @{ $records } )
{
$num++;
}
- $old_end = $sample->[ 2 ];
+ $old_end = $sample->{ "LINE_END" };
}
close $fh;
@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;