[BioRuby-cvs] bioruby/lib/bio/db/embl format_embl.rb, 1.1.2.5, 1.1.2.6

Naohisa Goto ngoto at dev.open-bio.org
Tue Jun 17 16:06:06 UTC 2008


Update of /home/repository/bioruby/bioruby/lib/bio/db/embl
In directory dev.open-bio.org:/tmp/cvs-serv21282/lib/bio/db/embl

Modified Files:
      Tag: BRANCH-biohackathon2008
	format_embl.rb 
Log Message:
* Added support for CC lines (comments).
* Added support for DR lines (database cross references).
* Many improvements.


Index: format_embl.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/Attic/format_embl.rb,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** format_embl.rb	28 May 2008 13:38:07 -0000	1.1.2.5
--- format_embl.rb	17 Jun 2008 16:06:04 -0000	1.1.2.6
***************
*** 2,6 ****
  # = bio/db/embl/format_embl.rb - EMBL format generater
  #
! # Copyright::  Copyright (C) 2008 Jan Aerts <jandot at bioruby.org>
  # License::    The Ruby License
  #
--- 2,8 ----
  # = bio/db/embl/format_embl.rb - EMBL format generater
  #
! # Copyright::  Copyright (C) 2008
! #              Jan Aerts <jandot at bioruby.org>,
! #              Naohisa Goto <ng at bioruby.org>
  # License::    The Ruby License
  #
***************
*** 125,136 ****
      end
  
      # Erb template of EMBL format for Bio::Sequence
      erb_template <<'__END_OF_TEMPLATE__'
! ID   <%= entry_id %>; SV <%= sequence_version %>; <%= topology %>; <%= molecule_type %>; <%= data_class %>; <%= division %>; <%= seq.length %> BP.
  XX   
  <%= embl_wrap('AC   ', accessions.reject{|a| a.nil?}.join('; ') + ';') %>
  XX   
! DT   <%= date_created %>
! DT   <%= date_modified %>
  XX   
  <%= embl_wrap('DE   ', definition) %>
--- 127,166 ----
      end
  
+     # moleculue type
+     def mol_type_embl
+       if mt = molecule_type then
+         mt
+       elsif f = (features or []).find { |f| f.feature == 'source' } and
+           q = f.qualifiers.find { |q| q.qualifier == 'mol_type' } then
+         q.value
+       else
+         'NA'
+       end
+     end
+ 
+     # CC line. Comments.
+     def comments_format_embl(cmnts)
+       return '' if !cmnts or cmnts.empty?
+       cmnts = [ cmnts ] unless cmnts.kind_of?(Array)
+       a = []
+       cmnts.each do |str|
+         a.push embl_wrap('CC   ', str)
+       end
+       unless a.empty? then
+         a.push "XX   "
+         a.push '' # dummy to put "\n" at the end of the string
+       end
+       a.join("\n")
+     end
+ 
+ 
      # Erb template of EMBL format for Bio::Sequence
      erb_template <<'__END_OF_TEMPLATE__'
! ID   <%= primary_accession || entry_id %>; SV <%= sequence_version %>; <%= topology %>; <%= mol_type_embl %>; <%= data_class %>; <%= division %>; <%= seq.length %> BP.
  XX   
  <%= embl_wrap('AC   ', accessions.reject{|a| a.nil?}.join('; ') + ';') %>
  XX   
! DT   <%= format_date(date_created || null_date) %> (Rel. <%= release_created || 0 %>, Created)
! DT   <%= format_date(date_modified || null_date) %> (Rel. <%= release_modified || 0 %>, Last updated, Version <%= entry_version || 0 %>)
  XX   
  <%= embl_wrap('DE   ', definition) %>
***************
*** 142,146 ****
  XX   
  <% hash = {}; (references || []).each do |ref| %><%= reference_format_embl(ref, hash) %>
! <% end %>FH   Key             Location/Qualifiers
  FH   
  <%= format_features_embl(features || []) %>XX   
--- 172,181 ----
  XX   
  <% hash = {}; (references || []).each do |ref| %><%= reference_format_embl(ref, hash) %>
! <% end %><% (dblinks || []).each do |r|
! %>DR   <%= r.database %>; <%= r.id %><% unless r.secondary_ids.empty? %>; <%= r.secondary_ids[0] %><% end %>.
! <% end %><% if dblinks and !dblinks.empty? then
!  %>XX   
! <% end %><%= comments_format_embl(comments)
! %>FH   Key             Location/Qualifiers
  FH   
  <%= format_features_embl(features || []) %>XX   




More information about the bioruby-cvs mailing list