updated jalview version of dasobert 1.53e client and added Das Sequence Source discov...
[jalview.git] / src / org / biojava / dasobert / feature / FeatureMapComparator.java
1 /*
2  *                    BioJava development code
3  *
4  * This code may be freely distributed and modified under the
5  * terms of the GNU Lesser General Public Licence.  This should
6  * be distributed with the code.  If you do not have a copy,
7  * see:
8  *
9  *      http://www.gnu.org/copyleft/lesser.html
10  *
11  * Copyright for this code is held jointly by the individual
12  * authors.  These should be listed in @author doc comments.
13  *
14  * For more information on the BioJava project and its aims,
15  * or to join the biojava-l mailing list, visit the home page
16  * at:
17  *
18  *      http://www.biojava.org/
19  *
20  * Created on 23.09.2004
21  * @author Andreas Prlic
22  *
23  */
24
25
26 package org.biojava.dasobert.feature ;
27
28 import java.util.Comparator ;
29 import java.util.Map ;
30
31 /** a comparator to sort Features if they are still in a Map ( sorts by type )
32  * @author Andreas Prlic
33  */
34
35 public class FeatureMapComparator 
36     implements Comparator
37 {
38
39     public FeatureMapComparator() {
40     }
41
42     public int compare(Object a, Object b) {
43         Map x = (Map) a;
44         Map y = (Map) b;
45
46         String typea = (String)x.get("TYPE");
47         String typeb = (String)y.get("TYPE");
48         
49         
50
51         if ( isSecstruc(typea) && isSecstruc(typeb)) {
52             return 0 ;
53         }
54         return typea.compareTo(typeb);
55     }
56
57     public boolean isSecstruc(String type) {
58         if ( type.equals("HELIX") 
59              ||
60              type.equals("STRAND") 
61              ||
62              type.equals("TURN") 
63              ) {
64             return true ;
65         }
66         return false ;
67     }
68
69 }