Package org.biojavax.bio.db
Class HashRichSequenceDB
- java.lang.Object
-
- org.biojava.utils.AbstractChangeable
-
- org.biojavax.bio.db.AbstractBioEntryDB
-
- org.biojavax.bio.db.AbstractRichSequenceDB
-
- org.biojavax.bio.db.HashRichSequenceDB
-
- All Implemented Interfaces:
SequenceDB
,SequenceDBLite
,Changeable
,BioEntryDB
,BioEntryDBLite
,RichSequenceDB
,RichSequenceDBLite
public class HashRichSequenceDB extends AbstractRichSequenceDB implements RichSequenceDB
An implementation of RichSequenceDB that uses an underlying HashMap to store the RichSequence objects.- Since:
- 1.5
- Author:
- Matthew Pocock, Gerald Loeffler, Richard Holland
-
-
Field Summary
-
Fields inherited from interface org.biojavax.bio.db.BioEntryDBLite
BIOENTRYS
-
Fields inherited from interface org.biojava.bio.seq.db.SequenceDBLite
SEQUENCES
-
-
Constructor Summary
Constructors Constructor Description HashRichSequenceDB()
Generate a HashRichSequenceDB object that will use byName to generate ids for sequences and have a null name.HashRichSequenceDB(String name)
Generate a HashRichSequenceDB object that will use byName to generate ids and will have the requested name.HashRichSequenceDB(IDMaker idMaker)
Generate a HashRichSequenceDB object that will use idMaker to generate ids for sequences and have a null name.HashRichSequenceDB(IDMaker idMaker, String name)
Generate a HashRichSequenceDB object that will use idMaker to generate ids for sequences and have the requested name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addRichSequence(String id, RichSequence seq)
void
addRichSequence(RichSequence seq)
Add a sequence.IDMaker
getIDMaker()
Retrieve the IDMaker associated with this database.String
getName()
Get the name of this sequence database.RichSequence
getRichSequence(String id)
Retrieve a single RichSequence by its id.RichSequenceDB
getRichSequences(Set ids)
Retrieve multiple RichSequence by its id.RichSequenceDB
getRichSequences(Set ids, RichSequenceDB db)
Retrieve multiple RichSequence into a specific sequence database.Set
ids()
Get an immutable set of all of the IDs in the database.void
removeSequence(String id)
Remove the sequence associated with an ID from the database.-
Methods inherited from class org.biojavax.bio.db.AbstractRichSequenceDB
addBioEntry, addSequence, filter, getBioEntry, getBioEntryIterator, getBioEntrys, getBioEntrys, getRichSequenceIterator, getSequence, removeBioEntry, removeRichSequence, sequenceIterator
-
Methods inherited from class org.biojava.utils.AbstractChangeable
addChangeListener, addChangeListener, generateChangeSupport, getChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.biojavax.bio.db.BioEntryDB
getBioEntryIterator
-
Methods inherited from interface org.biojavax.bio.db.BioEntryDBLite
addBioEntry, getBioEntry, getBioEntrys, getBioEntrys, removeBioEntry
-
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
Methods inherited from interface org.biojavax.bio.db.RichSequenceDB
getRichSequenceIterator, sequenceIterator
-
Methods inherited from interface org.biojavax.bio.db.RichSequenceDBLite
removeRichSequence
-
Methods inherited from interface org.biojava.bio.seq.db.SequenceDB
filter
-
Methods inherited from interface org.biojava.bio.seq.db.SequenceDBLite
addSequence, getSequence
-
-
-
-
Constructor Detail
-
HashRichSequenceDB
public HashRichSequenceDB()
Generate a HashRichSequenceDB object that will use byName to generate ids for sequences and have a null name.
-
HashRichSequenceDB
public HashRichSequenceDB(IDMaker idMaker)
Generate a HashRichSequenceDB object that will use idMaker to generate ids for sequences and have a null name.- Parameters:
idMaker
- the object that will work out the default id for a sequence
-
HashRichSequenceDB
public HashRichSequenceDB(String name)
Generate a HashRichSequenceDB object that will use byName to generate ids and will have the requested name.- Parameters:
name
- the name for this database
-
HashRichSequenceDB
public HashRichSequenceDB(IDMaker idMaker, String name)
Generate a HashRichSequenceDB object that will use idMaker to generate ids for sequences and have the requested name.- Parameters:
idMaker
- the object that will work out the default id for a sequencename
- the name for this database
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:SequenceDBLite
Get the name of this sequence database.- Specified by:
getName
in interfaceBioEntryDBLite
- Specified by:
getName
in interfaceSequenceDBLite
- Returns:
- the name of the sequence database, which may be null.
-
getIDMaker
public IDMaker getIDMaker()
Retrieve the IDMaker associated with this database.- Returns:
- the current IDMaker object
-
getRichSequence
public RichSequence getRichSequence(String id) throws BioException, IllegalIDException
Description copied from interface:RichSequenceDBLite
Retrieve a single RichSequence by its id.- Specified by:
getRichSequence
in interfaceRichSequenceDBLite
- Parameters:
id
- the id to retrieve by- Returns:
- the Sequence with that id
- Throws:
IllegalIDException
- if the database doesn't know about the idBioException
-
getRichSequences
public RichSequenceDB getRichSequences(Set ids) throws BioException, IllegalIDException
Description copied from interface:RichSequenceDBLite
Retrieve multiple RichSequence by its id.- Specified by:
getRichSequences
in interfaceRichSequenceDBLite
- Parameters:
ids
- a set of ids to retrieve by- Returns:
- the RichSequences with that id
- Throws:
IllegalIDException
- if the database doesn't know about the idBioException
-
getRichSequences
public RichSequenceDB getRichSequences(Set ids, RichSequenceDB db) throws BioException, IllegalIDException
Description copied from interface:RichSequenceDBLite
Retrieve multiple RichSequence into a specific sequence database. If that database is null, a new HashRichSequenceDB is used.- Specified by:
getRichSequences
in interfaceRichSequenceDBLite
- Parameters:
ids
- a set of ids to retrieve bydb
- a database to load the seqs into- Returns:
- the RichSequences with that id
- Throws:
IllegalIDException
- if the database doesn't know about the idBioException
-
ids
public Set ids()
Description copied from interface:SequenceDB
Get an immutable set of all of the IDs in the database. The ids are legal arguments to getSequence.- Specified by:
ids
in interfaceBioEntryDB
- Specified by:
ids
in interfaceSequenceDB
- Returns:
- a Set of ids - at the moment, strings
-
addRichSequence
public void addRichSequence(RichSequence seq) throws IllegalIDException, BioException, ChangeVetoException
Add a sequence.- Specified by:
addRichSequence
in interfaceRichSequenceDBLite
- Overrides:
addRichSequence
in classAbstractRichSequenceDB
- Parameters:
seq
- the RichSequence to add- Throws:
ChangeVetoException
- if this addition was vetoedIllegalIDException
- if a uniqe ID could not be generated for RichSequenceBioException
- if something goes wrong with adding the RichSequence
-
addRichSequence
protected void addRichSequence(String id, RichSequence seq) throws IllegalIDException, BioException, ChangeVetoException
-
removeSequence
public void removeSequence(String id) throws IllegalIDException, BioException, ChangeVetoException
Description copied from interface:SequenceDBLite
Remove the sequence associated with an ID from the database.- Specified by:
removeSequence
in interfaceSequenceDBLite
- Overrides:
removeSequence
in classAbstractRichSequenceDB
- Parameters:
id
- the ID of the sequence to remove- Throws:
IllegalIDException
- if there is no sequence for the IDBioException
- if something failed while removing the sequence for that IDChangeVetoException
- if either the database does not allow sequences to be removed or the modification was vetoed
-
-