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

com.hfg.bio.seq.alignment.blast.BLAST_DatabaseGroup Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.bio.seq.alignment.blast;


import java.util.ArrayList;
import java.util.List;

import com.hfg.bio.seq.BioSequenceType;
import com.hfg.util.StringUtil;
import com.hfg.util.collection.CollectionUtil;
import com.hfg.xml.XMLName;
import com.hfg.xml.XMLTag;

//==============================================================================
/**
 Container for a group of BLAST sequence databases.
 
@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 BLAST_DatabaseGroup { private String mName; private BioSequenceType mSeqType; private List mDatabases; protected static XMLName XML_NAME = new XMLName("BLAST_DatabaseGroup"); private static XMLName XML_NAME_ATT = new XMLName("name"); private static XMLName XML_SEQ_TYPE_ATT = new XMLName("seqType"); //########################################################################### // PUBLIC METHODS //########################################################################### //--------------------------------------------------------------------------- public BLAST_DatabaseGroup(String inName, BioSequenceType inType) { mName = inName; mSeqType = inType; } //--------------------------------------------------------------------------- public BLAST_DatabaseGroup(XMLTag inXMLTag) { inXMLTag.verifyTagName(XML_NAME); mName = inXMLTag.getAttributeValue(XML_NAME_ATT); String bioSequenceTypeString = inXMLTag.getAttributeValue(XML_SEQ_TYPE_ATT); if (! StringUtil.isSet(bioSequenceTypeString)) { throw new RuntimeException("No " + StringUtil.singleQuote(XML_SEQ_TYPE_ATT) + " specified for group " + StringUtil.singleQuote(mName) + "!"); } mSeqType = BioSequenceType.valueOf(bioSequenceTypeString); List dbTags = inXMLTag.getSubtagsByName(BLAST_Database.XML_NAME); if (CollectionUtil.hasValues(dbTags)) { for (XMLTag dbTag : dbTags) { addDatabase(new BLAST_Database(dbTag)); } } } //########################################################################### // PUBLIC METHODS //########################################################################### //--------------------------------------------------------------------------- public XMLTag toXMLTag() { XMLTag tag = new XMLTag(XML_NAME); tag.setAttribute(XML_NAME_ATT, name()); tag.setAttribute(XML_SEQ_TYPE_ATT, getSeqType()); if (CollectionUtil.hasValues(getDatabases())) { for (BLAST_Database db : getDatabases()) { tag.addSubtag(db.toXMLTag()); } } return tag; } //--------------------------------------------------------------------------- @Override public String toString() { return name(); } //--------------------------------------------------------------------------- public String name() { return mName; } //--------------------------------------------------------------------------- public BioSequenceType getSeqType() { return mSeqType; } //--------------------------------------------------------------------------- public void addDatabase(BLAST_Database inValue) { if (null == mDatabases) { mDatabases = new ArrayList<>(10); } mDatabases.add(inValue); } //--------------------------------------------------------------------------- public List getDatabases() { return mDatabases; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy