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 */
021package org.biojava.nbio.structure;
022
023/**
024 *  
025 * The type of entity (polymer, non-polymer, water, macrolide)
026 * as defined in the mmCIF dictionary: <a href="http://mmcif.wwpdb.org/dictionaries/mmcif_pdbx_v40.dic/Items/_entity.type.html"></a>
027 * <p>
028 * Entities are of four types:  polymer, non-polymer, macrolide and water.
029 * <p>
030 * Note that the water category includes only water;  ordered
031 * solvent such as sulfate ion or acetone would be described as
032 * individual non-polymer entities.
033 * It is not clear what macrolides are, but they appear to be supported since mmCIF 4.0.
034 *
035 * 
036 * @author Anthony Bradley
037 * @author Jose Duarte
038 *
039 */
040public enum EntityType {
041
042        /**
043         * Polymeric entities: poly-peptides and nucleotide chains
044         */
045        POLYMER("polymer"),
046        
047        /**
048         * Non-polymeric entities: ligands, metal ions, buffer molecules, etc
049         */
050        NONPOLYMER("non-polymer"), 
051        
052        /**
053         * Water
054         */
055        WATER("water"),
056        
057        /**
058         * Macrolide. Supported in mmCIF 4.0 dictionary. Not clear what it refers to.
059         */
060        MACROLIDE("macrolide");
061        
062        private String entityType;
063
064        /**
065         * @param entType the type of the Entity
066         */
067        private EntityType(String entType) {
068                
069                this.setEntityType(entType);
070                
071        }
072
073        /** 
074         * Returns the type of the Entity as a String
075         *
076         * @return String representation of the entity type.
077     */
078        public String getEntityType() {
079                return entityType;
080        }
081
082
083        private void setEntityType(String entityType) {
084                this.entityType = entityType;
085        }
086
087        /** 
088         * Creates a new EntityType from a String value.
089         * Returns null if entityType is null or not one of the supported
090         * standard types.
091         *
092         * @param entityType String value , should be one of "polymer","non-polymer","water","macrolide"
093         * @return an EntityType object
094     */
095        public static EntityType entityTypeFromString(String entityType)
096        {
097
098                if ( entityType == null)
099                        return null;
100
101                for(EntityType et : EntityType.values())
102                {
103                        if(entityType.equals(et.entityType))
104                        {
105                                return et;
106                        }
107                }
108                return null;
109        }
110        
111}