001package com.hfg.bio.proteinproperty;
002
003
004import com.hfg.bio.HfgBioXML;
005import com.hfg.util.StringUtil;
006import com.hfg.xml.XMLTag;
007
008//------------------------------------------------------------------------------
009/**
010 Protein analysis modes.
011 <div>
012  @author J. Alex Taylor, hairyfatguy.com
013 </div>
014 */
015//------------------------------------------------------------------------------
016// com.hfg XML/HTML Coding Library
017//
018// This library is free software; you can redistribute it and/or
019// modify it under the terms of the GNU Lesser General Public
020// License as published by the Free Software Foundation; either
021// version 2.1 of the License, or (at your option) any later version.
022//
023// This library is distributed in the hope that it will be useful,
024// but WITHOUT ANY WARRANTY; without even the implied warranty of
025// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
026// Lesser General Public License for more details.
027//
028// You should have received a copy of the GNU Lesser General Public
029// License along with this library; if not, write to the Free Software
030// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
031//
032// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
033// jataylor@hairyfatguy.com
034//------------------------------------------------------------------------------
035
036public abstract class ProteinAnalysisMode
037{
038   private String mName;
039
040   public static final NativeAnalysisMode    NATIVE    = NativeAnalysisMode.getInstance();
041   public static final ReducedAnalysisMode   REDUCED   = new ReducedAnalysisMode();
042
043   //--------------------------------------------------------------------------
044   protected ProteinAnalysisMode(String inName)
045   {
046      mName = inName;
047   }
048
049
050   //---------------------------------------------------------------------------
051   public String name()
052   {
053      return mName;
054   }
055
056   //--------------------------------------------------------------------------
057   public XMLTag toXMLTag()
058   {
059      XMLTag tag = new XMLTag(HfgBioXML.PROTEIN_ANALYSIS_MODE_TAG);
060      tag.setAttribute("class", this.getClass().getName());
061
062      return tag;
063   }
064
065   //--------------------------------------------------------------------------
066   public static ProteinAnalysisMode instantiate(XMLTag inXMLNode)
067   {
068      String classname = inXMLNode.getAttributeValue(HfgBioXML.CLASS_ATT);
069      if (! StringUtil.isSet(classname))
070      {
071         throw new RuntimeException("No " + HfgBioXML.CLASS_ATT + " specified on sequence's XML tag!");
072      }
073
074      ProteinAnalysisMode value = null;
075      if (classname.equals(NATIVE.getClass().getName()))
076      {
077         value = NATIVE;
078      }
079      else
080      {
081         value = new ReducedAnalysisMode(inXMLNode);
082      }
083
084      return value;
085   }
086}