monkfan has asked for the wisdom of the Perl Monks concerning the following question:
and copy it into every of its instance(s) of the set that it belongs to.CONSENSUS: AGAGAAAG 1, Horz OCC: 7 ZSCORE: 0.142138988325903 Number of Submotifs: 3 Vertical Occurence: 10 Score: 7.66666666666667
#!/usr/bin/perl -w use strict; use Data::Dumper; use Carp; my %bighash; my $org = 'mus09r'; my @all; my @temp; my @temp2; my @ins_grp; my ( $cons, $hor_oc ); while ( my $line = <DATA> ) { chomp $line; if ( $line =~ /CONSENSUS: \s ([ATCGSN]+ \s \d+), \s Horz \s OCC: \s ( +\d+)/xms ) { @temp = (); ( $cons, $hor_oc ) = ( $1, $2 ); push @temp, ( $cons, $hor_oc ); } elsif ( $line =~ /ZSCORE (?:.*) (\d+\.\d+|NA)$/xms ) { my $zscore = $1; push @temp, $zscore; } elsif ( $line =~ /^Number (?:.*) (\d+)/xms ) { my $nb_sb = $1; push @temp, $nb_sb; } elsif ( $line =~ /^Vertical (?:.*) (\d+)/xms ) { my $vert_occ = $1; push @temp, $vert_occ; } elsif ( $line =~ /Score: \s (.*)$/xms ) { my $score = $1; push @ins_grp, $score; } elsif ( $line =~ /\d+,-\d+,[ATCG]+$/xms ) { push @ins_grp, $line; } elsif ( $line =~ /^$/xms ) { push @temp2, [(@temp,@ins_grp)] if (@ins_grp); @ins_grp = (); } elsif ( $line =~ /\^+/xms ) { push @all, [@temp2]; } } $bighash{$org} = [@all]; print Dumper \%bighash ; __DATA__ Total Consensus: 448 CONSENSUS: AGAGAAAG 1, Horz OCC: 7 ZSCORE: 0.142138988325903 Number of Submotifs: 3 Vertical Occurence: 10 Score: 7.66666666666667 PATTERN: 3 B -2 A 1,-424,CAGAGACAGGGGAGAGATAG 1,-338,AAGAGAAAGGGAGGAGAGGC 1,-349,AAGAGGGGAGGAAGAGAAAG Score: 7.66666666666667 PATTERN: 3 C -3 F -4 E 1,-337,AGAGAAAGGGAGGAGAGGCA 1,-348,AGAGGGGAGGAAGAGAAAGG 1,-423,AGAGACAGGGGAGAGATAGA ^^^^^^^^^^^^^^ CONSENSUS: AGAAACAG 1, Horz OCC: 7 ZSCORE: 1.36112386682747 Number of Submotifs: 4 Vertical Occurence: 4 Score: 7.66666666666667 PATTERN: 3 C -2 F 1,-383,TGAGAAACAG 1,-319,CAAGAAACAG 0,-457,CTTGAAACAG ^^^^^^^^^^^^^^
$VAR1 = { 'mus09r' => [ [ 'AGAGAAAG 1', '7', '0.142138988325903', '3', '0', [ '7.66666666666667', '1,-337,AGAGAAAGGGAGGAGAGGCA', '1,-348,AGAGGGGAGGAAGAGAAAGG', '1,-423,AGAGACAGGGGAGAGATAGA' ] ], [ 'AGAGAAAG 1', '7', '0.142138988325903', '3', '0', [ '7.66666666666667', '1,-424,CAGAGACAGGGGAGAGATAG', '1,-338,AAGAGAAAGGGAGGAGAGGC', '1,-349,AAGAGGGGAGGAAGAGAAAG' ], ], [ 'AGAAACAG 1', '7', '1.36112386682747', '4', '4', [ '7.66666666666667', '1,-383,TGAGAAACAG', '1,-319,CAAGAAACAG', '0,-457,CTTGAAACAG' ] ] ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem of Duplicating an Array while Parsing Text
by GrandFather (Saint) on Dec 20, 2005 at 04:08 UTC | |
by monkfan (Curate) on Dec 20, 2005 at 08:15 UTC | |
by GrandFather (Saint) on Dec 20, 2005 at 11:09 UTC | |
by tphyahoo (Vicar) on Dec 20, 2005 at 09:03 UTC | |
|
Re: Problem of Duplicating an Array while Parsing Text
by QM (Parson) on Dec 20, 2005 at 17:05 UTC |