[ensembl-dev] Chromosome-HGNC mapping
Andy Yates
ayates at ebi.ac.uk
Mon Jul 22 16:11:33 BST 2013
Hi Monica,
Ah I believe there is some confusion to the relationship between a Gene and its GeneAdaptor. Bio::EnsEMBL::Gene provides accessors to a gene's attributes such as start, end & strand (as you've found). GeneAdaptor (http://www.ensembl.org/info/docs/Doxygen/core-api/classBio_1_1EnsEMBL_1_1DBSQL_1_1GeneAdaptor.html) is responsible for querying the Ensembl database and returning Gene objects. As a user consuming Ensembl data you should query for an object type & use the methods on the object to retrieve data. You may also find the tutorial helpful (http://www.ensembl.org/info/docs/api/core/core_tutorial.html) especially the sections on features, genes, transcripts and exons.
All the best,
Andy
Andrew Yates Ensembl Core Software Project Leader
EMBL-EBI Tel: +44-(0)1223-492538
Wellcome Trust Genome Campus Fax: +44-(0)1223-494468
Cambridge CB10 1SD, UK http://www.ensembl.org/
On 22 Jul 2013, at 15:44, "Manam, Monica (NIH/NCI) [F]" <monica.manam at nih.gov> wrote:
> 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/
>
>
> _______________________________________________
> 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