001/*
002 * BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 * Author: Daniel Asarnow
021 * Date:   2012-6-23
022 */
023
024package org.biojava.nbio.structure.cath;
025
026/** The categories found within CATH.
027 *
028 * The CATH node types are:
029 * 'C' (class), 'A' (architecture), 'T' (topology), 'H' (homologous superfamily),
030 * 'S' (sequence family, S35), 'O' (orthologous sequence family, S60),
031 * 'L' ("like" sequence family, S95), 'I' (identical, S100) and
032 * 'D' (domain, S100 count).
033 *
034 * @author Daniel Asarnow
035 */
036public enum CathCategory {
037        Class,
038        Architecture,
039        Topolgy,
040        Homology,
041        SequenceFamily,
042        OrthologousSequenceFamily,
043        LikeSequenceFamily,
044        IdenticalSequenceFamily,
045        DomainCounter;
046
047        static final String lut = "CATHSOLID";
048
049        public static CathCategory fromString(String type) {
050                if ( type.equals("C") ) {
051                        return Class;
052                } else if ( type.equals("A") ) {
053                        return Architecture;
054                } else if ( type.equals("T") ) {
055                        return Topolgy;
056                } else if ( type.equals("H") ) {
057                        return Homology;
058                } else if ( type.equals("S") ) {
059                        return SequenceFamily;
060                } else if ( type.equals("O") ) {
061                        return OrthologousSequenceFamily;
062                } else if ( type.equals("L") ) {
063                        return LikeSequenceFamily;
064                } else if ( type.equals("I") ) {
065                        return IdenticalSequenceFamily;
066//        } else if ( type.equals("D") ) {
067                } else {
068                        return DomainCounter;
069                }
070        }
071
072        @Override
073        public String toString() {
074                switch (this) {
075                        case Class:
076                                return "C";
077                        case Architecture:
078                                return "A";
079                        case Topolgy:
080                                return "T";
081                        case Homology:
082                                return "H";
083                        case SequenceFamily:
084                                return "S";
085                        case OrthologousSequenceFamily:
086                                return "O";
087                        case LikeSequenceFamily:
088                                return "L";
089                        case IdenticalSequenceFamily:
090                                return "I";
091//            case DomainCounter:
092                        default:
093                                return "D";
094                }
095        }
096
097        public static CathCategory fromCathCode(String code) {
098                int count = 0;
099                int idx = 0;
100                while ((idx = code.indexOf(".",idx)) != -1) {
101                        count++;
102                        idx++;
103                }
104                return fromString(lut.substring(count,count+1));
105        }
106
107}