All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.bio.glyco.Glycan Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.bio.glyco;


import java.awt.*;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.hfg.chem.IonizableGroup;
import com.hfg.chem.Molecule;
import com.hfg.svg.SVG;
import com.hfg.svg.SvgAttr;
import com.hfg.svg.SvgGroup;
import com.hfg.svg.SvgNode;
import com.hfg.svg.SvgPath;
import com.hfg.util.CompareUtil;
import com.hfg.util.StringUtil;
import com.hfg.util.collection.CollectionUtil;
import com.hfg.util.collection.OrderedSet;


//------------------------------------------------------------------------------
/**
 Common mammalian polysaccharide structures.
 Masses / elemental compositions for glycans are for intact structures.
 A water is removed when a glycan is attached to a protein.
 
@author J. Alex Taylor, hairyfatguy.com
*/ //------------------------------------------------------------------------------ // com.hfg XML/HTML Coding Library // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com // [email protected] //------------------------------------------------------------------------------ public class Glycan extends Molecule { //########################################################################## // PUBLIC FIELDS //########################################################################## // Complex public static Glycan A2G0 = new Glycan("A2G0"); public static Glycan A2G0F = new Glycan("A2G0F"); public static Glycan A2G1 = new Glycan("A2G1"); public static Glycan A2G1F = new Glycan("A2G1F"); public static Glycan A2G2 = new Glycan("A2G2"); public static Glycan A2G2F = new Glycan("A2G2F"); public static Glycan A2S1G0F = new Glycan("A2S1G0F"); public static Glycan A2S1G1 = new Glycan("A2S1G1"); public static Glycan A2S1G1F = new Glycan("A2S1G1F"); public static Glycan A2S2 = new Glycan("A2S2"); public static Glycan A3G0 = new Glycan("A3G0"); public static Glycan A3G0F = new Glycan("A3G0F"); public static Glycan A3G1 = new Glycan("A3G1"); public static Glycan A3G1F = new Glycan("A3G1F"); public static Glycan A3G2 = new Glycan("A3G2"); public static Glycan A3G2F = new Glycan("A3G2F"); public static Glycan A3S1G2 = new Glycan("A3S1G2"); public static Glycan A3G3 = new Glycan("A3G3"); public static Glycan A3S3 = new Glycan("A3S3"); public static Glycan A3S2G1 = new Glycan("A3S2G1"); // Hybrid public static Glycan M3F = new Glycan("M3F"); // Core-F public static Glycan A1G0 = new Glycan("A1G0"); public static Glycan A1G0F = new Glycan("A1G0F"); public static Glycan A1G0M4F = new Glycan("A1G0M4F"); public static Glycan A1G1F = new Glycan("A1G1F"); public static Glycan A1G1M4F = new Glycan("A1G1M4F"); public static Glycan A1G1M5F = new Glycan("A1G1M5F"); public static Glycan A1S1M4F = new Glycan("A1S1M4F"); public static Glycan A2G0M4F = new Glycan("A2G0M4F"); public static Glycan A2S2F = new Glycan("A2S2F"); public static Glycan A3G3F = new Glycan("A3G3F"); public static Glycan A3S1G2F = new Glycan("A3S1G2F"); public static Glycan A3S2G1F = new Glycan("A3S2G1F"); public static Glycan A3S3F = new Glycan("A3S3F"); // High-Mannose public static Glycan M3 = new Glycan("M3"); // Core public static Glycan M4 = new Glycan("M4"); public static Glycan M5 = new Glycan("M5"); public static Glycan M6 = new Glycan("M6"); public static Glycan M7 = new Glycan("M7"); public static Glycan M8 = new Glycan("M8"); public static Glycan M9 = new Glycan("M9"); //########################################################################## // PRIVATE FIELDS //########################################################################## private String mName; private String mAbbrev; private Map mMonosaccharideCountMap = new HashMap<>(5); // This declaration has to come before the public constants below. private static Set sValues = new OrderedSet<>(); static { M3.add(Monosaccharide.GlcNAc, 2) .add(Monosaccharide.Mannose, 3) .lock() .register(); A2G0.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .lock() .register(); A2G0F.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Fucose, 1) .lock() .register(); A2G1.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 1) .lock() .register(); A2G1F.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 1) .add(Monosaccharide.Fucose, 1) .lock() .register(); A2G2.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 2) .lock() .register(); A2G2F.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 2) .add(Monosaccharide.Fucose, 1) .lock() .register(); A2S1G0F.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 1) .add(Monosaccharide.NeuAc, 1) .lock() .register(); A2S1G1.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 2) .add(Monosaccharide.NeuAc, 1) .lock() .register(); A2S1G1F.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 2) .add(Monosaccharide.Fucose, 1) .add(Monosaccharide.NeuAc, 1) .lock() .register(); A2S2.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 2) .add(Monosaccharide.NeuAc, 2) .lock() .register(); A3G0.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .lock() .register(); A3G0F.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Fucose, 1) .lock() .register(); A3G1.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 1) .lock() .register(); A3G1F.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 1) .add(Monosaccharide.Fucose, 1) .lock() .register(); A3G2.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 2) .lock() .register(); A3G2F.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 2) .add(Monosaccharide.Fucose, 1) .lock() .register(); A3S1G2.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 3) .add(Monosaccharide.NeuAc, 1) .lock() .register(); A3S2G1.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 3) .add(Monosaccharide.NeuAc, 2) .lock() .register(); A3G3.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 3) .lock() .register(); A3S3.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 3) .add(Monosaccharide.NeuAc, 3) .lock() .register(); M3F.add(Monosaccharide.GlcNAc, 2) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Fucose, 1) .lock() .register(); A1G0.add(Monosaccharide.GlcNAc, 3) .add(Monosaccharide.Mannose, 3) .lock() .register(); A1G0F.add(Monosaccharide.GlcNAc, 3) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Fucose, 1) .lock() .register(); A1G0M4F.add(Monosaccharide.GlcNAc, 3) .add(Monosaccharide.Mannose, 4) .add(Monosaccharide.Fucose, 1) .lock() .register(); A1G1F.add(Monosaccharide.GlcNAc, 3) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 1) .add(Monosaccharide.Fucose, 1) .lock() .register(); A1G1M4F.add(Monosaccharide.GlcNAc, 3) .add(Monosaccharide.Mannose, 4) .add(Monosaccharide.Hexose, 1) .add(Monosaccharide.Fucose, 1) .lock() .register(); A1G1M5F.add(Monosaccharide.GlcNAc, 3) .add(Monosaccharide.Mannose, 5) .add(Monosaccharide.Hexose, 1) .add(Monosaccharide.Fucose, 1) .lock() .register(); A1S1M4F.add(Monosaccharide.GlcNAc, 3) .add(Monosaccharide.Mannose, 4) .add(Monosaccharide.Hexose, 1) .add(Monosaccharide.Fucose, 1) .add(Monosaccharide.NeuAc, 1) .lock() .register(); A2G0M4F.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 4) .add(Monosaccharide.Fucose, 1) .lock() .register(); A2S2F.add(Monosaccharide.GlcNAc, 4) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 2) .add(Monosaccharide.Fucose, 1) .add(Monosaccharide.NeuAc, 2) .lock() .register(); A3G3F.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 3) .add(Monosaccharide.Fucose, 1) .lock() .register(); A3S1G2F.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 3) .add(Monosaccharide.Fucose, 1) .add(Monosaccharide.NeuAc, 1) .lock() .register(); A3S2G1F.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 3) .add(Monosaccharide.Fucose, 1) .add(Monosaccharide.NeuAc, 2) .lock() .register(); A3S3F.add(Monosaccharide.GlcNAc, 5) .add(Monosaccharide.Mannose, 3) .add(Monosaccharide.Hexose, 3) .add(Monosaccharide.Fucose, 1) .add(Monosaccharide.NeuAc, 3) .lock() .register(); M4.add(Monosaccharide.GlcNAc, 2) .add(Monosaccharide.Mannose, 4) .lock() .register(); M5.add(Monosaccharide.GlcNAc, 2) .add(Monosaccharide.Mannose, 5) .lock() .register(); M6.add(Monosaccharide.GlcNAc, 2) .add(Monosaccharide.Mannose, 6) .lock() .register(); M7.add(Monosaccharide.GlcNAc, 2) .add(Monosaccharide.Mannose, 7) .lock() .register(); M8.add(Monosaccharide.GlcNAc, 2) .add(Monosaccharide.Mannose, 8) .lock() .register(); M9.add(Monosaccharide.GlcNAc, 2) .add(Monosaccharide.Mannose, 9) .lock() .register(); } //########################################################################## // CONSTRUCTORS //########################################################################## //-------------------------------------------------------------------------- private Glycan(String inName) { mName = inName; mAbbrev = inName; } //########################################################################## // PUBLIC METHODS //########################################################################## //-------------------------------------------------------------------------- public static Glycan valueOf(String inString) { Glycan value = null; if (StringUtil.isSet(inString)) { for (Glycan glycan : sValues) { if (glycan.name().equalsIgnoreCase(inString) || glycan.getAbbrev().equals(inString)) { value = glycan; break; } } } return value; } //-------------------------------------------------------------------------- public static Glycan[] values() { return sValues.toArray(new Glycan[sValues.size()]); } //-------------------------------------------------------------------------- /** Puts the Glycan into the Set of unique Glycans returned by Glycan.values(). */ public void register() { if (! isLocked()) { throw new RuntimeException("Only locked Glycans can be added to the values list!"); } sValues.add(this); } //-------------------------------------------------------------------------- @Override public int compareTo(Object inObj2) { int result = -1; if (inObj2 != null) { if (inObj2 instanceof Glycan) { Glycan glycan2 = (Glycan) inObj2; result = CompareUtil.compare(name(), glycan2.name()); } else { result = CompareUtil.compare(hashCode(), inObj2.hashCode()); } } return result; } //-------------------------------------------------------------------------- @Override public Glycan lock() { return (Glycan) super.lock(); } //-------------------------------------------------------------------------- public String name() { return mName; } //-------------------------------------------------------------------------- public String getAbbrev() { return mAbbrev; } //-------------------------------------------------------------------------- @Override public String toString() { return getAbbrev(); } //-------------------------------------------------------------------------- public SVG toSVG() { SVG svg = new SVG(); SvgGroup backbone = svg.addGroup().addStyle(SvgAttr.stroke + ": #000000"); // Start with the M3 core SvgGroup core = svg.addGroup(); SvgNode glcNAc1 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float(130, 27)); core.addSubtag(glcNAc1); SvgNode glcNAc2 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float(110, 27)); core.addSubtag(glcNAc2); backbone.addLine(glcNAc1.getCenterPoint(), glcNAc2.getCenterPoint()); SvgNode man1 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(90, 27)); core.addSubtag(man1); backbone.addLine(glcNAc2.getCenterPoint(), man1.getCenterPoint()); SvgNode man2 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(70, 12)); core.addSubtag(man2); backbone.addLine(man1.getCenterPoint(), man2.getCenterPoint()); SvgNode man3 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(70, 37)); core.addSubtag(man3); backbone.addLine(man1.getCenterPoint(), man3.getCenterPoint()); if (name().endsWith("F")) { SvgNode svgNode = Monosaccharide.Fucose.toSVGNode().setPosition(new Point2D.Float(130, 7)); svg.addSubtag(svgNode); backbone.addLine(glcNAc1.getCenterPoint(), svgNode.getCenterPoint()); } int mannoseCount = mMonosaccharideCountMap.containsKey(Monosaccharide.Mannose) ? mMonosaccharideCountMap.get(Monosaccharide.Mannose) : 0; int glcNAcCount = mMonosaccharideCountMap.containsKey(Monosaccharide.GlcNAc) ? mMonosaccharideCountMap.get(Monosaccharide.GlcNAc) : 0; int hexoseCount = mMonosaccharideCountMap.containsKey(Monosaccharide.Hexose) ? mMonosaccharideCountMap.get(Monosaccharide.Hexose) : 0; int sialicAcidCount = mMonosaccharideCountMap.containsKey(Monosaccharide.NeuAc) ? mMonosaccharideCountMap.get(Monosaccharide.NeuAc) : 0; Rectangle2D man2bbox = man2.getBoundsBox(); Rectangle2D man3bbox = man3.getBoundsBox(); if (3 == mannoseCount) { if (3 == glcNAcCount) { SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point2D.Double(man2bbox.getX() - 4, man2bbox.getY()), new Point2D.Double(man3bbox.getX() - 4, (man3bbox.getY() + man3bbox.getHeight())), 10); svg.addSubtag(curlyBrace); Rectangle2D curlyBraceBBox = curlyBrace.getBoundsBox(); svg.addSubtag(Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5))); } else if (4 == glcNAcCount) { SvgNode glcNac3 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Double(man2bbox.getX() - 20, man2bbox.getY())); svg.addSubtag(glcNac3); backbone.addLine(man2.getCenterPoint(), glcNac3.getCenterPoint()); SvgNode glcNac4 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Double(man3bbox.getX() - 20, man3bbox.getY())); svg.addSubtag(glcNac4); backbone.addLine(man3.getCenterPoint(), glcNac4.getCenterPoint()); Rectangle2D glcNac3bbox = glcNac3.getBoundsBox(); Rectangle2D glcNac4bbox = glcNac4.getBoundsBox(); if (1 == hexoseCount) { SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point2D.Double(glcNac3bbox.getX() - 4, glcNac3bbox.getY()), new Point2D.Double(glcNac4bbox.getX() - 4, (glcNac4bbox.getY() + glcNac4bbox.getHeight())), 10); svg.addSubtag(curlyBrace); Rectangle2D curlyBraceBBox = curlyBrace.getBoundsBox(); SvgNode hex = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5)); svg.addSubtag(hex); if (sialicAcidCount > 0) { Rectangle2D hexBBox = hex.getBoundsBox(); SvgNode sialicAcid = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hexBBox.getX() - 20, hexBBox.getY())); svg.addSubtag(sialicAcid); backbone.addLine(hex.getCenterPoint(), sialicAcid.getCenterPoint()); } } else if (2 == hexoseCount) { SvgNode hex1 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(glcNac3bbox.getX() - 20, glcNac3bbox.getY())); svg.addSubtag(hex1); backbone.addLine(glcNac3.getCenterPoint(), hex1.getCenterPoint()); SvgNode hex2 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(glcNac4bbox.getX() - 20, glcNac4bbox.getY())); svg.addSubtag(hex2); backbone.addLine(glcNac4.getCenterPoint(), hex2.getCenterPoint()); Rectangle2D hex1bbox = hex1.getBoundsBox(); Rectangle2D hex2bbox = hex2.getBoundsBox(); if (1 == sialicAcidCount) { SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point2D.Double(hex1bbox.getX() - 4, hex1bbox.getY()), new Point2D.Double(hex2bbox.getX() - 4, (hex2bbox.getY() + hex2bbox.getHeight())), 10); svg.addSubtag(curlyBrace); Rectangle curlyBraceBBox = curlyBrace.getBoundsBox(); svg.addSubtag(Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5))); } else if (2 == sialicAcidCount) { SvgNode sialicAcid1 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hex1bbox.getX() - 20, hex1bbox.getY())); svg.addSubtag(sialicAcid1); backbone.addLine(hex1.getCenterPoint(), sialicAcid1.getCenterPoint()); SvgNode sialicAcid2 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hex2bbox.getX() - 20, hex2bbox.getY())); svg.addSubtag(sialicAcid2); backbone.addLine(hex2.getCenterPoint(), sialicAcid2.getCenterPoint()); } } } else if (5 == glcNAcCount) { SvgNode glcNac3 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Double(man2bbox.getX() - 20, man2bbox.getY() - 10)); svg.addSubtag(glcNac3); backbone.addLine(man2.getCenterPoint(), glcNac3.getCenterPoint()); SvgNode glcNac4 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Double(man3bbox.getX() - 20, man2bbox.getY() + 7)); svg.addSubtag(glcNac4); backbone.addLine(man2.getCenterPoint(), glcNac4.getCenterPoint()); SvgNode glcNac5 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Double(man3bbox.getX() - 20, man3bbox.getY())); svg.addSubtag(glcNac5); backbone.addLine(man3.getCenterPoint(), glcNac5.getCenterPoint()); Rectangle2D glcNac3bbox = glcNac3.getBoundsBox(); Rectangle2D glcNac4bbox = glcNac4.getBoundsBox(); Rectangle2D glcNac5bbox = glcNac5.getBoundsBox(); if (hexoseCount >= 1 && hexoseCount <= 2) { SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point2D.Double(glcNac3bbox.getX() - 4, glcNac3bbox.getY()), new Point2D.Double(glcNac5bbox.getX() - 4, (glcNac5bbox.getY() + glcNac5bbox.getHeight())), 10); svg.addSubtag(curlyBrace); Rectangle2D curlyBraceBBox = curlyBrace.getBoundsBox(); if (1 == hexoseCount) { SvgNode hex = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5)); svg.addSubtag(hex); if (sialicAcidCount > 0) { Rectangle2D hexBBox = hex.getBoundsBox(); SvgNode sialicAcid = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hexBBox.getX() - 20, hexBBox.getY())); svg.addSubtag(sialicAcid); backbone.addLine(hex.getCenterPoint(), sialicAcid.getCenterPoint()); } } else { SvgNode hex1 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.25) - 5)); svg.addSubtag(hex1); SvgNode hex2 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.75) - 5)); svg.addSubtag(hex2); Rectangle2D hex1BBox = hex1.getBoundsBox(); Rectangle2D hex2BBox = hex2.getBoundsBox(); if (sialicAcidCount > 0) { SvgNode sialicAcid = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hex1BBox.getX() - 20, hex1BBox.getY())); svg.addSubtag(sialicAcid); backbone.addLine(hex1.getCenterPoint(), sialicAcid.getCenterPoint()); if (2 == sialicAcidCount) { SvgNode sialicAcid2 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hex2BBox.getX() - 20, hex2BBox.getY())); svg.addSubtag(sialicAcid2); backbone.addLine(hex2.getCenterPoint(), sialicAcid2.getCenterPoint()); } } } } else if (3 == hexoseCount) { SvgNode hex1 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(glcNac3bbox.getX() - 20, glcNac3bbox.getY())); svg.addSubtag(hex1); backbone.addLine(glcNac3.getCenterPoint(), hex1.getCenterPoint()); SvgNode hex2 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(glcNac4bbox.getX() - 20, glcNac4bbox.getY())); svg.addSubtag(hex2); backbone.addLine(glcNac4.getCenterPoint(), hex2.getCenterPoint()); SvgNode hex3 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Double(glcNac5bbox.getX() - 20, glcNac5bbox.getY())); svg.addSubtag(hex3); backbone.addLine(glcNac5.getCenterPoint(), hex3.getCenterPoint()); Rectangle2D hex1bbox = hex1.getBoundsBox(); Rectangle2D hex2bbox = hex2.getBoundsBox(); Rectangle2D hex3bbox = hex3.getBoundsBox(); if (sialicAcidCount >= 1 && sialicAcidCount <= 2) { SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point2D.Double(hex1bbox.getX() - 4, hex1bbox.getY()), new Point2D.Double(hex3bbox.getX() - 4, (hex3bbox.getY() + hex3bbox.getHeight())), 10); svg.addSubtag(curlyBrace); Rectangle2D curlyBraceBBox = curlyBrace.getBoundsBox(); if (1 == sialicAcidCount) { svg.addSubtag(Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5))); } else if (2 == sialicAcidCount) { SvgNode sialicAcid1 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.25) - 5)); svg.addSubtag(sialicAcid1); SvgNode sialicAcid2 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.75) - 5)); svg.addSubtag(sialicAcid2); } } else if (3 == sialicAcidCount) { SvgNode sialicAcid1 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hex1bbox.getX() - 20, hex1bbox.getY())); svg.addSubtag(sialicAcid1); backbone.addLine(hex1.getCenterPoint(), sialicAcid1.getCenterPoint()); SvgNode sialicAcid2 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hex2bbox.getX() - 20, hex2bbox.getY())); svg.addSubtag(sialicAcid2); backbone.addLine(hex2.getCenterPoint(), sialicAcid2.getCenterPoint()); SvgNode sialicAcid3 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Double(hex3bbox.getX() - 20, hex3bbox.getY())); svg.addSubtag(sialicAcid3); backbone.addLine(hex3.getCenterPoint(), sialicAcid3.getCenterPoint()); } } } } else if (4 == mannoseCount) { if (glcNAcCount > 2) { SvgNode man4 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(50, 7)); svg.addSubtag(man4); backbone.addLine(man2.getCenterPoint(), man4.getCenterPoint()); SvgNode glcNac3 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float(50, 37)); svg.addSubtag(glcNac3); backbone.addLine(man3.getCenterPoint(), glcNac3.getCenterPoint()); if (hexoseCount > 0) { SvgNode hex = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float(30, 37)); svg.addSubtag(hex); backbone.addLine(glcNac3.getCenterPoint(), hex.getCenterPoint()); if (sialicAcidCount > 0) { SvgNode sialicAcid = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float(10, 37)); svg.addSubtag(sialicAcid); backbone.addLine(hex.getCenterPoint(), sialicAcid.getCenterPoint()); } } } else { SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point2D.Double(man2bbox.getX() - 4, man2bbox.getY()), new Point2D.Double(man3bbox.getX() - 4, (man3bbox.getY() + man3bbox.getHeight())), 10); svg.addSubtag(curlyBrace); Rectangle2D curlyBraceBBox = curlyBrace.getBoundsBox(); svg.addSubtag(Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5))); } } else if (5 == mannoseCount) { SvgNode man4 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(50, 2)); svg.addSubtag(man4); backbone.addLine(man2.getCenterPoint(), man4.getCenterPoint()); SvgNode man5 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(50, 19)); svg.addSubtag(man5); backbone.addLine(man2.getCenterPoint(), man5.getCenterPoint()); if (glcNAcCount > 2) { SvgNode glcNac3 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float(50, 37)); svg.addSubtag(glcNac3); backbone.addLine(man3.getCenterPoint(), glcNac3.getCenterPoint()); if (hexoseCount > 0) { SvgNode hex = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float(30, 37)); svg.addSubtag(hex); backbone.addLine(glcNac3.getCenterPoint(), hex.getCenterPoint()); if (sialicAcidCount > 0) { SvgNode sialicAcid = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float(10, 37)); svg.addSubtag(sialicAcid); backbone.addLine(hex.getCenterPoint(), sialicAcid.getCenterPoint()); } } } } else if (6 <= mannoseCount) { SvgNode man4 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(50, 2)); svg.addSubtag(man4); backbone.addLine(man2.getCenterPoint(), man4.getCenterPoint()); SvgNode man5 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(50, 19)); svg.addSubtag(man5); backbone.addLine(man2.getCenterPoint(), man5.getCenterPoint()); SvgNode man6 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(50, 37)); svg.addSubtag(man6); backbone.addLine(man3.getCenterPoint(), man6.getCenterPoint()); if (9 == mannoseCount) { SvgNode man7 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(30, 2)); svg.addSubtag(man7); backbone.addLine(man4.getCenterPoint(), man7.getCenterPoint()); SvgNode man8 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(30, 19)); svg.addSubtag(man8); backbone.addLine(man5.getCenterPoint(), man8.getCenterPoint()); SvgNode man9 = Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float(30, 37)); svg.addSubtag(man9); backbone.addLine(man6.getCenterPoint(), man9.getCenterPoint()); } else if (mannoseCount > 6) { Rectangle2D man4bbox = man4.getBoundsBox(); Rectangle2D man6bbox = man6.getBoundsBox(); SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point2D.Double(man4bbox.getX() - 4, man4bbox.getY()), new Point2D.Double(man6bbox.getX() - 4, man6bbox.getY() + man6bbox.getHeight()), 10); svg.addSubtag(curlyBrace); Rectangle2D curlyBraceBBox = curlyBrace.getBoundsBox(); if (7 == mannoseCount) { svg.addSubtag(Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5))); } else if (8 == mannoseCount) { svg.addSubtag(Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.25) - 5))); svg.addSubtag(Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Double(curlyBraceBBox.getX() - 14, (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.75) - 5))); } } } return svg; } //-------------------------------------------------------------------------- public Glycan add(Monosaccharide inMonosaccharide, int inCount) { Integer currentCount = mMonosaccharideCountMap.get(inMonosaccharide); int newCount = (currentCount != null ? currentCount : 0) + inCount; int newBondCount = inCount - 1 + (mMonosaccharideCountMap.size() > 0 ? 1 : 0); mMonosaccharideCountMap.put(inMonosaccharide, newCount); super.add(inMonosaccharide, inCount); super.remove(Molecule.H2O, newBondCount); return this; } //-------------------------------------------------------------------------- /** Returns a List of IonizableGroup objects. @return List of IonizableGroups */ public List getKas() { List ionizableGroups = null; for (Monosaccharide monosaccharide : mMonosaccharideCountMap.keySet()) { List monosaccharideKas = monosaccharide.getKas(); if (CollectionUtil.hasValues(monosaccharideKas)) { if (null == ionizableGroups) { ionizableGroups = new ArrayList<>(5); } for (IonizableGroup ionizableGroup : monosaccharideKas) { for (int i = 0; i < mMonosaccharideCountMap.get(monosaccharide); i++) { ionizableGroups.add(ionizableGroup); } } } } return ionizableGroups; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy