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 * Created on May 30, 2010
021 * Author: Jianjiong Gao
022 *
023 */
024
025package org.biojava.nbio.protmod;
026
027import java.util.HashMap;
028import java.util.Map;
029
030/**
031 * define modification categories.
032 *
033 * @author Jianjiong Gao
034 * @since 3.0
035 */
036public enum ModificationCategory {
037        ATTACHMENT("attachment", "Attachment of a chemical group"),
038        CHEMICAL_MODIFICATION("modified residue", "Chemical modification of an residue"),
039        CROSS_LINK_1("crosslink1", "A complicated cross-link (usually found in chromophores)"),
040        CROSS_LINK_2("crosslink2", "A cross-link of two residues"),
041        CROSS_LINK_3("crosslink3", "A cross-link of three residues"),
042        CROSS_LINK_4("crosslink4", "A cross-link of four residues"),
043        CROSS_LINK_5("crosslink5", "A cross-link of five residues"),
044        CROSS_LINK_6("crosslink6", "A cross-link of six residues"),
045        CROSS_LINK_7("crosslink7", "A cross-link of seven residues"),
046        CROSS_LINK_8_OR_LARGE("crosslink8 or large", "A cross-link of eight or more residues"), // 8 or high
047        UNDEFINED("undefined", "Undefined category")
048        ;
049
050        ModificationCategory(String label, String desc) {
051                this.label = label;
052        }
053
054        /**
055         *
056         * @return the label of this ModificationCategory.
057         */
058        public String label() {
059                return label;
060        }
061
062        /**
063         *
064         * @return the description
065         */
066        public String description() {
067                return desc;
068        }
069
070        /**
071         * @return the label of this ModificationCategory.
072         */
073        @Override
074        public String toString() {
075                return label;
076        }
077
078        /**
079         *
080         * @return true if it is a CrossLink; false, otherwise.
081         */
082        public boolean isCrossLink() {
083                return this == CROSS_LINK_1
084                        || this == CROSS_LINK_2
085                        || this == CROSS_LINK_3
086                        || this == CROSS_LINK_4
087                        || this == CROSS_LINK_5
088                        || this == CROSS_LINK_6
089                        || this == CROSS_LINK_7
090                        || this == CROSS_LINK_8_OR_LARGE;
091        }
092
093        /**
094         * The variable is the same as the &ltType> in the ptm_list XML file.
095         */
096        private String label;
097
098        private String desc;
099
100        /**
101         *
102         * @param label the label of ModificationCategory.
103         * @return the ModificationCategory that has the label.
104         */
105        public static ModificationCategory getByLabel(String label) {
106                return mapLabelCat.get(label);
107        }
108
109        private static Map<String, ModificationCategory> mapLabelCat;
110        static {
111                mapLabelCat = new HashMap<String, ModificationCategory>();
112                for (ModificationCategory cat:ModificationCategory.values()) {
113                        mapLabelCat.put(cat.label, cat);
114                }
115        }
116}