45134e4f8f30afcb3f9fa124edd3dc21876fdebd
[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         // TODO Auto-generated method stub
64         return null;
65     }
66
67     @Override
68     public StringBuffer asText() {
69         // TODO Auto-generated method stub
70         return null;
71     }
72
73     @Override
74     public PhylogenyData copy() {
75         // TODO Auto-generated method stub
76         return null;
77     }
78
79     public Confidence getConfidence() {
80         return confidence;
81     }
82
83     public Double getDistance() {
84         return distance;
85     }
86
87     public Sequence getRef0() {
88         return ref0;
89     }
90
91     public Sequence getRef1() {
92         return ref1;
93     }
94
95     public SEQUENCE_RELATION_TYPE getType() {
96         return type;
97     }
98
99     @Override
100     public boolean isEqual( final PhylogenyData data ) {
101         // TODO Auto-generated method stub
102         return false;
103     }
104
105     public void setConfidence( final Confidence confidence ) {
106         this.confidence = confidence;
107     }
108
109     public void setDistance( final Double distance ) {
110         this.distance = distance;
111     }
112
113     public void setRef0( final Sequence ref0 ) {
114         this.ref0 = ref0;
115     }
116
117     public void setRef1( final Sequence ref1 ) {
118         this.ref1 = ref1;
119     }
120
121     public void setType( final SEQUENCE_RELATION_TYPE type ) {
122         this.type = type;
123     }
124
125     @Override
126     public StringBuffer toNHX() {
127         throw new UnsupportedOperationException();
128     }
129
130     @Override
131     public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
132         // TODO Auto-generated method stub
133     }
134
135     public static String getPrintableNameByType( final SEQUENCE_RELATION_TYPE type ) {
136         String s = typesToNames.get( type );
137         if ( s != null ) {
138             s = s.replace( '_', ' ' );
139             if ( ( s.length() > 15 ) && s.toLowerCase().endsWith( "ology" ) ) {
140                 s = s.substring( 0, s.length() - 5 ) + ".";
141             }
142         }
143         return s;
144     }
145
146     public static enum SEQUENCE_RELATION_TYPE {
147         orthology, one_to_one_orthology, super_orthology, paralogy, ultra_paralogy, xenology, unknown, other;
148     }
149 }