com.hfg.bio.NTerminalGroup 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;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.hfg.chem.Charge;
import com.hfg.chem.Element;
import com.hfg.chem.IonizableGroup;
import com.hfg.chem.Molecule;
import com.hfg.xml.XMLNode;
import com.hfg.util.StringUtil;
//------------------------------------------------------------------------------
/**
N-terminal protein group.
@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 NTerminalGroup extends Molecule
{
// This declaration has to come before the public constants below.
private static Set sValues = new HashSet<>(15);
//##########################################################################
// PUBLIC FIELDS
//##########################################################################
public static final NTerminalGroup UNMODIFIED_N_TERMINUS = new NTerminalGroup("Unmodified", "<");
public static final NTerminalGroup BOC_T_BUTYLOXYCARBONYL = new NTerminalGroup("Boc (t-butyloxycarbonyl)-", "Boc-");
public static final NTerminalGroup CBZ_BENZYLOXYCARBONLYL = new NTerminalGroup("CBZ (Benzyloxycarbonyl)-", "CBZ-");
public static final NTerminalGroup N_ACETYL = new NTerminalGroup("N-acetyl-", "N-acetyl-");
public static final NTerminalGroup N_CARBAMYL = new NTerminalGroup("N-carbamyl-", "N-carbamyl-");
public static final NTerminalGroup N_FORMYL = new NTerminalGroup("N-formyl-", "N-formyl-");
public static final NTerminalGroup N_METHYL = new NTerminalGroup("N-methyl-", "N-methyl-");
public static final NTerminalGroup N_MYRISTOYL = new NTerminalGroup("N-myristoyl-", "N-myristoyl-");
public static final NTerminalGroup PYRO_GLU_N_TERM_GLU = new NTerminalGroup("Pyro-glu (N-term E)", "pyroglu-");
public static final NTerminalGroup PYRO_GLU_N_TERM_GLN = new NTerminalGroup("Pyro-glu (N-term Q)", "pyroglu-");
static
{
UNMODIFIED_N_TERMINUS
.addAtoms(Element.HYDROGEN, 1)
.addKa(new IonizableGroup(1.0E-8, Charge.POSITIVE)) // pKa 8.0
.lock()
.register();
BOC_T_BUTYLOXYCARBONYL
.addAtoms(Element.CARBON, 5)
.addAtoms(Element.HYDROGEN, 9)
.addAtoms(Element.OXYGEN, 2)
.lock()
.register();
CBZ_BENZYLOXYCARBONLYL
.addAtoms(Element.CARBON, 8)
.addAtoms(Element.HYDROGEN, 7)
.addAtoms(Element.OXYGEN, 2)
.lock()
.register();
N_ACETYL
.addAtoms(Element.CARBON, 2)
.addAtoms(Element.HYDROGEN, 3)
.addAtoms(Element.OXYGEN, 1)
.lock()
.register();
N_CARBAMYL
.addAtoms(Element.CARBON, 1)
.addAtoms(Element.HYDROGEN, 2)
.addAtoms(Element.NITROGEN, 1)
.addAtoms(Element.OXYGEN, 1)
.lock()
.register();
N_FORMYL
.addAtoms(Element.CARBON, 1)
.addAtoms(Element.HYDROGEN, 1)
.addAtoms(Element.OXYGEN, 1)
.lock()
.register();
N_METHYL
.addAtoms(Element.CARBON, 1)
.addAtoms(Element.HYDROGEN, 3)
.lock()
.register();
N_MYRISTOYL
.addAtoms(Element.CARBON, 14)
.addAtoms(Element.HYDROGEN, 27)
.addAtoms(Element.OXYGEN, 1)
.lock()
.register();
PYRO_GLU_N_TERM_GLN
.addAtoms(Element.HYDROGEN, -2)
.addAtoms(Element.NITROGEN, -1)
.lock()
.register();
PYRO_GLU_N_TERM_GLU
.addAtoms(Element.HYDROGEN, -1)
.addAtoms(Element.OXYGEN, -1)
.lock()
.register();
}
//##########################################################################
// PRIVATE FIELDS
//##########################################################################
private String mShortName;
//##########################################################################
// CONSTRUCTORS
//##########################################################################
//--------------------------------------------------------------------------
public NTerminalGroup(String inName)
{
super();
setName(inName);
}
//--------------------------------------------------------------------------
private NTerminalGroup(String inName, String inShortName)
{
this(inName);
mShortName = inShortName;
}
//--------------------------------------------------------------------------
public NTerminalGroup(String inName, Map inElementalComposition)
{
super(inName, inElementalComposition);
}
//--------------------------------------------------------------------------
public NTerminalGroup(XMLNode inXML)
{
super(inXML);
if (! inXML.getTagName().equals(HfgBioXML.NTERM_TAG))
{
throw new RuntimeException("Cannot construct an " + this.getClass().getSimpleName() + " from a " + inXML.getTagName() + " tag!");
}
XMLNode sidechainKasTag = inXML.getOptionalSubtagByName(HfgBioXML.SIDECHAIN_KAS_TAG);
if (sidechainKasTag != null)
{
for (XMLNode subtag : sidechainKasTag.getXMLNodeSubtags())
{
addKa(new IonizableGroup(subtag));
}
}
mShortName = inXML.getAttributeValue(HfgBioXML.SHORT_NAME_ATT);
}
//##########################################################################
// PUBLIC METHODS
//##########################################################################
//--------------------------------------------------------------------------
public static NTerminalGroup[] values()
{
return sValues.toArray(new NTerminalGroup[sValues.size()]);
}
//--------------------------------------------------------------------------
/**
Returns the NTerminalGroup whose name matches the specified String.
@param inString the name for the NTerminalGroup to retrieve
@return the NTerminalGroup whose name matches the specified String
*/
public static NTerminalGroup valueOf(String inString)
{
NTerminalGroup value = null;
if (StringUtil.isSet(inString))
{
for (NTerminalGroup group : sValues)
{
if (group.name().equalsIgnoreCase(inString))
{
value = group;
break;
}
}
}
return value;
}
//--------------------------------------------------------------------------
/**
Puts the NTerminalGroup into the Set of unique NTerminalGroups returned by NTerminalGroup.values().
*/
public void register()
{
if (! isLocked())
{
throw new RuntimeException("Only locked NTerminalGroups can be added to the values list!");
}
sValues.add(this);
}
//--------------------------------------------------------------------------
@Override
public NTerminalGroup addAtoms(Element inElement, int inNum)
{
return (NTerminalGroup) super.addAtoms(inElement, inNum);
}
//--------------------------------------------------------------------------
@Override
public NTerminalGroup lock()
{
return (NTerminalGroup) super.lock();
}
//--------------------------------------------------------------------------
@Override
public NTerminalGroup addKa(IonizableGroup inValue)
{
return (NTerminalGroup) super.addKa(inValue);
}
//--------------------------------------------------------------------------
public String getShortName()
{
return mShortName;
}
//--------------------------------------------------------------------------
@Override
public XMLNode toXMLNode()
{
XMLNode node = super.toXMLNode();
node.setTagName(HfgBioXML.NTERM_TAG);
if (StringUtil.isSet(mShortName)) node.setAttribute(HfgBioXML.SHORT_NAME_ATT, mShortName);
return node;
}
}