2 # = lib/evo/sequence/domain_structure.rb - DomainStructure class
4 # Copyright:: Copyright (C) 2006-2007 Christian M. Zmasek
5 # License:: GNU Lesser General Public License (LGPL)
7 # $Id: domain_structure.rb,v 1.2 2007/06/12 04:51:33 cmzmasek Exp $
9 # last modified: 05/16/2007
11 require 'lib/evo/util/constants'
17 def initialize( total_length )
19 @total_length = total_length
22 def add_domain( domain, overwrite_if_same_from_to )
24 if ( @domains.has_key?( key ) )
25 prev_domain = @domains[ key ]
26 if ( prev_domain.get_to == domain.get_to )
27 puts( "WARNING: more than one domain at the same location [" +
28 key.to_s + "-" + domain.get_to.to_s + "]: " + prev_domain.get_name + " and " + domain.get_name)
29 if ( overwrite_if_same_from_to )
30 puts( " ignored the one with higher E-value [" +
31 prev_domain.get_confidence().to_s + " vs " + domain.get_confidence().to_s + "]" )
32 if prev_domain.get_confidence() < domain.get_confidence()
33 return # keep previous one
35 @domains[ key ] = domain
41 while ( @domains.has_key?( key ) )
46 @domains[ key ] = domain
51 str << get_total_length.to_s
55 str << Evoruby::Constants::DOMAIN_STRUCTURE_NHX_SEPARATOR
56 str << domain.get_from.to_s
57 str << Evoruby::Constants::DOMAIN_STRUCTURE_NHX_SEPARATOR
58 str << domain.get_to.to_s
59 str << Evoruby::Constants::DOMAIN_STRUCTURE_NHX_SEPARATOR
60 str << domain.get_confidence.to_s
61 str << Evoruby::Constants::DOMAIN_STRUCTURE_NHX_SEPARATOR
62 str << domain.get_name
71 end # class DomainStructure