in reply to How to convert the NCBI Gene ID to GenBank ID?

As per Bio::DB::GenBank's documentation the function you are calling get_Seq_by_gi() returns a Bio::Seq object. Whose documentation is here Bio::Seq. In there it shows how to print the sequence, for example, using a method like : print $seq->seq()."\n";

That said, be warned that in your script you hammer in your '7157' ID to a remote service which expects GenBank's IDs (NM_000546.5). You do get a response which is garbage unfortunately as it relates to "Dictyostelium discoideum (Slime mold)" and not to "Homo Sapiens" - what's the difference one can ask (sidenote: more evidence that the old GIGO effect is deep-rooted into the heart of the lite "sciences").

In order to get the response you want you must supply the get_Seq_by_id() with this $id='NM_000546.5'. Then it remains to explore the documentation in order to extract what you want from that large (>100KB) dataset you just transfered from 4000km away across land and sea and possibly through aether.

If your main aim is to convert programmatically the ID 7157 to an ID understood by GenBank, e.g. NM_000546.5 then welcome to the club of gene id conversions. Probably a tenth of the net's transfers are to sites claiming to convert between the numerous ID standards imposed by bio-narcissi and fund-whores and desperate users who somewhere got lost in these standards or found that the mapping is not 1-1. I can not help you with that although, additionally to Bioperl, R (bioconductor) may offer you another lifeline.

Replies are listed 'Best First'.
Re^2: How to convert the NCBI Gene ID to GenBank ID?
by Anonymous Monk on Jun 22, 2018 at 23:32 UTC

    Thanks much bliako for mentioning the method to get the sequence from Bio::Seq. That thought occurred to be much later that the module may already have a(some) method(s) to do that; advice about Data::Dumper may turn out to be of no use.

      Glad. If you hear of a method to do what you want then let me know and I can assist you with the low-level details if need be. I would like to put all these converters in one place one day.

      btw the returned object is of type Bio::Seq::RichSeq and not what I initially said, Bio:Seq. It is a superset of it, so-to-speak. I was citing the doc and overlooked the returned value you posted.

        Thanks for the offer, but I am not involved with the area of inquiry. I wanted to thank you for providing the relevant information to OP than I did or ever could.

      Anonymous Monk,

      Thanks for your comments.

      With regards,

Re^2: How to convert the NCBI Gene ID to GenBank ID?
by supriyoch_2008 (Monk) on Jun 23, 2018 at 17:47 UTC

    Hi Bliako,

    Thank you very much for your valuable comments and suggestions.

    I am sorry for late reply as the internet connectivity was not available this morning.

    With regards,