FORMAT that I need <filed1> | <field2>271479 | Papaya leaf curl Guandong virus | Geminiviridae | V1.3_105649 +:75.8 12202 | Lettuce mosaic virus | Potyviridae | V1.3_118815:65.4 116056 | Pelargonium zonate spot virus | Bromoviridae | V1_111931:65.5 45709 | Sabia virus | Arenaviridae | V1_112261:16.8
The actual code I wrote to sort and rank...But this doesnt have the code to accomodate the input data of the form shown above and hence it fails unless I can pre process the data and then run the script. Here is the actual code;271479 | Papaya leaf curl Guandong virus 12202 | Lettuce mosaic virus 116056 | Pelargonium zonate spot virus 45709 | Sabia virus 130556 | Culex nigripalpus NPV
ANY HELP WILL BE GREATLY APPRECIATED. If I can just run a one line perl command to do this on command line that is also fine PLEASE HELP.......THANKS#!/usr/bin/perl # Rank array data in accordance with their P-values # Script author: AR, 2007. my $pvalues_file = $ARGV[0]; my $MAX_TOP_ENTRIES = 20; open PVAL, "< $pvalues_file" or die "Error: Can't open $pvalues_file: +$!"; my %arrays; my @profile_names; while (my $line = <PVAL>) { chomp $line; if ($line =~ /^ARRAYS/) { my $hdr, $i; ($hdr, @profile_names) = split("\t", $line); for $i (0 ... $#{@profile_names}) { $profile_names[$i] =~ s/^\s+//; $profile_names[$i] =~ s/\s+$//; } } else { (my $array_name, @pvalues) = split("\t", $line); for $i (0 ... $#{@profile_names}) { $arrays{$array_name}{$profile_names[$i]} = $pvalues[$i]; } } } foreach $array (keys %arrays) { my $top_count = 0; print "$array\t"; %pvalues = %{$arrays{$array}}; @profiles_sorted = sort { $pvalues{$a} <=> $pvalues{$b} } ( ke +ys %pvalues ); foreach $key (@profiles_sorted) { $top_count++; if ($top_count <= $MAX_TOP_ENTRIES) { print "$key:$pvalues{$key}\t"; } } print "\n"; }
In reply to formating data input by manu7495
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |