X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fphylogeny%2Fdata%2FDomainArchitecture.java;h=0f09c55345f71a3d69b9da82c84e0ba552e43939;hb=79cae2c4cb52ff0d105292121ea9637886f1f8af;hp=e19c2efa9f1881853c65b0ea056128337b8ced93;hpb=48f7a89be9d34f1930a1f863e608235cc27184c5;p=jalview.git diff --git a/forester/java/src/org/forester/phylogeny/data/DomainArchitecture.java b/forester/java/src/org/forester/phylogeny/data/DomainArchitecture.java index e19c2ef..0f09c55 100644 --- a/forester/java/src/org/forester/phylogeny/data/DomainArchitecture.java +++ b/forester/java/src/org/forester/phylogeny/data/DomainArchitecture.java @@ -5,7 +5,7 @@ // Copyright (C) 2008-2009 Christian M. Zmasek // Copyright (C) 2008-2009 Burnham Institute for Medical Research // All rights reserved -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -15,18 +15,19 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.phylogeny.data; import java.io.IOException; import java.io.Writer; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.SortedMap; @@ -40,10 +41,10 @@ import org.forester.util.ForesterUtil; public class DomainArchitecture implements PhylogenyData { - public final static String NHX_SEPARATOR = ">"; - private static final double INCREASE_KEY = 0.0001; - private SortedMap _domains; - private int _total_length; + public final static String NHX_SEPARATOR = ">"; + private static final BigDecimal INCREASE_KEY = new BigDecimal( "0.00001" ); + private SortedMap _domains; + private int _total_length; public DomainArchitecture() { init(); @@ -79,7 +80,7 @@ public class DomainArchitecture implements PhylogenyData { } } catch ( final Exception e ) { - throw new IllegalArgumentException( "Malformed format for domain structure \"" + da_str + "\": " + throw new IllegalArgumentException( "malformed format for domain structure \"" + da_str + "\": " + e.getMessage() ); } if ( to > total_length ) { @@ -89,13 +90,14 @@ public class DomainArchitecture implements PhylogenyData { } public void addDomain( final ProteinDomain pd ) { - Double key = new Double( pd.getFrom() ); + BigDecimal key = new BigDecimal( "" + pd.getFrom() ); while ( _domains.containsKey( key ) ) { - key = new Double( key.doubleValue() + DomainArchitecture.INCREASE_KEY ); + key = new BigDecimal( "" + ( key.doubleValue() + DomainArchitecture.INCREASE_KEY.doubleValue() ) ); } _domains.put( key, pd ); } + @Override public StringBuffer asSimpleText() { final StringBuffer sb = new StringBuffer(); for( int i = 0; i < getDomains().size(); ++i ) { @@ -107,6 +109,7 @@ public class DomainArchitecture implements PhylogenyData { return sb; } + @Override public StringBuffer asText() { final StringBuffer sb = new StringBuffer(); for( int i = 0; i < getDomains().size(); ++i ) { @@ -118,6 +121,7 @@ public class DomainArchitecture implements PhylogenyData { return sb; } + @Override public PhylogenyData copy() { final List domains = new ArrayList( getDomains().size() ); for( int i = 0; i < getDomains().size(); ++i ) { @@ -130,7 +134,7 @@ public class DomainArchitecture implements PhylogenyData { return ( ProteinDomain ) _domains.values().toArray()[ i ]; } - public SortedMap getDomains() { + public SortedMap getDomains() { return _domains; } @@ -143,7 +147,7 @@ public class DomainArchitecture implements PhylogenyData { } private void init() { - _domains = new TreeMap(); + _domains = new TreeMap(); _total_length = 0; } @@ -153,6 +157,7 @@ public class DomainArchitecture implements PhylogenyData { * * */ + @Override public boolean isEqual( final PhylogenyData domain_architecture ) { if ( domain_architecture == null ) { return false; @@ -176,6 +181,7 @@ public class DomainArchitecture implements PhylogenyData { _total_length = total_length; } + @Override public StringBuffer toNHX() { final StringBuffer sb = new StringBuffer(); sb.append( ":" ); @@ -196,6 +202,7 @@ public class DomainArchitecture implements PhylogenyData { return sb; } + @Override public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException { writer.write( ForesterUtil.LINE_SEPARATOR ); writer.write( indentation );