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 *
021 */
022package org.biojava.nbio.structure.io.mmcif.chem;
023
024import java.io.Serializable;
025import java.util.Arrays;
026import java.util.Collections;
027import java.util.HashSet;
028import java.util.Set;
029
030/**
031 * Enumerates the classification of polymers.
032 * This information is derived from the mmcif dictionary
033 * @author mulvaney
034 * @author Andreas Prlic
035 * @see <a href="http://mmcif.rcsb.org/dictionaries/mmcif_pdbx.dic/Items/_entity_poly.type.html">link into mmCIF dictionary</a>
036 * @since 1.7
037 */
038public enum PolymerType implements Serializable
039{
040
041
042        /**
043         * polypeptide(L)
044         */
045        peptide("polypeptide(L)"),
046
047        /**
048         * polypeptide(D)
049         */
050        dpeptide("polypeptide(D)"),
051
052        /**
053         * polydeoxyribonucleotide
054         */
055        dna("polydeoxyribonucleotide"),
056
057        /**
058         * polyribonucleotide
059         */
060        rna("polyribonucleotide"),
061
062        /**
063         * polydeoxyribonucleotide/polyribonucleotide hybrid
064         */
065        dnarna("polydeoxyribonucleotide/polyribonucleotide hybrid"),
066
067        /**
068         * polysaccharide(D)
069         */
070        polysaccharide("polysaccharide(D)"),
071
072        /**
073         * polysaccharide(L)
074         */
075        lpolysaccharide("polysaccharide(L)"),
076
077        /**
078         * other
079         */
080        otherPolymer("other"),
081
082        /**
083         * cyclic peptides
084         */
085        cyclicPeptide("cyclic-pseudo-peptide"),
086
087        /**
088         * Peptide nucleic acids
089         */
090        peptideNucleicAcid("peptide nucleic acid"),
091
092        /**
093         * if all else fails...
094         */
095        unknown(null);
096
097        PolymerType(String entity_poly_type)
098        {
099                this.entity_poly_type = entity_poly_type;
100        }
101        public final String entity_poly_type;
102
103        public static PolymerType polymerTypeFromString(String polymerType)
104        {
105                for(PolymerType pt : PolymerType.values())
106                {
107                        if(polymerType.equals(pt.entity_poly_type))
108                        {
109                                return pt;
110                        }
111                }
112                return unknown;
113        }
114
115        /**
116         * Convenience <tt>Set</tt> of polymer types classified as protein.  This only contains {@link #peptide}
117         */
118        public static final Set<PolymerType> PROTEIN_ONLY;
119
120        /**
121         * Convenience <tt>Set</tt> of polymer types classified as DNA.  This only contains {@link #dna}
122         */
123        public static final Set<PolymerType> DNA_ONLY;
124
125        /**
126         * Convenience <tt>Set</tt> of polymer types classified as RNA.  This only contains {@link #rna}
127         */
128        public static final Set<PolymerType> RNA_ONLY;
129
130        /**
131         * Convenience <tt>Set</tt> of polymer types classified as DNA.  This contains:
132         * <ul>
133         * <li>{@link #dna}</li>
134         * <li>{@link #rna}</li>
135         * <li>{@link #dnarna}</li>
136         * </ul>
137         */
138        public static final Set<PolymerType> POLYNUCLEOTIDE_ONLY;
139
140        /**
141         * Convenience <tt>Set</tt> of all polymer types.
142         */
143        public static final Set<PolymerType> ALL_POLYMER_TYPES;
144
145        static {
146                Set<PolymerType> tmp;
147
148                tmp = new HashSet<PolymerType>();
149                tmp.add(peptide);
150                PROTEIN_ONLY = Collections.unmodifiableSet(tmp);
151
152                tmp = new HashSet<PolymerType>();
153                tmp.add(dna);
154                DNA_ONLY = Collections.unmodifiableSet(tmp);
155
156                tmp = new HashSet<PolymerType>();
157                tmp.add(rna);
158                RNA_ONLY = Collections.unmodifiableSet(tmp);
159
160                tmp = new HashSet<PolymerType>();
161                tmp.add(dna);
162                tmp.add(rna);
163                tmp.add(dnarna);
164                POLYNUCLEOTIDE_ONLY = Collections.unmodifiableSet(tmp);
165
166                ALL_POLYMER_TYPES = Collections.unmodifiableSet(new HashSet<PolymerType>(Arrays.asList(values())));
167        }
168
169}