001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.program.homologene;
023
024
025/**
026 * this entry contains data about the orthologue.
027 */
028public class SimpleOrthologue implements Orthologue
029{
030    private String title;
031    private Taxon taxon;
032    private String locusID;
033    private String homologeneID;
034    private String accession;
035
036    public SimpleOrthologue(
037        Taxon taxon,
038        String locusID,
039        String homologeneID,
040        String accession
041        )
042    {
043        setTaxon(taxon);
044        setLocusID(locusID);
045        setHomologeneID(homologeneID);
046        setAccession(accession);
047    }
048
049    /**
050     * this constructor does the Taxon lookup for you too
051     */
052    public SimpleOrthologue(
053        int taxonID,
054        String locusID,
055        String homologeneID,
056        String accession
057        )
058        throws IllegalArgumentException
059    {
060        // get corresponding Taxon
061        taxon = HomologeneTools.getTaxon(taxonID);
062        if (taxon == null) throw new IllegalArgumentException("Taxon with ID of " + taxonID + " does not exist.");
063
064        setTaxon(taxon);
065        setLocusID(locusID);
066        setHomologeneID(homologeneID);
067        setAccession(accession);
068    }
069
070    public String getTitle() { return title; }
071    public Taxon getTaxon() { return taxon; }
072    public int getTaxonID() { return taxon.getTaxonID(); }
073    public String getLocusID() { return locusID; }
074    public String getHomologeneID() { return homologeneID; }
075    public String getAccession() { return accession; }
076
077    public void setTitle(String title) { this.title = title; }
078    void setTaxon(Taxon taxon) { this.taxon = taxon; }
079    void setLocusID(String locusID) { this.locusID = locusID.trim(); }
080    void setHomologeneID(String homologeneID) { this.homologeneID = homologeneID.trim(); }
081    void setAccession(String accession) { this.accession = accession.trim(); }
082
083    public boolean equals(Object o)
084    {
085        if (!(o instanceof Orthologue)) return false;
086
087        // two Orthologues are only equal if they have identical data
088        Orthologue other = (Orthologue) o;
089
090        if (other.getTaxon() != taxon) return false;
091        if (other.getLocusID() != locusID) return false;
092        if (other.getHomologeneID() != homologeneID) return false;
093        if (other.getAccession() != accession) return false;
094
095        return true;
096    }
097}