Home Original page

HashSequenceDB (biojava-legacy 1.9.5 API)

  • java.lang.Object
    • org.biojava.utils.AbstractChangeable
      • org.biojava.bio.seq.db.AbstractSequenceDB
        • org.biojava.bio.seq.db.HashSequenceDB
  • All Implemented Interfaces:
    Serializable, SequenceDB, SequenceDBLite, Changeable

    public class HashSequenceDB
    extends AbstractSequenceDB
    implements SequenceDB, Serializable

    An implementation of SequenceDB that uses an underlying HashMap to store the sequence objects.

    Author:
    Matthew Pocock, Gerald Loeffler, Matias Pilpari (LinkedHashMap)
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from interface org.biojava.bio.seq.db.SequenceDBLite

        SEQUENCES
    • Constructor Summary

      Constructors 
      Constructor Description
      HashSequenceDB()

      Generate a HashSequenceDB object that will use byName to generate ids for sequences and have a null name.

      HashSequenceDB​(String name)

      Generate a HashSequenceDB object that will use byName to generate ids and will have the requested name.

      HashSequenceDB​(IDMaker idMaker)

      Generate a HashSequenceDB object that will use idMaker to generate ids for sequences and have a null name.

      HashSequenceDB​(IDMaker idMaker, String name)

      Generate a HashSequenceDB 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
      void addSequence​(String id, Sequence seq)

      Add a sequence under a particular id.

      void addSequence​(Sequence seq)

      Adds a sequence to the database.

      IDMaker getIDMaker()

      Retrieve the IDMaker associated with this database.

      String getName()

      Get the name of this sequence database.

      Sequence getSequence​(String id)

      Retrieve a single sequence by its id.

      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.

      SequenceIterator sequenceIterator()

      Returns a SequenceIterator over all sequences in the database.

      • Methods inherited from class org.biojava.bio.seq.db.AbstractSequenceDB

        filter
      • 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.biojava.utils.Changeable

        addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
      • Methods inherited from interface org.biojava.bio.seq.db.SequenceDB

        filter
    • Constructor Detail

      • HashSequenceDB

        public HashSequenceDB()

        Generate a HashSequenceDB object that will use byName to generate ids for sequences and have a null name.

      • HashSequenceDB

        public HashSequenceDB​(IDMaker idMaker)

        Generate a HashSequenceDB 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
      • HashSequenceDB

        public HashSequenceDB​(String name)

        Generate a HashSequenceDB object that will use byName to generate ids and will have the requested name.

        Parameters:
        name - the name for this database
      • HashSequenceDB

        public HashSequenceDB​(IDMaker idMaker,
                              String name)

        Generate a HashSequenceDB 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 sequence
        name - the name for this database
    • Method Detail

      • getName

        public String getName()

        Get the name of this sequence database.

        Specified by:
        getName in interface SequenceDBLite
        Returns:
        the name of the sequence database, which may be null.
      • getSequence

        public Sequence getSequence​(String id)
                             throws IllegalIDException

        Retrieve a single sequence by its id.

        Specified by:
        getSequence in interface SequenceDBLite
        Parameters:
        id - the id to retrieve by
        Returns:
        the Sequence with that id
        Throws:
        IllegalIDException - if the database doesn't know about the id
      • 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 interface SequenceDB
        Returns:
        a Set of ids - at the moment, strings
      • sequenceIterator

        public SequenceIterator sequenceIterator()

        Description copied from interface: SequenceDB

        Returns a SequenceIterator over all sequences in the database. The order of retrieval is undefined.

        Specified by:
        sequenceIterator in interface SequenceDB
        Overrides:
        sequenceIterator in class AbstractSequenceDB
        Returns:
        a SequenceIterator over all sequences
      • addSequence

        public void addSequence​(String id,
                                Sequence seq)
                         throws ChangeVetoException

        Add a sequence under a particular id.

        Parameters:
        id - the id to use
        seq - the Sequence to add
        Throws:
        ChangeVetoException - if this addition was vetoed
      • getIDMaker

        public IDMaker getIDMaker()

        Retrieve the IDMaker associated with this database.

        Returns:
        the current IDMaker object
      • addSequence

        public void addSequence​(Sequence seq)
                         throws ChangeVetoException

        Adds a sequence to the database.

        Specified by:
        addSequence in interface SequenceDBLite
        Overrides:
        addSequence in class AbstractSequenceDB
        Parameters:
        seq - the Sequence to add
        Throws:
        ChangeVetoException - if either the database does not allow sequences to be added or the modification was vetoed
      • removeSequence

        public void removeSequence​(String id)
                            throws BioException,
                                   ChangeVetoException

        Remove the sequence associated with an ID from the database.

        Specified by:
        removeSequence in interface SequenceDBLite
        Overrides:
        removeSequence in class AbstractSequenceDB
        Parameters:
        id - the ID of the sequence to remove
        Throws:
        IllegalIDException - if there is no sequence for the ID
        BioException - if something failed while removing the sequence for that ID
        ChangeVetoException - if either the database does not allow sequences to be removed or the modification was vetoed