2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.phylogeny.data;
28 import java.io.IOException;
29 import java.io.Writer;
30 import java.util.LinkedHashMap;
33 public class SequenceRelation implements PhylogenyData {
35 //public final static Map<String, SEQUENCE_RELATION_TYPE> typesToNames = new LinkedHashMap<String, SEQUENCE_RELATION_TYPE>();
36 public final static Map<SEQUENCE_RELATION_TYPE, String> typesToNames = new LinkedHashMap<SEQUENCE_RELATION_TYPE, String>();
37 public final static String SEQUENCE_RELATION_TYPE_ORTHOLOGY = "orthology";
38 public final static String SEQUENCE_RELATION_TYPE_ONE_TO_ONE_ORTHOLOGY = "one_to_one_orthology";
39 public final static String SEQUENCE_RELATION_TYPE_SUPER_ORTHOLOGY = "super_orthology";
40 public final static String SEQUENCE_RELATION_TYPE_PARALOGY = "paralogy";
41 public final static String SEQUENCE_RELATION_TYPE_ULTRA_PARALOGY = "ultra_paralogy";
42 public final static String SEQUENCE_RELATION_TYPE_XENOLOGY = "xenology";
43 public final static String SEQUENCE_RELATION_TYPE_UNKNOWN = "unknown";
44 public final static String SEQUENCE_RELATION_TYPE_OTHER = "other";
45 private Sequence ref0;
46 private Sequence ref1;
47 private SEQUENCE_RELATION_TYPE type;
48 private Double distance;
49 private Confidence confidence;
51 typesToNames.put( SEQUENCE_RELATION_TYPE.orthology, SEQUENCE_RELATION_TYPE_ORTHOLOGY );
52 typesToNames.put( SEQUENCE_RELATION_TYPE.one_to_one_orthology, SEQUENCE_RELATION_TYPE_ONE_TO_ONE_ORTHOLOGY );
53 typesToNames.put( SEQUENCE_RELATION_TYPE.super_orthology, SEQUENCE_RELATION_TYPE_SUPER_ORTHOLOGY );
54 typesToNames.put( SEQUENCE_RELATION_TYPE.paralogy, SEQUENCE_RELATION_TYPE_PARALOGY );
55 typesToNames.put( SEQUENCE_RELATION_TYPE.ultra_paralogy, SEQUENCE_RELATION_TYPE_ULTRA_PARALOGY );
56 typesToNames.put( SEQUENCE_RELATION_TYPE.xenology, SEQUENCE_RELATION_TYPE_XENOLOGY );
57 typesToNames.put( SEQUENCE_RELATION_TYPE.unknown, SEQUENCE_RELATION_TYPE_UNKNOWN );
58 typesToNames.put( SEQUENCE_RELATION_TYPE.other, SEQUENCE_RELATION_TYPE_OTHER );
62 public StringBuffer asSimpleText() {
63 // TODO Auto-generated method stub
68 public StringBuffer asText() {
69 // TODO Auto-generated method stub
74 public PhylogenyData copy() {
75 // TODO Auto-generated method stub
79 public Confidence getConfidence() {
83 public Double getDistance() {
87 public Sequence getRef0() {
91 public Sequence getRef1() {
95 public SEQUENCE_RELATION_TYPE getType() {
100 public boolean isEqual( final PhylogenyData data ) {
101 // TODO Auto-generated method stub
105 public void setConfidence( final Confidence confidence ) {
106 this.confidence = confidence;
109 public void setDistance( final Double distance ) {
110 this.distance = distance;
113 public void setRef0( final Sequence ref0 ) {
117 public void setRef1( final Sequence ref1 ) {
121 public void setType( final SEQUENCE_RELATION_TYPE type ) {
126 public StringBuffer toNHX() {
127 throw new UnsupportedOperationException();
131 public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
132 // TODO Auto-generated method stub
135 public static String getPrintableNameByType( final SEQUENCE_RELATION_TYPE type ) {
136 String s = typesToNames.get( type );
138 s = s.replace( '_', ' ' );
139 if ( ( s.length() > 15 ) && s.toLowerCase().endsWith( "ology" ) ) {
140 s = s.substring( 0, s.length() - 5 ) + ".";
146 public static enum SEQUENCE_RELATION_TYPE {
147 orthology, one_to_one_orthology, super_orthology, paralogy, ultra_paralogy, xenology, unknown, other;