Skip to content
Snippets Groups Projects
Commit fb59e45f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

unused ExporterService removed

parent 6b3b3237
No related branches found
No related tags found
1 merge request!207Resolve "remove unused JSF code"
package lcsb.mapviewer.run;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.annotation.services.ModelAnnotator;
import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.persist.ApplicationContextLoader;
import lcsb.mapviewer.persist.DbUtils;
import lcsb.mapviewer.services.interfaces.IExporterService;
import lcsb.mapviewer.services.interfaces.IExporterService.ExporterParameters;
import lcsb.mapviewer.services.utils.data.ExportFileType;
/**
* This class prepare data for Bell format (further transformation is done by
* Marek).
*
* @author Piotr Gawron
*
*/
public class BellExport {
/**
* Default class logger.
*/
private static Logger logger = Logger.getLogger(BellExport.class.getName());
/**
* Object that performs different types of export transformation.
*/
@Autowired
private IExporterService exporter;
/**
* Object used to annotate the model.
*/
@Autowired
private ModelAnnotator modelAnnotator;
/**
* Object used to annotate the model.
*/
@Autowired
private DbUtils dbUtils;
/**
* Static main method used to run this stand alone code.
*
* @param args
* command line arguments
*/
public static void main(String[] args) {
ApplicationContextLoader.loadApplicationContext("consoleApplicationContext.xml");
BellExport main = new BellExport();
ApplicationContextLoader.injectDependencies(main);
main.run();
}
/**
* Default constructor.
*/
public BellExport() {
}
/**
* Method that export pd map into file that can be exported to bell (by
* Marek).
*
*/
private void run() {
CellDesignerXmlParser p = new CellDesignerXmlParser();
try {
String filename = PdMapAnnotations.getLastPdFilename();
String version = PdMapAnnotations.getLastPdVersion();
// filename = "testFiles/other_full/ASTHMAP18000X8000V1_38.xml";
// version = "1.1.38";
dbUtils.createSessionForCurrentThread();
Model model = p.createModel(new ConverterParams().filename(filename));
modelAnnotator.performAnnotations(model, new IProgressUpdater() {
@Override
public void setProgress(double progress) {
}
});
ExporterParameters params = new IExporterService.ExporterParameters().model(model).//
fileName("out/bell/" + version + "-reactions.txt").//
fileType(ExportFileType.TAB_SEPARATED).//
type(Species.class).//
moleculeEdges(false);
exporter.exportReactions(params);
params = new IExporterService.ExporterParameters().model(model).//
fileName("out/bell/" + version + "-species.txt").//
fileType(ExportFileType.TAB_SEPARATED).//
type(Species.class).//
// column(ExportColumn.FULL).//
moleculeEdges(false);
exporter.exportSpecies(params);
params = new IExporterService.ExporterParameters().model(model).//
fileName("out/bell/" + version + "-compartments.txt").//
fileType(ExportFileType.TAB_SEPARATED).//
type(Object.class); //
// column(ExportColumn.FULL);
exporter.exportCompartments(params);
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
dbUtils.closeSessionForCurrentThread();
}
}
/**
* @return the modelAnnotator
* @see #modelAnnotator
*/
public ModelAnnotator getModelAnnotator() {
return modelAnnotator;
}
/**
* @param modelAnnotator
* the modelAnnotator to set
* @see #modelAnnotator
*/
public void setModelAnnotator(ModelAnnotator modelAnnotator) {
this.modelAnnotator = modelAnnotator;
}
}
package lcsb.mapviewer.services.interfaces;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.services.utils.data.ExportColumn;
import lcsb.mapviewer.services.utils.data.ExportFileType;
import lcsb.mapviewer.services.view.PubmedAnnotatedElementsView;
/**
* Interface used for simple export of the {@link Model}.
*
* @author Piotr Gawron
*
*/
public interface IExporterService {
/**
* Class that contains parameters used for exporting data.
*
* @author Piotr Gawron
*
*/
class ExporterParameters {
/**
* File where the export data should be saved.
*/
private String fileName = null;
/**
* List of models from which data is exported.
*/
private List<Model> models = new ArrayList<Model>();
/**
* List of compartment names that should be included in export (empty list
* means that everything should be included).
*/
private List<String> included = new ArrayList<String>();
/**
* List of compartment names that should be excluded in export (empty list
* means that anything should be excluded).
*/
private List<String> excluded = new ArrayList<String>();
/**
* Type of file to which export should be performed.
*/
private ExportFileType fileType = null;
/**
* Elements that should be exported.
*/
private List<Class<?>> types = new ArrayList<Class<?>>();
/**
* Columns that should be included in the export data.
*/
private List<ExportColumn> columns = new ArrayList<ExportColumn>();
/**
* Miriam annotations that should be included in the export data.
*/
private List<MiriamType> miriamTypes = new ArrayList<MiriamType>();
/**
* List of compartment aliases that should be included in export (empty list
* means that everything should be included).
*/
private Set<Compartment> includedAliases = new HashSet<Compartment>();
/**
* List of compartment aliases that should be excluded in export (empty list
* means that anything should be excluded).
*/
private Set<Compartment> excludedAliases = new HashSet<Compartment>();
/**
* If false default complex name will be used for exporting complexes. If
* true then the name will be a concatenated string of all complex
* subspecies.
*/
private boolean complexElementsName = false;
/**
* Should the molecules be considered as edges. Might be usefull for <a
* href=
* "http://en.wikipedia.org/wiki/Protein%E2%80%93protein_interaction">PPI
* </a>.
*/
private boolean moleculeEdges = false;
/**
*
*/
public ExporterParameters() {
}
/**
* Sets {@link #fileName}.
*
* @param fileName
* new {@link #fileName}
* @return object with all parameters set
*/
public ExporterParameters fileName(String fileName) {
this.fileName = fileName;
return this;
}
/**
* Sets {@link #model}.
*
* @param model
* new {@link #model}
* @return object with all parameters set
*/
public ExporterParameters model(Model model) {
this.models = new ArrayList<Model>();
models.add(model);
for (Model m : model.getSubmodels()) {
models.add(m);
}
for (Model modelElement : models) {
includedAliases.clear();
for (String string : included) {
for (Compartment alias : modelElement.getCompartments()) {
if (alias.getName().equalsIgnoreCase(string)) {
includedAliases.add(alias);
}
}
}
excludedAliases.clear();
for (String string : excluded) {
for (Compartment alias : modelElement.getCompartments()) {
if (alias.getName().equalsIgnoreCase(string)) {
excludedAliases.add(alias);
}
}
}
}
return this;
}
/**
* Adds element to {@link #included}.
*
* @param included
* new element in {@link #included}
* @return object with all parameters set
*/
public ExporterParameters included(String included) {
this.included.add(included);
if (models.size() > 0) {
for (Model model : models) {
for (Compartment alias : model.getCompartments()) {
if (alias.getName().equalsIgnoreCase(included)) {
includedAliases.add(alias);
}
}
}
}
return this;
}
/**
* Adds elements to {@link #included}.
*
* @param included
* list of elements to add to {@link #included}
* @return object with all parameters set
*/
public ExporterParameters included(List<String> included) {
for (String string : included) {
included(string);
}
return this;
}
/**
* Adds element to {@link #excluded}.
*
* @param excluded
* new element in {@link #excluded}
* @return object with all parameters set
*/
public ExporterParameters excluded(String excluded) {
this.excluded.add(excluded);
if (models.size() > 0) {
for (Model model : models) {
for (Compartment alias : model.getCompartments()) {
if (alias.getName().equalsIgnoreCase(excluded)) {
excludedAliases.add(alias);
}
}
}
}
return this;
}
/**
* Adds element to {@link #excluded}.
*
* @param excluded
* new element in {@link #excluded}
* @return object with all parameters set
*/
public ExporterParameters excluded(Compartment excluded) {
this.excluded.add(excluded.getName());
excludedAliases.add(excluded);
return this;
}
/**
* Adds elements to {@link #excluded}.
*
* @param excluded
* list of elements to add to {@link #excluded}
* @return object with all parameters set
*/
public ExporterParameters excluded(List<String> excluded) {
for (String string : excluded) {
excluded(string);
}
return this;
}
/**
* Adds elements to {@link #excluded}.
*
* @param excluded
* list of elements to add to {@link #excluded}
* @return object with all parameters set
*/
public ExporterParameters excluded(Collection<Compartment> excluded) {
for (Compartment string : excluded) {
excluded(string);
}
return this;
}
/**
* Sets {@link #fileType}.
*
* @param fileType
* new {@link #fileType}
* @return object with all parameters set
*/
public ExporterParameters fileType(ExportFileType fileType) {
this.fileType = fileType;
return this;
}
/**
* Adds type to {@link #types}.
*
* @param type
* new element in {@link #types}
* @return object with all parameters set
*/
public ExporterParameters type(Class<?> type) {
this.types.add(type);
return this;
}
/**
* Adds types to {@link #types}.
*
* @param types
* new elements in {@link #types}
* @return object with all parameters set
*/
public ExporterParameters type(List<Class<?>> types) {
this.types.addAll(types);
return this;
}
/**
* Adds column to {@link #columns}.
*
* @param column
* new element in {@link #columns}
* @return object with all parameters set
*/
public ExporterParameters column(ExportColumn column) {
this.columns.add(column);
return this;
}
/**
* Adds columns to {@link #columns}.
*
* @param columns
* new elements in {@link #columns}
* @return object with all parameters set
*/
public ExporterParameters column(List<ExportColumn> columns) {
this.columns.addAll(columns);
return this;
}
/**
* Adds {@link MiriamType} to {@link #miriamTypes}.
*
* @param mt
* new element in {@link #miriamTypes}
* @return object with all parameters set
*/
public ExporterParameters miriamType(MiriamType mt) {
this.miriamTypes.add(mt);
return this;
}
/**
* Adds {@link MiriamType miriam types} to {@link #miriamTypes list}.
*
* @param mts
* new elements in {@link #miriamTypes}
* @return object with all parameters set
*/
public ExporterParameters miriamTypes(List<MiriamType> mts) {
this.miriamTypes.addAll(mts);
return this;
}
/**
* Adds columns to {@link #columns}.
*
* @param columns2
* new elements in {@link #columns}
* @return object with all parameters set
*/
public ExporterParameters column(ExportColumn[] columns2) {
for (ExportColumn exportColumn : columns2) {
column(exportColumn);
}
return this;
}
/**
* Sets {@link #moleculeEdges}.
*
* @param moleculeEdges
* new {@link #moleculeEdges}
* @return object with all parameters set
*/
public ExporterParameters moleculeEdges(boolean moleculeEdges) {
this.moleculeEdges = moleculeEdges;
return this;
}
/**
* Adds elements to {@link #included}.
*
* @param included
* list of elements to add to {@link #included}
* @return object with all parameters set
*/
public ExporterParameters included(String[] included) {
for (String string : included) {
included(string);
}
return this;
}
/**
* Adds elements to {@link #excluded}.
*
* @param excluded
* list of elements to add to {@link #excluded}
* @return object with all parameters set
*/
public ExporterParameters excluded(String[] excluded) {
for (String string : excluded) {
excluded(string);
}
return this;
}
/**
* Sets {@link #complexElementsName}.
*
* @param complexElementsName
* new {@link #complexElementsName}
* @return object with all parameters set
*/
public ExporterParameters complexElementsName(boolean complexElementsName) {
this.complexElementsName = complexElementsName;
return this;
}
/**
* @return the fileName
* @see #fileName
*/
public String getFileName() {
return fileName;
}
/**
* @return the model
* @see #model
*/
public List<Model> getModels() {
return models;
}
/**
* @return the included
* @see #included
*/
public List<String> getIncluded() {
return included;
}
/**
* @return the excluded
* @see #excluded
*/
public List<String> getExcluded() {
return excluded;
}
/**
* @return the fileType
* @see #fileType
*/
public ExportFileType getFileType() {
return fileType;
}
/**
* @return the types
* @see #types
*/
public List<Class<?>> getTypes() {
return types;
}
/**
* @return the columns
* @see #columns
*/
public List<ExportColumn> getColumns() {
return columns;
}
/**
* @return the includedAliases
* @see #includedAliases
*/
public Set<Compartment> getIncludedAliases() {
return includedAliases;
}
/**
* @return the excludedAliases
* @see #excludedAliases
*/
public Set<Compartment> getExcludedAliases() {
return excludedAliases;
}
/**
* @return the complexElementsName
* @see #complexElementsName
*/
public boolean isComplexElementsName() {
return complexElementsName;
}
/**
* @return the moleculeEdges
* @see #moleculeEdges
*/
public boolean isMoleculeEdges() {
return moleculeEdges;
}
/**
* @return the miriamTypes
* @see #miriamTypes
*/
public List<MiriamType> getMiriamTypes() {
return miriamTypes;
}
}
/**
* Export species using given parameters.
*
* @param parameters
* {@link ExporterParameters export parameters}
* @throws IOException
* thrown when there is a problem with accessing output file
*/
void exportSpecies(ExporterParameters parameters) throws IOException;
/**
* Returns string with all species exported using given parameters.
*
* @param parameters
* {@link ExporterParameters export parameters}
* @return String representing exported data
*/
String getExportSpeciesString(ExporterParameters parameters);
/**
* Returns string with all compartments exported using given parameters.
*
* @param parameters
* {@link ExporterParameters export parameters}
* @return String representing exported data
*/
String getExportCompartmentsString(ExporterParameters parameters);
/**
* Export compartments using given parameters.
*
* @param parameters
* {@link ExporterParameters export parameters}
* @throws IOException
* thrown when there is a problem with accessing output file
*/
void exportCompartments(ExporterParameters parameters) throws IOException;
/**
* Export reactions using given parameters.
*
* @param parameters
* {@link ExporterParameters export parameters}
* @throws IOException
* thrown when there is a problem with accessing output file
*/
void exportReactions(ExporterParameters parameters) throws IOException;
/**
* Returns string with all reactions exported using given parameters.
*
* @param parameters
* {@link ExporterParameters export parameters}
* @return String representing exported data
*/
String getExportInteractionString(ExporterParameters parameters);
/**
* Returns list of publciations for given model.
*
* @param model
* model for which list of publication will be returned
* @return list of publciations for given model
*/
List<PubmedAnnotatedElementsView> getPublicationModelSummary(Model model);
}
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
<bean id="DrugService" class="lcsb.mapviewer.services.search.db.drug.DrugService"/> <bean id="DrugService" class="lcsb.mapviewer.services.search.db.drug.DrugService"/>
<bean id="ExporterService" class="lcsb.mapviewer.services.impl.ExporterService"/>
<bean id="ExternalServicesService" class="lcsb.mapviewer.services.impl.ExternalServicesService"/> <bean id="ExternalServicesService" class="lcsb.mapviewer.services.impl.ExternalServicesService"/>
<bean id="LayoutService" class="lcsb.mapviewer.services.impl.LayoutService"/> <bean id="LayoutService" class="lcsb.mapviewer.services.impl.LayoutService"/>
......
...@@ -9,7 +9,6 @@ import org.junit.runners.Suite.SuiteClasses; ...@@ -9,7 +9,6 @@ import org.junit.runners.Suite.SuiteClasses;
ConfigurationServiceTest.class, // ConfigurationServiceTest.class, //
DataMiningServiceTest.class, // DataMiningServiceTest.class, //
DataMiningServiceTest2.class, // DataMiningServiceTest2.class, //
ExporterServiceTest.class, //
ExternalServicesServiceTest.class, // ExternalServicesServiceTest.class, //
LayoutServiceTest.class, // LayoutServiceTest.class, //
Md5PasswordEncoderTest.class, // Md5PasswordEncoderTest.class, //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment