com.hfg.bio.glyco.Glycan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.bio.glyco;
import java.awt.*;
import java.awt.geom.Point2D;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.hfg.chem.Molecule;
import com.hfg.svg.SVG;
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.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();
// 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;
Rectangle man2bbox = man2.getBoundsBox();
Rectangle man3bbox = man3.getBoundsBox();
if (3 == mannoseCount)
{
if (3 == glcNAcCount)
{
SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point((int) man2bbox.getX() - 4, (int) man2bbox.getY()),
new Point((int) man3bbox.getX() - 4, (int) (man3bbox.getY() + man3bbox.getHeight())), 10);
svg.addSubtag(curlyBrace);
Rectangle curlyBraceBBox = curlyBrace.getBoundsBox();
svg.addSubtag(Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5)));
}
else if (4 == glcNAcCount)
{
SvgNode glcNac3 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float((int) man2bbox.getX() - 20, (int) man2bbox.getY()));
svg.addSubtag(glcNac3);
backbone.addLine(man2.getCenterPoint(), glcNac3.getCenterPoint());
SvgNode glcNac4 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float((int) man3bbox.getX() - 20, (int) man3bbox.getY()));
svg.addSubtag(glcNac4);
backbone.addLine(man3.getCenterPoint(), glcNac4.getCenterPoint());
Rectangle glcNac3bbox = glcNac3.getBoundsBox();
Rectangle glcNac4bbox = glcNac4.getBoundsBox();
if (1 == hexoseCount)
{
SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point((int) glcNac3bbox.getX() - 4, (int) glcNac3bbox.getY()),
new Point((int) glcNac4bbox.getX() - 4, (int) (glcNac4bbox.getY() + glcNac4bbox.getHeight())), 10);
svg.addSubtag(curlyBrace);
Rectangle curlyBraceBBox = curlyBrace.getBoundsBox();
SvgNode hex = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5));
svg.addSubtag(hex);
if (sialicAcidCount > 0)
{
Rectangle hexBBox = hex.getBoundsBox();
SvgNode sialicAcid = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hexBBox.getX() - 20, (int) hexBBox.getY()));
svg.addSubtag(sialicAcid);
backbone.addLine(hex.getCenterPoint(), sialicAcid.getCenterPoint());
}
}
else if (2 == hexoseCount)
{
SvgNode hex1 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) glcNac3bbox.getX() - 20, (int) glcNac3bbox.getY()));
svg.addSubtag(hex1);
backbone.addLine(glcNac3.getCenterPoint(), hex1.getCenterPoint());
SvgNode hex2 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) glcNac4bbox.getX() - 20, (int) glcNac4bbox.getY()));
svg.addSubtag(hex2);
backbone.addLine(glcNac4.getCenterPoint(), hex2.getCenterPoint());
Rectangle hex1bbox = hex1.getBoundsBox();
Rectangle hex2bbox = hex2.getBoundsBox();
if (1 == sialicAcidCount)
{
SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point((int) hex1bbox.getX() - 4, (int) hex1bbox.getY()),
new Point((int) hex2bbox.getX() - 4, (int) (hex2bbox.getY() + hex2bbox.getHeight())), 10);
svg.addSubtag(curlyBrace);
Rectangle curlyBraceBBox = curlyBrace.getBoundsBox();
svg.addSubtag(Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5)));
}
else if (2 == sialicAcidCount)
{
SvgNode sialicAcid1 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hex1bbox.getX() - 20, (int) hex1bbox.getY()));
svg.addSubtag(sialicAcid1);
backbone.addLine(hex1.getCenterPoint(), sialicAcid1.getCenterPoint());
SvgNode sialicAcid2 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hex2bbox.getX() - 20, (int) hex2bbox.getY()));
svg.addSubtag(sialicAcid2);
backbone.addLine(hex2.getCenterPoint(), sialicAcid2.getCenterPoint());
}
}
}
else if (5 == glcNAcCount)
{
SvgNode glcNac3 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float((int) man2bbox.getX() - 20, (int) man2bbox.getY() - 10));
svg.addSubtag(glcNac3);
backbone.addLine(man2.getCenterPoint(), glcNac3.getCenterPoint());
SvgNode glcNac4 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float((int) man3bbox.getX() - 20, (int) man2bbox.getY() + 7));
svg.addSubtag(glcNac4);
backbone.addLine(man2.getCenterPoint(), glcNac4.getCenterPoint());
SvgNode glcNac5 = Monosaccharide.GlcNAc.toSVGNode().setPosition(new Point2D.Float((int) man3bbox.getX() - 20, (int) man3bbox.getY()));
svg.addSubtag(glcNac5);
backbone.addLine(man3.getCenterPoint(), glcNac5.getCenterPoint());
Rectangle glcNac3bbox = glcNac3.getBoundsBox();
Rectangle glcNac4bbox = glcNac4.getBoundsBox();
Rectangle glcNac5bbox = glcNac5.getBoundsBox();
if (hexoseCount >= 1
&& hexoseCount <= 2)
{
SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point((int) glcNac3bbox.getX() - 4, (int) glcNac3bbox.getY()),
new Point((int) glcNac5bbox.getX() - 4, (int) (glcNac5bbox.getY() + glcNac5bbox.getHeight())), 10);
svg.addSubtag(curlyBrace);
Rectangle curlyBraceBBox = curlyBrace.getBoundsBox();
if (1 == hexoseCount)
{
SvgNode hex = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5));
svg.addSubtag(hex);
if (sialicAcidCount > 0)
{
Rectangle hexBBox = hex.getBoundsBox();
SvgNode sialicAcid = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hexBBox.getX() - 20, (int) hexBBox.getY()));
svg.addSubtag(sialicAcid);
backbone.addLine(hex.getCenterPoint(), sialicAcid.getCenterPoint());
}
}
else
{
SvgNode hex1 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.25) - 5));
svg.addSubtag(hex1);
SvgNode hex2 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.75) - 5));
svg.addSubtag(hex2);
Rectangle hex1BBox = hex1.getBoundsBox();
Rectangle hex2BBox = hex2.getBoundsBox();
if (sialicAcidCount > 0)
{
SvgNode sialicAcid = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hex1BBox.getX() - 20, (int) hex1BBox.getY()));
svg.addSubtag(sialicAcid);
backbone.addLine(hex1.getCenterPoint(), sialicAcid.getCenterPoint());
if (2 == sialicAcidCount)
{
SvgNode sialicAcid2 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hex2BBox.getX() - 20, (int) hex2BBox.getY()));
svg.addSubtag(sialicAcid2);
backbone.addLine(hex2.getCenterPoint(), sialicAcid2.getCenterPoint());
}
}
}
}
else if (3 == hexoseCount)
{
SvgNode hex1 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) glcNac3bbox.getX() - 20, (int) glcNac3bbox.getY()));
svg.addSubtag(hex1);
backbone.addLine(glcNac3.getCenterPoint(), hex1.getCenterPoint());
SvgNode hex2 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) glcNac4bbox.getX() - 20, (int) glcNac4bbox.getY()));
svg.addSubtag(hex2);
backbone.addLine(glcNac4.getCenterPoint(), hex2.getCenterPoint());
SvgNode hex3 = Monosaccharide.Hexose.toSVGNode().setPosition(new Point2D.Float((int) glcNac5bbox.getX() - 20, (int) glcNac5bbox.getY()));
svg.addSubtag(hex3);
backbone.addLine(glcNac5.getCenterPoint(), hex3.getCenterPoint());
Rectangle hex1bbox = hex1.getBoundsBox();
Rectangle hex2bbox = hex2.getBoundsBox();
Rectangle hex3bbox = hex3.getBoundsBox();
if (sialicAcidCount >= 1
&& sialicAcidCount <= 2)
{
SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point((int) hex1bbox.getX() - 4, (int) hex1bbox.getY()),
new Point((int) hex3bbox.getX() - 4, (int) (hex3bbox.getY() + hex3bbox.getHeight())), 10);
svg.addSubtag(curlyBrace);
Rectangle curlyBraceBBox = curlyBrace.getBoundsBox();
if (1 == sialicAcidCount)
{
svg.addSubtag(Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5)));
}
else if (2 == sialicAcidCount)
{
SvgNode sialicAcid1 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.25) - 5));
svg.addSubtag(sialicAcid1);
SvgNode sialicAcid2 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.75) - 5));
svg.addSubtag(sialicAcid2);
}
}
else if (3 == sialicAcidCount)
{
SvgNode sialicAcid1 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hex1bbox.getX() - 20, (int) hex1bbox.getY()));
svg.addSubtag(sialicAcid1);
backbone.addLine(hex1.getCenterPoint(), sialicAcid1.getCenterPoint());
SvgNode sialicAcid2 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hex2bbox.getX() - 20, (int) hex2bbox.getY()));
svg.addSubtag(sialicAcid2);
backbone.addLine(hex2.getCenterPoint(), sialicAcid2.getCenterPoint());
SvgNode sialicAcid3 = Monosaccharide.NeuAc.toSVGNode().setPosition(new Point2D.Float((int) hex3bbox.getX() - 20, (int) 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 Point((int) man2bbox.getX() - 4, (int) man2bbox.getY()),
new Point((int) man3bbox.getX() - 4, (int) (man3bbox.getY() + man3bbox.getHeight())), 10);
svg.addSubtag(curlyBrace);
Rectangle curlyBraceBBox = curlyBrace.getBoundsBox();
svg.addSubtag(Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (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)
{
Rectangle man4bbox = man4.getBoundsBox();
Rectangle man6bbox = man6.getBoundsBox();
SvgPath curlyBrace = SvgPath.generateCurlyBracket(new Point((int) man4bbox.getX() - 4, (int) man4bbox.getY()),
new Point((int) man6bbox.getX() - 4, (int) (man6bbox.getY() + man6bbox.getHeight())), 10);
svg.addSubtag(curlyBrace);
Rectangle curlyBraceBBox = curlyBrace.getBoundsBox();
if (7 == mannoseCount)
{
svg.addSubtag(Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() / 2) - 5)));
}
else if (8 == mannoseCount)
{
svg.addSubtag(Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (curlyBraceBBox.getY() + curlyBraceBBox.getHeight() * 0.25) - 5)));
svg.addSubtag(Monosaccharide.Mannose.toSVGNode().setPosition(new Point2D.Float((int) curlyBraceBBox.getX() - 14, (int) (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;
}
}