-sub soft_parse
-{
- # Martin A. Hansen, February 2008.
-
- # !!! NOT USED ANYMORE !!! #
-
- # Reads in and parses a file in SOFT format.
-
- my ( $path, # full path to SOFT file
- ) = @_;
-
- # Returns a list.
-
- my ( $fh, @lines, $i, $c, $num, %key_hash, @fields, %id_hash, $id, $seq, $count, $record, @records, $platform_id, $sample_id, $sample_title );
-
- $fh = Maasha::Common::read_open( $path );
-
- @lines = <$fh>;
-
- close $fh;
-
- chomp @lines;
-
- $i = 0;
-
- $num = 1;
-
- while ( $i < @lines )
- {
- if ( $lines[ $i ] =~ /^\^PLATFORM = (.+)/ )
- {
- $platform_id = $1;
- }
- elsif ( $lines[ $i ] =~ /^!platform_table_begin$/ )
- {
- @fields = split "\t", $lines[ $i + 1 ];
-
- for ( $c = 0; $c < @fields; $c++ ) {
- $key_hash{ $fields[ $c ] } = $c;
- }
-
- $c = $i + 2;
-
- while ( $lines[ $c ] !~ /^!platform_table_end$/ )
- {
- @fields = split "\t", $lines[ $c ];
-
- $id_hash{ $fields[ $key_hash{ "ID" } ] } = $fields[ $key_hash{ "SEQUENCE" } ];
-
- $c++;
- }
-
- $i = $c;
- }
- elsif ( $lines[ $i ] =~ /^\^SAMPLE = (.+)/ )
- {
- $sample_id = $1;
- }
- elsif ( $lines[ $i ] =~ /^!Sample_title = (.+)/ )
- {
- $sample_title = $1;
- }
- elsif ( $lines[ $i ] =~ /^!sample_table_begin/ )
- {
- undef %key_hash;
-
- @fields = split "\t", $lines[ $i + 1 ];
-
- for ( $c = 0; $c < @fields; $c++ ) {
- $key_hash{ $fields[ $c ] } = $c;
- }
-
- $c = $i + 2;
-
- while ( $lines[ $c ] !~ /^!sample_table_end$/ )
- {
- undef $record;
-
- @fields = split "\t", $lines[ $c ];
-
- $id = $fields[ $key_hash{ "ID_REF" } ];
- $seq = $id_hash{ $id };
- $count = $fields[ $key_hash{ "VALUE" } ];
-
- $seq =~ tr/./N/;
-
- $record->{ "SAMPLE_TITLE" } = $sample_title;
- $record->{ "SEQ" } = $seq;
- $record->{ "SEQ_NAME" } = join( "_", $platform_id, $sample_id, $num, $count );
-
- push @records, $record;
-
- $c++;
- $num++;
- }
-
- $i = $c;
-
- $num = 1;
- }
-
- $i++;
- }
-
- return wantarray ? @records : \@records;
-}
-
-