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

de.julielab.geneexpbase.genemodel.OrthologyRecord Maven / Gradle / Ivy

package de.julielab.geneexpbase.genemodel;

import java.io.Serializable;

/**
 * This class models lines from the gene_orthologs file.
 *
 * @see ftp://ftp.ncbi.nih.gov/gene/DATA/
 */
public class OrthologyRecord implements Serializable {
    private final String taxId;
    private final String geneId;
    private final String otherTaxId;
    private final String otherGeneId;

    /**
     * 

* This constructor expects a line in the original gene_orthologs format. *

*

Used by {@link GeneOrthologs}.

* * @param geneOrthologyLine The orthology record. */ OrthologyRecord(String geneOrthologyLine) { if (geneOrthologyLine.startsWith("#")) throw new IllegalArgumentException("The line " + geneOrthologyLine + " is a comment and not an orthology record."); String[] split = geneOrthologyLine.split("\\t"); taxId = split[0].trim().intern(); geneId = split[1].trim().intern(); otherTaxId = split[3].trim().intern(); otherGeneId = split[4].trim().intern(); } @Override public String toString() { return "OrthologyRecord{" + "taxId='" + taxId + '\'' + ", geneId='" + geneId + '\'' + ", otherTaxId='" + otherTaxId + '\'' + ", otherGeneId='" + otherGeneId + '\'' + '}'; } public String getTaxId() { return taxId; } public String getGeneId() { return geneId; } public String getOtherTaxId() { return otherTaxId; } public String getOtherGeneId() { return otherGeneId; } public String getGeneIdNotEqualTo(String geneId) { boolean eqGeneId = geneId.equals(this.geneId); boolean eqOtherGeneId = geneId.equals(this.otherGeneId); if (eqGeneId && eqOtherGeneId) throw new IllegalArgumentException("The gene ID " + geneId + " is not a part of this record: " + this); if (eqGeneId) return otherGeneId; return this.geneId; } public String getGeneIdForTaxId(String taxId) { assert taxId != null : "The passed taxonomy ID is null."; if (taxId.equals(this.taxId)) return geneId; if (taxId.equals(otherTaxId)) return otherGeneId; throw new IllegalArgumentException("The taxonomy ID " + taxId + " is not part of this record: " + this); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy