001package org.biopax.paxtools.pattern.miner; 002 003import org.biopax.paxtools.model.BioPAXElement; 004import org.biopax.paxtools.pattern.Match; 005 006import java.io.IOException; 007import java.io.OutputStream; 008import java.util.List; 009import java.util.Map; 010 011/** 012 * Base class for SIF Miners. 013 * @author Ozgun Babur 014 */ 015public abstract class AbstractSIFMiner extends MinerAdapter implements SIFMiner 016{ 017 /** 018 * The binary interaction type that this class mines. 019 */ 020 SIFType type; 021 022 /** 023 * Constructor with interaction type. 024 * 025 * @param type SIF type 026 */ 027 public AbstractSIFMiner(SIFType type) 028 { 029 super(type.getTag(), type.getDescription()); 030 031 this.type = type; 032 } 033 034 /** 035 * Constructor with interaction type, supplementary name, supplementary description, and ubiquitous IDs. 036 * Supplementary name and description are sometimes needed, because there can be multiple 037 * miners for the same binary interaction type. In that case these supplementary data is 038 * augmented to the name and description of the interaction type. 039 * 040 * @param type SIF type 041 * @param supplName supplementary name 042 * @param supplDesc supplemantary description 043 */ 044 public AbstractSIFMiner(SIFType type, String supplName, String supplDesc) 045 { 046 super(type.getTag() + supplName, type.getDescription() + " " + supplDesc); 047 048 this.type = type; 049 } 050 051 /** 052 * Writes the result as "A used-for-production-of B", where A and B are small molecule names, 053 * and whitespace is tab. 054 * @param matches pattern search result 055 * @param out output stream 056 */ 057 @Override 058 public void writeResult(Map<BioPAXElement, List<Match>> matches, OutputStream out) 059 throws IOException 060 { 061 writeResultAsSIF(matches, out, type.isDirected(), getSourceLabel(), getTargetLabel()); 062 } 063 064 @Override 065 public SIFType getSIFType() 066 { 067 return type; 068 } 069 070 public void setType(SIFType type) 071 { 072 this.type = type; 073 } 074}