in progress
[jalview.git] / forester / java / src / org / forester / phylogeny / data / SequenceRelation.java
1 // $Id:
2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
4 //
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // All rights reserved
8 //
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.
13 //
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.
18 //
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
22 //
23 // Contact: phylosoft @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
25
26 package org.forester.phylogeny.data;
27
28 import java.io.IOException;
29 import java.io.Writer;
30 import java.util.LinkedHashMap;
31 import java.util.Map;
32
33 public class SequenceRelation implements PhylogenyData {
34
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;
50     static {
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 );
59     }
60
61     @Override
62     public StringBuffer asSimpleText() {
63         return null;
64     }
65
66     @Override
67     public StringBuffer asText() {
68         return null;
69     }
70
71     @Override
72     public PhylogenyData copy() {
73         // TODO Auto-generated method stub
74         return null;
75     }
76
77     public Confidence getConfidence() {
78         return confidence;
79     }
80
81     public Double getDistance() {
82         return distance;
83     }
84
85     public Sequence getRef0() {
86         return ref0;
87     }
88
89     public Sequence getRef1() {
90         return ref1;
91     }
92
93     public SEQUENCE_RELATION_TYPE getType() {
94         return type;
95     }
96
97     @Override
98     public boolean isEqual( final PhylogenyData data ) {
99         // TODO Auto-generated method stub
100         return false;
101     }
102
103     public void setConfidence( final Confidence confidence ) {
104         this.confidence = confidence;
105     }
106
107     public void setDistance( final Double distance ) {
108         this.distance = distance;
109     }
110
111     public void setRef0( final Sequence ref0 ) {
112         this.ref0 = ref0;
113     }
114
115     public void setRef1( final Sequence ref1 ) {
116         this.ref1 = ref1;
117     }
118
119     public void setType( final SEQUENCE_RELATION_TYPE type ) {
120         this.type = type;
121     }
122
123     @Override
124     public StringBuffer toNHX() {
125         throw new UnsupportedOperationException();
126     }
127
128     @Override
129     public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
130         // TODO Auto-generated method stub
131     }
132
133     public static String getPrintableNameByType( final SEQUENCE_RELATION_TYPE type ) {
134         String s = typesToNames.get( type );
135         if ( s != null ) {
136             s = s.replace( '_', ' ' );
137             if ( ( s.length() > 15 ) && s.toLowerCase().endsWith( "ology" ) ) {
138                 s = s.substring( 0, s.length() - 5 ) + ".";
139             }
140         }
141         return s;
142     }
143
144     public static enum SEQUENCE_RELATION_TYPE {
145         orthology, one_to_one_orthology, super_orthology, paralogy, ultra_paralogy, xenology, unknown, other;
146     }
147 }