X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fphylogeny%2Fdata%2FTaxonomy.java;h=117f831b9e217dee7664ef32978a0f65c4e6ac75;hb=4a71774e563925de62c37378a6c32c3275f2e287;hp=026d68bfd9608f41bae079ea57bef89c0d9c9c71;hpb=48f7a89be9d34f1930a1f863e608235cc27184c5;p=jalview.git diff --git a/forester/java/src/org/forester/phylogeny/data/Taxonomy.java b/forester/java/src/org/forester/phylogeny/data/Taxonomy.java index 026d68b..117f831 100644 --- a/forester/java/src/org/forester/phylogeny/data/Taxonomy.java +++ b/forester/java/src/org/forester/phylogeny/data/Taxonomy.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,13 +15,13 @@ // 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; @@ -35,6 +35,7 @@ import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.PhyloXmlUtil; import org.forester.util.ForesterUtil; +import org.forester.util.TaxonomyUtil; public class Taxonomy implements PhylogenyData, MultipleUris, Comparable { @@ -46,19 +47,23 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable _uris; + private List _lineage; public Taxonomy() { init(); } + @Override public StringBuffer asSimpleText() { return asText(); } + @Override public Uri getUri( final int index ) { return getUris().get( index ); } + @Override public void addUri( final Uri uri ) { if ( getUris() == null ) { setUris( new ArrayList() ); @@ -66,6 +71,7 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable() ); for( final Uri uri : getUris() ) { @@ -125,6 +142,14 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable() ); + for( final String l : getLineage() ) { + if ( l != null ) { + t.getLineage().add( l ); + } + } + } return t; } @@ -176,13 +201,14 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable getUris() { return _uris; } @Override public int hashCode() { - if ( getIdentifier() != null ) { + if ( ( getIdentifier() != null ) && !ForesterUtil.isEmpty( getIdentifier().getValue() ) ) { return getIdentifier().hashCode(); } else if ( !ForesterUtil.isEmpty( getTaxonomyCode() ) ) { @@ -203,22 +229,32 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable uris ) { _uris = uris; } + @Override public StringBuffer toNHX() { final StringBuffer sb = new StringBuffer(); if ( getIdentifier() != null ) { @@ -322,6 +368,7 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable 0 ) { + PhylogenyDataUtil.appendElement( writer, PhyloXmlMapping.TAXONOMY_LINEAGE, sb.toString(), indentation ); + } + } writer.write( ForesterUtil.LINE_SEPARATOR ); writer.write( indentation ); PhylogenyDataUtil.appendClose( writer, PhyloXmlMapping.TAXONOMY ); @@ -380,15 +447,36 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable lineage ) { + _lineage = lineage; + } + + public List getLineage() { + return _lineage; } }