×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

perl-minimum & maximum value

perl-minimum & maximum value

perl-minimum & maximum value

(OP)
input file
Xm_ABL1 Geneious extracted region 1 168 . + . Name=Extracted region from gi|371443098|gb|JH556762.1|;Extracted interval="3512970000000 -> 3514640000000"
Xm_ABL1 Geneious extracted region 169 334 . + . Name=Extracted region from gi|371443098|gb|JH556762.1|;Extracted interval="3717850000000 -> 3719500000000"

my part of perl code

if ($array[1] =~ /extracted region/){
die "No CDS record for $key!\n" unless $metadata->{$key};
(my $label = $array[7]) =~ s/.*region from (.*)\|;.*/$1/;
$label =~ s/\|/_/g;
$group->{$label} ||= { #seed summary if not exists
pos1 => 1e10,
pos2 => 0,
metadata => $metadata->{$key},
sequences => [],
};
(my $pos1, my $arr, my $pos2) = ($array[7]=~/.*interval=\"(\d+) (<?->?) (\d+)\"$/gm);
# capture hi/lo values for group
$group->{$label}->{pos1} = $pos1 if $pos1 < $group->{$label}->{pos1};
$group->{$label}->{pos2} = $pos2 if $pos2 > $group->{$label}->{pos2};
# push this sequence onto the group's array
push(@{ $group->{$label}->{sequences} }, [ $pos1, $pos2, $arrow->{$arr} ]);
}


In the code $pos1=3512970000000,3717850000000 & $pos2=3514640000000,3719500000000. My code prints new line finding minimum and maximum value (if $pos1 is less than 10,000), but if the value is greater than 10,0000 it gives error in printing minimum value of pos1. Any one help me in debug in finding minimum value of $pos1 and maximum value of $pos2

RE: perl-minimum & maximum value

Hi,

Quote:


In the code $pos1=3512970000000,3717850000000 & $pos2=3514640000000,3719500000000. My code prints new line finding minimum and maximum value (if $pos1 is less than 10,000), but if the value is greater than 10,0000 it gives error in printing minimum value of pos1. Any one help me in debug in finding minimum value of $pos1 and maximum value of $pos2

Your issue isn't entirely clear:
- Where are the values of 10000 and 100000 coming from. Even then, there is nothing in your code to cause issues around these specific values.
- Specifically, what is the "error in printing minimum value".

However, I believe the following could potentially be the issue you are describing; As you know, inevitably the condition "$pos1 < $group->{$label}->{pos1}" won't ever fall true if $group->{$label}->{pos1} initially has an undef value. As a method around this, if $group->{$label}->{pos1} is "false", you assign it the value of "1e10" or "10000000000". However, based on your example input data, all potential pos1 values are higher than "10000000000", therefore pos1 will remain at "10000000000". A better way around this would be to also assign pos1 if $group->{$label}->{pos1} if undefined and remove the initial assignment altogether:

CODE

L.6     pos1 => 1e10,
L.13    $group->{$label}->{pos1} = $pos1 if $pos1 < $group->{$label}->{pos1};

L.13    $group->{$label}->{pos1} = $pos1 if ((!defined $group->{$label}->{pos1}) || ($pos1 < $group->{$label}->{pos1})); 

Although unaffected, you would probably use the same method for pos2.

Regards,

Chris

RE: perl-minimum & maximum value

* A better way around this would be to also assign pos1 if $group->{$label}->{pos1} is undefined / remove the initial assignment altogether:

RE: perl-minimum & maximum value

(OP)
Thanks Zhris. It was timely help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close