[ensembl-dev] Chromosome-HGNC mapping

Manam, Monica (NIH/NCI) [F] monica.manam at nih.gov
Mon Jul 22 15:44:36 BST 2013


I have one last question Andy,

I do not want to define the start & the ends like the link you gave.
I want to fetch them.

However,

I tried this & it worked :
---------------------------
#!/opt/nasapps/applibs/perl-5.16.2/bin/perl

use strict;
use warnings;
use Bio::EnsEMBL::Registry;

my $registry = 'Bio::EnsEMBL::Registry';
$registry->load_registry_from_db(
   -host => 'ensembldb.ensembl.org',
   # -host => 'useastdb.ensembl.org',
   -user => 'anonymous'
);
my $gene_adaptor =Bio::EnsEMBL::Registry->get_adaptor( "human",
"core","gene" );
my @genes = @{$gene_adaptor->fetch_all_by_external_name('MSGN1')};

foreach(@genes){
my $gene=shift(@genes);
    my $gstring = feature2string($gene);
    print "$gstring\n";
    }
    
    
    sub feature2string
{
    my $feature = shift;

    my $stable_id  = $feature->stable_id();
    my $seq_region = $feature->slice->seq_region_name();
    my $start      = $feature->start();
    my $end        = $feature->end();
    my $strand     = $feature->strand();

    return sprintf( "%s: %s:%d-%d (%+d)",
        $stable_id, $seq_region, $start, $end, $strand );
}

-----------------------


Output (which I wanted):

ENSG00000151379: 2:17997763-17998368 (+1)

-----------------------

But, thanks for all the help Andy!
Good day!!

-- 
Monica Manam
Summer Intern
CCRIFX BioInformatics CORE
NCI-NIH




On 7/22/13 10:37 AM, "Andy Yates" <ayates at ebi.ac.uk> wrote:

>Hi there,
>
>Yes that's what I'm getting. The method is returning you a Gene object.
>To access Gene attributes you will have to call methods on the object.
>You can find the full list of available methods from
>http://www.ensembl.org/info/docs/Doxygen/core-api/classBio_1_1EnsEMBL_1_1G
>ene.html.
>
>Hope this helps,
>
>Andy
>
>On 22 Jul 2013, at 15:34, "Manam, Monica (NIH/NCI) [F]"
><monica.manam at nih.gov> wrote:
>
>> Im sorry I sent you the prev code, I initially commented out the
>>"strict"
>> & "warning" to test & removed the comment while sending it to you.
>> Thanks, however the result of this command is :
>> 
>> 71 at -e line 1.
>> 
>> The result of the edited code, with the variable declaration etc is "
>> 
>> Bio::EnsEMBL::Gene=HASH(0x303a570)
>> 
>> 
>> Isn't this what you are getting?
>> 
>> Thanks,
>> Monica.
>> 
>> 
>> 
>> On 7/22/13 10:25 AM, "Andy Yates" <ayates at ebi.ac.uk> wrote:
>> 
>>> perl -MBio::EnsEMBL::ApiVersion -e 'warn
>>> Bio::EnsEMBL::ApiVersion::software_version()'
>> 
>> 
>> _______________________________________________
>> Dev mailing list    Dev at ensembl.org
>> Posting guidelines and subscribe/unsubscribe info:
>>http://lists.ensembl.org/mailman/listinfo/dev
>> Ensembl Blog: http://www.ensembl.info/
>
>
>_______________________________________________
>Dev mailing list    Dev at ensembl.org
>Posting guidelines and subscribe/unsubscribe info:
>http://lists.ensembl.org/mailman/listinfo/dev
>Ensembl Blog: http://www.ensembl.info/





More information about the Dev mailing list