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.secstruc;
022
023import java.io.Serializable;
024
025import org.biojava.nbio.structure.Group;
026
027/**
028 * Container for the secondary structure information of a single residue. This
029 * class is designed to be stored inside an Amino Acid object. It can also
030 * contain a back-reference to its parent AA.
031 *
032 * @author Aleix Lafita
033 * @since 4.1.1
034 *
035 */
036public class SecStrucInfo implements Serializable {
037
038        private static final long serialVersionUID = 4516925175715607227L;
039
040        /** Secondary strucuture assigned by the PDB author */
041        public static final String PDB_AUTHOR_ASSIGNMENT = "PDB_AUTHOR_ASSIGNMENT";
042
043        /** Secondary strucuture parsed from a DSSP output file */
044        public static final String DSSP_ASSIGNMENT = "DSSP_ASSIGNMENT";
045
046        /** Secondary strucuture calculated and assigned by DSSP of BioJava */
047        public static final String BIOJAVA_ASSIGNMENT = "BIOJAVA_ASSIGNMENT";
048
049        protected SecStrucType type;
050        protected String assignment;
051        protected Group parent;
052
053        public SecStrucInfo(Group g, String ass, SecStrucType t) {
054                type = t;
055                assignment = ass;
056                parent = g;
057        }
058
059        public SecStrucType getType() {
060                return type;
061        }
062
063        public void setType(SecStrucType t) {
064                type = t;
065        }
066
067        public String getAssignment() {
068                return assignment;
069        }
070
071        public Group getGroup() {
072                return parent;
073        }
074
075        @Override
076        public String toString() {
077                return assignment + ": " + type;
078        }
079
080        @Override
081        public int hashCode() {
082            final int prime = 31;
083            int result = 1;
084            result = prime * result
085                    + ((assignment == null) ? 0 : type.hashCode());
086            return result;
087        }
088
089        @Override
090        public boolean equals(Object o) {
091                if (!(o instanceof SecStrucInfo))
092                        return false;
093                else {
094                        SecStrucInfo ss = (SecStrucInfo) o;
095                        if (type == ss.type)
096                                return true;
097                        else
098                                return false;
099                }
100        }
101
102}