[BioRuby] Multi Fasta Sequence file to Genbank conversion..

Adam Kraut adamnkraut at gmail.com
Fri Sep 5 15:00:31 UTC 2008


Naohisa, thanks for clearing that up.  I knew there was a better way ;)

Sharvari, which version of Bioruby have you installed?  Both examples will
print everything to stdout, which you can redirect to a single file.

On Fri, Sep 5, 2008 at 10:22 AM, Sharvari Gujja <sgujja at broad.mit.edu>wrote:

> Hi,
>
> Thank you so much for the reply.
>
> However, I get the following error on running this code:
>
> *require 'bio'
>  Bio::FlatFile.open($<) do |ff|
>   ff.each do |e|
>     print e.to_biosequence.output(:genbank)
>   end
>  end*
>
>
> undefined method `to_biosequence' for #<Bio::FastaFormat:0x2a95cc4948>
> (NoMethodError)
>
> And running this code gives me:
>
> *include Bio
>
> fasta = Alignment::MultiFastaFormat.new(File.open('my.fasta').read)
> fasta.entries.each do |seq|
>  puts seq.to_seq.output(:genbank)
> end*
>
> uninitialized constant Alignment (NameError)...
>
> I guess this is something to do with rubygems.
>
> Also, I believe this would generate a genbank file for each sequence in the
> multi-fasta file. Is there a way to get single Genbank file for the
> multi-fasta sequence file?
>
> Appreciate all the help.
>
> Thanks
> S
>
>
> Naohisa GOTO wrote:
>
>> Hi,
>>
>> On Thu, 4 Sep 2008 19:13:25 -0400
>> "Adam Kraut" <adamnkraut at gmail.com> wrote:
>>
>>
>>
>>> I've never used the genbank format, but in Bioruby you could try:
>>>
>>> include Bio
>>>
>>> fasta = Alignment::MultiFastaFormat.new(File.open('my.fasta').read)
>>> fasta.entries.each do |seq|
>>>  puts seq.to_seq.output(:genbank)
>>> end
>>>
>>>
>>
>> No need to use Bio::Alignment::MultiFastaFormat in this case.
>> Bio::FlatFile alone can do.
>>
>> For example, to read from stdin and output to stdout,
>>
>>  require 'bio'
>>  Bio::FlatFile.open($<) do |ff|
>>    ff.each do |e|
>>      print e.to_biosequence.output(:genbank)
>>    end
>>  end
>>
>> Note that the output(:genbank) are new feature only in
>> the latest development version in the git repository.
>> http://github.com/bioruby/bioruby
>> (i.e. in BioRuby 1.2.1, above examples cannot be run.)
>>
>> Naohisa Goto
>> ngoto at gen-info.osaka-u.ac.jp / ng at bioruby.org
>>
>>
>>
>>> The only tricky part is perhaps is the to_seq call for a Bio::Sequence
>>> object which has different output format methods.
>>> -Adam
>>>
>>> On Thu, Sep 4, 2008 at 10:53 AM, Sharvari Gujja <sgujja at broad.mit.edu
>>> >wrote:
>>>
>>>
>>>
>>>> Hi,
>>>>
>>>> I am trying to convert a multi fasta sequence file (nucleotide/protein)
>>>> to
>>>> genbank format.Is there a way to do this using Bioruby?
>>>>
>>>> Appreciate any input/suggestions.
>>>>
>>>> Thanks
>>>> S
>>>> _______________________________________________
>>>> BioRuby mailing list
>>>> BioRuby at lists.open-bio.org
>>>> http://lists.open-bio.org/mailman/listinfo/bioruby<https://lists.open-bio.org/mailman/listinfo/bioruby>
>>>> <https://lists.open-bio.org/mailman/listinfo/bioruby>
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> BioRuby mailing list
>>> BioRuby at lists.open-bio.org
>>> http://lists.open-bio.org/mailman/listinfo/bioruby<https://lists.open-bio.org/mailman/listinfo/bioruby>
>>>
>>>
>>
>>
>>
>>
>>
>



More information about the BioRuby mailing list