001package org.biojava.nbio.structure.chem;
002
003import org.biojava.nbio.structure.io.cif.CifBean;
004import org.slf4j.Logger;
005import org.slf4j.LoggerFactory;
006
007/**
008 * Properties of a bond in a chemical component.
009 * @author Sebastian Bittrich
010 * @since 6.0.0
011 */
012public class ChemCompBond implements CifBean {
013    private static final long serialVersionUID = 5905371029161975421L;
014    private static final Logger logger = LoggerFactory.getLogger(ChemCompBond.class);
015
016    private String compId;
017    private String atomId1;
018    private String atomId2;
019    private String valueOrder;
020    private String pdbxAromaticFlag;
021    private String pdbxStereoConfig;
022    private int pdbxOrdinal;
023
024    public static Logger getLogger() {
025        return logger;
026    }
027
028    public String getCompId() {
029        return compId;
030    }
031
032    public void setCompId(String compId) {
033        this.compId = compId;
034    }
035
036    public String getAtomId1() {
037        return atomId1;
038    }
039
040    public void setAtomId1(String atomId1) {
041        this.atomId1 = atomId1;
042    }
043
044    public String getAtomId2() {
045        return atomId2;
046    }
047
048    public void setAtomId2(String atomId2) {
049        this.atomId2 = atomId2;
050    }
051
052    public String getValueOrder() {
053        return valueOrder;
054    }
055
056    public void setValueOrder(String valueOrder) {
057        this.valueOrder = valueOrder;
058    }
059
060    public String getPdbxAromaticFlag() {
061        return pdbxAromaticFlag;
062    }
063
064    public void setPdbxAromaticFlag(String pdbxAromaticFlag) {
065        this.pdbxAromaticFlag = pdbxAromaticFlag;
066    }
067
068    public String getPdbxStereoConfig() {
069        return pdbxStereoConfig;
070    }
071
072    public void setPdbxStereoConfig(String pdbxStereoConfig) {
073        this.pdbxStereoConfig = pdbxStereoConfig;
074    }
075
076    public int getPdbxOrdinal() {
077        return pdbxOrdinal;
078    }
079
080    public void setPdbxOrdinal(int pdbxOrdinal) {
081        this.pdbxOrdinal = pdbxOrdinal;
082    }
083
084    /**
085     * Converts this ChemCompBond's value_order attribute into an int using the
086     * conversion:
087     *
088     * <pre>
089     *  SING -> 1
090     *  DOUB -> 2
091     *  TRIP -> 3
092     *  QUAD -> 4
093     * </pre>
094     *
095     * Any other values will return -1.
096     * <p>
097     * (Source:
098     * http://mmcif.rcsb.org/dictionaries/mmcif_mdb.dic/Items/_chem_comp_bond.
099     * value_order.html)
100     *
101     * @return the numerical value of this ChemCompBond's bond order, or -1 if
102     *         the value is non-numeric or unknown.
103     */
104    public int getNumericalBondOrder() {
105        switch (valueOrder) {
106            case "SING":
107                return 1;
108            case "DOUB":
109                return 2;
110            case "TRIP":
111                return 3;
112            case "QUAD":
113                return 4;
114            default:
115                logger.error("Unknown or non-numeric value for value_order: " + valueOrder);
116                return -1;
117        }
118    }
119}