[ensembl-dev] Cannot get sequence from genome using perl variables (no HTML)

Hans-Rudolf Hotz hrh at fmi.ch
Wed Apr 27 17:16:30 BST 2011


probably a typo:

$slice = $slice_adpator->fetch_by_region( 'chromosome', $chr, $e_start,
                   ^^


Regards, Hans



On 04/27/2011 06:00 PM, Damian wrote:
>
> Hi Bert,
> Thanks for the quick reply.
> I have tried it without the quotes around the '1' and it does work.
> So:
>
> $chr = 1;
> $start = 724572;
> $end = 724726;
> $slice = $slice_adaptor->fetch_by_region( 'chromosome', $chr, $start,
> $end );
> $x = $slice->seq;
>
> Will work.
>
>
> However this code doesn't work:
>
> $coords = "1,724572,724726";
> @ary = split(/,/, $coords);
> $chr = $ary[0];
> $e_start = $ary[1];
> $e_end = $ary[2];
>
> ## get the sequence coordinates.
> print STDERR "$coords\n";
> print STDERR "|$chr|\n";
> print STDERR "|$e_start|\n";
> print STDERR "|$e_end|\n";
>
> $slice = $slice_adpator->fetch_by_region( 'chromosome', $chr, $e_start,
> $e_end );
> $x = $slice->seq;
> print "\n$x\n";
>
> And throws the error:
> Can't call method "fetch_by_region" on an undefined value at genSeqs.pl
> line 39.
>
> Any ideas?
>
> Damian
>
>
>
> On 04/27/2011 11:48 AM, Bert Overduin wrote:
>> Hi Damian,
>>
>> Haven't you put a few too many quotation marks around the 1?
>>
>> Cheers,
>> Bert
>>
>> Sent from my iPhone
>>
>> On Apr 27, 2011, at 4:41 PM, Damian<dfermin at umich.edu> wrote:
>>
>>> Hello.
>>>
>>> Sorry for double posting. My message go corrupted since I sent it via
>>> HTML..
>>>
>>> Down below I've pasted a snippet of a script I've written to retrieve
>>> regions of the genome.
>>> The first call to slice_adaptor works as expected. This call uses the
>>> hard coded coordinates.
>>> The second version of the call to slice_adaptor fails to work,
>>> throwing the error:
>>> Can't call method "seq" on an undefined value at getSeqs.pl line 23.
>>>
>>> The only difference between the two calls to slice_adaptor is that
>>> the second version uses perl variables ($chr, $start, $end) instead
>>> of the hard coded values.
>>> Is this a bug or am I doing something wrong?
>>> I'm using Ensembl Perl API version 62 with the Human database
>>> installed (homo_sapiens_core_62_37g).
>>>
>>> Thanks in advance for any and all help.
>>> Damian
>>>
>>>
>>> #!/usr/bin/perl -w
>>>
>>> use Bio::EnsEMBL::Registry;
>>> use Bio::EnsEMBL::Slice;
>>>
>>> my $registry = 'Bio::EnsEMBL::Registry';
>>> $registry->load_registry_from_db(
>>> -host => '127.0.0.1',
>>> -user => 'jonDoe'
>>> );
>>>
>>> $slice_adaptor = $registry->get_adaptor('Human', 'Core', 'Slice');
>>>
>>> $slice = $slice_adaptor->fetch_by_region( 'chromosome', '1', 724572,
>>> 724726 );
>>> $x = $slice->seq;
>>> print "\n## 1 ###\n$x\n\n";
>>>
>>> ## this version does NOT work
>>> $chr = "'1'";
>>> $start = 724572;
>>> $end = 724726;
>>> $slice = $slice_adaptor->fetch_by_region( 'chromosome', $chr, $start,
>>> $end );
>>> $x = $slice->seq;
>>> print "\n## 2 ###\n$x\n\n";
>>>
>>> exit;
>>>
>>> --
>>> ------------------------------------------------------------------------------
>>>
>>> Damian Fermin, Ph.D.
>>> Pathology Department
>>> University of Michigan
>>> 4237 Medical Science I
>>> 1301 Catherine
>>> Ann Arbor, MI 48109-0602
>>> 734.615.0302
>>>
>>> "There is No Gene for the Human Spirit"
>>> -- GATTACA
>>> ------------------------------------------------------------------------------
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list Dev at ensembl.org
>>> List admin (including subscribe/unsubscribe):
>>> http://lists.ensembl.org/mailman/listinfo/dev
>>> Ensembl Blog: http://www.ensembl.info/
>>
>




More information about the Dev mailing list