in reply to Re: Selecting Random Sequence
in thread Selecting Random Sequence

Actually i need some help with both the parts. the URL is

http://www.ncbi.nlm.nih.gov/mapview/seq_reg.cgi?org=human&chr=7&from=1&to=158545518&cntg=cntg

Where the chr= changes, frm, to and cntg also change.
besides generating a random number which will span entire length of human genome is also a task!

courtesy janitoring by ybiC: Made URL to be active link, by surrounding it with square brackets thusly [http://www...]

Replies are listed 'Best First'.
Re: Re: Re: Selecting Random Sequence
by thor (Priest) on Apr 25, 2004 at 16:42 UTC
    Okay...that's a start. First, let's cover the "random sequence" part. I'll make some assumptions here, as I don't really have a lot to go on. I'll assume that you have your data in a single string (I'll call it $super). So, in order to get a "random sequence", there are two elements of randomness that we have the ability to introduce: length and starting position. I'll try to incorporate both.
    my $start = int(rand(length($super))); my $length = int(rand(length($super) - $start)) + 1; my $substring = substr($super, $start, $length);
    Of course, you could make either $start or $length static by just assigning a value to them.
    Now, on the the fetching part. Once you have all of the appropriate values for the variable in your URL, fetching it is not so bad:
    use LWP::Simple; getstore($url, $localfile);
    If I can elaborate any further, let me know how and I'll do my best.

    thor