001 /*
002 * The contents of this file are subject to the Mozilla Public
003 * License Version 1.1 (the "License"); you may not use this file
004 * except in compliance with the License. You may obtain a copy of
005 * the License at http://www.mozilla.org/MPL/
006 *
007 * Software distributed under the License is distributed on an "AS
008 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
009 * implied. See the License for the specific language governing
010 * rights and limitations under the License.
011 *
012 * The Original Code is Knowtator.
013 *
014 * The Initial Developer of the Original Code is University of Colorado.
015 * Copyright (C) 2005 - 2008. All Rights Reserved.
016 *
017 * Knowtator was developed by the Center for Computational Pharmacology
018 * (http://compbio.uchcs.edu) at the University of Colorado Health
019 * Sciences Center School of Medicine with support from the National
020 * Library of Medicine.
021 *
022 * Current information about Knowtator can be obtained at
023 * http://knowtator.sourceforge.net/
024 *
025 * Contributor(s):
026 * Philip V. Ogren <philip@ogren.info> (Original Author)
027 */
028
029 package edu.uchsc.ccp.knowtator.textsource.generif;
030
031 import java.util.ArrayList;
032
033 import edu.stanford.smi.protege.model.Cls;
034 import edu.stanford.smi.protege.model.Instance;
035 import edu.stanford.smi.protege.model.KnowledgeBase;
036 import edu.uchsc.ccp.knowtator.textsource.filelines.FileLineTextSource;
037
038 public class GeneRIFTextSource extends FileLineTextSource {
039
040 public static final String CLS_NAME = "generifs text source";
041
042 public static final String ENTREZ_GENE_SLOT_NAME = "generif_entrez_gene";
043
044 public static final String PMID_SLOT_NAME = "generif_pmid";
045
046 int lineNumber;
047
048 String[] entrezIDs;
049
050 String pmid;
051
052 public GeneRIFTextSource(String id, String[] entrezIDs, String pmid, String text) {
053 this.name = id;
054 this.entrezIDs = entrezIDs;
055 this.pmid = pmid;
056 this.text = text;
057 this.protegeClsName = CLS_NAME;
058 }
059
060 public Instance createTextSourceInstance(KnowledgeBase knowledgeBase) {
061 Cls textSourceCls = knowledgeBase.getCls(getProtegeClsName());
062
063 Instance textSourceInstance = knowledgeBase.createInstance(getName(), textSourceCls, true);
064
065 ArrayList entrezGeneInstances = new ArrayList();
066
067 for (int i = 0; i < entrezIDs.length; i++) {
068
069 Instance entrezGeneInstance = knowledgeBase.getInstance(entrezIDs[i]);
070 entrezGeneInstances.add(entrezGeneInstance);
071 }
072
073 textSourceInstance.setOwnSlotValues(knowledgeBase.getSlot(ENTREZ_GENE_SLOT_NAME), entrezGeneInstances);
074 textSourceInstance.setOwnSlotValue(knowledgeBase.getSlot(PMID_SLOT_NAME), pmid);
075 return textSourceInstance;
076 }
077
078 public String[] getEntrezIDs() {
079 return this.entrezIDs;
080 }
081
082 }