Git Lab CI for docker build enabled! You can enable it using .gitlab-ci.yml in your project. Check file template at https://gitlab.bio.di.uminho.pt/snippets/5

enzymes load bug fixed

parent 99450fc8
......@@ -19,15 +19,11 @@ import pt.uminho.ceb.biosystems.merlin.utilities.io.FileUtils;
public class BiggMain {
public static void main(String[] args) throws Exception {
String workFolderID = "/workdir/";
// String workFolderID = "C:/Users/Asus/Desktop/"; //Docker (/workdir/)
//String workFolderID = "/workdir/";
String workFolderID = "C:/Users/Asus/Desktop/"; //Docker (/workdir/)
String paramsPath = workFolderID.concat("workerSubmissions/params.txt");
Logger logger = Logger.getLogger("BiggMain");
FileHandler fh;
......@@ -37,8 +33,6 @@ public class BiggMain {
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
logger.info("JAR STARTED SUCCESSFULLY");
FileUtils.extractZipFile(workFolderID+"Bigg_Files/Results.tgz", workFolderID+"Bigg_Files/");
List<String> listArgs = readParamsFile(paramsPath);
......@@ -47,8 +41,6 @@ public class BiggMain {
Properties properties = new Properties();
properties = validateProperties(properties, listArgs);
//BiggDataCenter.genesReactionsRuleFile(workFolderID);
String filePath = workFolderID.concat("workerSubmissions/protein.faa");
int option = Integer.parseInt(listArgs.get(0));
......@@ -156,8 +148,6 @@ public class BiggMain {
System.out.println(ex.getMessage());
}
return properties;
}
......
......@@ -31,7 +31,6 @@ public class Blast implements Observer{
private Map<String, Set<String>> results;
private String workFolderID;
private Integer queryFileSize = 0;
private Properties properties;
private String queryFilePath;
private AtomicInteger counter = new AtomicInteger(0);
......@@ -43,6 +42,14 @@ public class Blast implements Observer{
private Double bitScore;
private Double queryCovergage;
/**
*
* @param workFolderID
* @param queryFilePath
* @param properties
* @param option
* @param items
*/
public Blast(String workFolderID, String queryFilePath, Properties properties, int option, String items) {
try {
......@@ -93,7 +100,6 @@ public class Blast implements Observer{
ConcurrentHashMap<String, AbstractSequence<?>> sequences= new ConcurrentHashMap<String, AbstractSequence<?>>();
sequences.putAll(FastaReaderHelper.readFastaProteinSequence(new File(queryFilePath)));
this.counter = new AtomicInteger(1);
queryFileSize = sequences.size();
AtomicInteger queryFileSizeAtomic = new AtomicInteger(sequences.size());
logger.info("Blast process initialized!");
......@@ -123,10 +129,17 @@ public class Blast implements Observer{
return results;
}
/**
*
* @param option
* @param items
* @throws Exception
*/
private void setFastaFile(int option, String items) throws Exception {
//1 - all models
//2 - chosen models
//3 - chosen organisms
//4 - random models
switch(option) {
......@@ -163,14 +176,6 @@ public class Blast implements Observer{
return results;
}
/**
* @return the queryFileSize
*/
public Integer getQueryFileSize() {
return queryFileSize;
}
}
package pt.uminho.ceb.biosystems.bigg.metabolic.loader.blast;
public class DatabaseLoader {
}
......@@ -13,7 +13,9 @@ public class FileUtils {
private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
/**
* @param path
*
* @param defaultValues
* @param configurationFilePath
* @return
*/
public static Map<String, String> readPropertiesFile(boolean defaultValues, String configurationFilePath){
......
......@@ -7,10 +7,6 @@ import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.bigg.metabolic.loader.data.BiggUtils;
/**
* @author Davide
*
*/
public class Properties {
private Map<String, String> allProperties;
......@@ -44,19 +40,10 @@ public class Properties {
else {
logger.error("The default configurations can not be loaded.");
// logger.error("TranSyT found a fatal error, the program is closing...");
System.exit(0);
}
}
// public Properties(String bitScore, String queryCoverage, String evalue) {
// this.bitScore = Double.valueOf(bitScore);
//
// this.queryCoverage = Double.valueOf(queryCoverage);
//
// this.blastEvalue = Double.valueOf(evalue);
// }
/**
* @return the bitScore
......
package pt.uminho.ceb.biosystems.bigg.metabolic.loader.blast;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.lang.StringUtils;
import org.h2.tools.DeleteDbFiles;
import pt.uminho.ceb.biosystems.bigg.metabolic.loader.data.BiggDataCenter;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.CompartmentContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.ReactionContainer;
import pt.uminho.ceb.biosystems.merlin.core.datatypes.WorkspaceInitialData;
import pt.uminho.ceb.biosystems.merlin.gui.datatypes.WorkspaceAIB;
import pt.uminho.ceb.biosystems.merlin.gui.datatypes.WorkspaceDatabaseAIB;
import pt.uminho.ceb.biosystems.merlin.gui.utilities.MerlinUtils;
import pt.uminho.ceb.biosystems.merlin.gui.utilities.NewWorkspaceRequirements;
import pt.uminho.ceb.biosystems.merlin.gui.utilities.TimeLeftProgress;
import pt.uminho.ceb.biosystems.merlin.services.DatabaseServices;
import pt.uminho.ceb.biosystems.merlin.services.WorkspaceInitialDataServices;
import pt.uminho.ceb.biosystems.merlin.services.model.ModelCompartmentServices;
import pt.uminho.ceb.biosystems.merlin.services.model.ModelGenesServices;
import pt.uminho.ceb.biosystems.merlin.services.model.ModelMetabolitesServices;
import pt.uminho.ceb.biosystems.merlin.services.model.ModelProteinsServices;
import pt.uminho.ceb.biosystems.merlin.services.model.ModelReactionsServices;
import pt.uminho.ceb.biosystems.merlin.services.model.loaders.ModelDatabaseLoadingServices;
import pt.uminho.ceb.biosystems.merlin.utilities.io.FileUtils;
public class ProvideBiggReactionsToGenes {
......@@ -60,6 +39,14 @@ public class ProvideBiggReactionsToGenes {
private Map<String,Set<String>> queryGeneBiggGeneMap;
private String workspaceName = "updatedBiggDatabase";
/**
*
* @param workFolderID
* @param queryPathParameters
* @param properties
* @param option
* @param items
*/
public ProvideBiggReactionsToGenes(String workFolderID, String queryPathParameters, Properties properties, int option, String items) {
this.queryPath = queryPathParameters;
this.workFolderID = workFolderID;
......@@ -262,6 +249,11 @@ public class ProvideBiggReactionsToGenes {
return finalRulesParsed;
}
/**
*
* @param finalRulesParsed
* @throws IOException
*/
private void writeGPRsFile(Map<String,String> finalRulesParsed) throws IOException {
// TODO Auto-generated method stub
String filePath = workFolderID + "resultsWorker/" + "GPRsResults.txt";
......@@ -281,6 +273,12 @@ public class ProvideBiggReactionsToGenes {
writer.close();
}
/**
*
* @param queryGenes
* @param reaction
* @param finalRules
*/
private void distributionAlgorithmOr(Set<String> queryGenes, String reaction, Map<String,Set<String>> finalRules) {
Set<String> queryGenesRule = finalRules.get(reaction);
......@@ -294,6 +292,11 @@ public class ProvideBiggReactionsToGenes {
finalRules.put(reaction, queryGenesRule);
}
/**
*
* @param gene
* @return
*/
private Set<String> validateGeneInBlastResultsOr(String gene) {
Set<String> listQueryGenes = new HashSet<String>();
......@@ -305,6 +308,12 @@ public class ProvideBiggReactionsToGenes {
return listQueryGenes;
}
/**
*
* @param queryGenes
* @param reaction
* @param finalRules
*/
private void distributionAlgorithmAnd(Set<String> queryGenes, String reaction, Map<String,Set<String>> finalRules) {
......@@ -329,6 +338,11 @@ public class ProvideBiggReactionsToGenes {
finalRules.put(reaction, queryGenesRule);
}
/**
*
* @param genes
* @return
*/
private Set<String> validateGeneInBlastResultsAnd(List<String> genes) {
Set<String> listQueryGenes = new HashSet<String>();
......
......@@ -9,10 +9,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.CompartmentContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.GeneContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.MetaboliteContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.ProteinContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.ReactionContainer;
......@@ -25,27 +23,22 @@ public class BiggDataLoader {
public static AtomicBoolean cancel = new AtomicBoolean(false);
private static HashMap<String,List<String>> metabolitesAliases = new HashMap<String,List<String>>();
private static String currentModel="";
private static List<String> allEnzymes;
private static HashMap<String,String> allEnzymesNames;
public static void loadData(String model, String databaseName) throws Exception {
currentModel = model;
UpdateBiggFiles dataCenter = new UpdateBiggFiles(model);
WorkspaceInitialData databaseInitialData = null;
WorkspaceData data = new WorkspaceData();
if(data.getResultGenes()!=null && data.getResultGenes().size()>0)
databaseInitialData = WorkspaceInitialDataServices.retrieveAnnotationData(databaseName);
else
databaseInitialData = WorkspaceInitialDataServices.retrieveAllData(databaseName);
databaseInitialData = WorkspaceInitialDataServices.retrieveAllData(databaseName);
data.getResultCompartments().addAll((compartmentsTransformer(dataCenter.getModelMetabolites())));
data.setResultMetabolites(metabolitesTransformer(dataCenter.getModelMetabolites()));
data.setResultEnzymes(enzymesTransformer(dataCenter.getModelReactions()));
data.setResultReactions(reactionsTransformer(dataCenter.getModelReactions()));
int numberOfProcesses = Runtime.getRuntime().availableProcessors();
List<Thread> threads = new ArrayList<Thread>();
......@@ -53,62 +46,34 @@ public class BiggDataLoader {
databaseInitialData.setMetabolitesIdentifier(new ConcurrentHashMap<String,Integer>());
numberOfProcesses = Runtime.getRuntime().availableProcessors();///2;
numberOfProcesses = Runtime.getRuntime().availableProcessors();
threads = new ArrayList<Thread>();
//loading normal statments (remove after setting all loaders to prepared statements
long startTime = System.currentTimeMillis();
//loading prepared statements
AtomicInteger dataSize = new AtomicInteger(1);
for(int i=0; i<numberOfProcesses; i++) {
Runnable loadBiggData = new BiggLoadMetabolicData(databaseName, data, databaseInitialData, cancel, dataSize);
Runnable loadBiggData = new BiggLoadMetabolicData(databaseName, data, databaseInitialData, cancel);
runnables.add(loadBiggData);
Thread thread = new Thread(loadBiggData);
threads.add(thread);
thread.start();
}
for(Thread thread :threads)
thread.join();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
numberOfProcesses = Runtime.getRuntime().availableProcessors();///2;
threads = new ArrayList<Thread>();
//loading normal statments (remove after setting all loaders to prepared statements
// for(int i=0; i<numberOfProcesses; i++) {
//
// Runnable loadMetabolicData = new LoadMetabolicData(databaseName, data, databaseInitialData, cancel, dataSize);
// runnables.add(loadMetabolicData);
// Thread thread = new Thread(loadMetabolicData);
// threads.add(thread);
// thread.start();
//
// }
for(Thread thread :threads)
thread.join();
long endTime2 = System.currentTimeMillis();
long startTime1 = System.currentTimeMillis();
long endTime1 = System.currentTimeMillis();
long endTime = System.currentTimeMillis();
System.out.println("Total elapsed time in execution of method Load_kegg is :"+ String.format("%d min, %d sec",
System.out.println("Total elapsed time in execution of method Load Bigg data is :"+ String.format("%d min, %d sec",
TimeUnit.MILLISECONDS.toMinutes(endTime2-startTime),TimeUnit.MILLISECONDS.toSeconds(endTime2-startTime) -TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(endTime2-startTime))));
System.out.println("Total elapsed time in execution of method build view is :"+ String.format("%d min, %d sec",
......@@ -117,16 +82,8 @@ public class BiggDataLoader {
System.out.println("Total elapsed time in execution of method TOTAL is :"+ String.format("%d min, %d sec",
TimeUnit.MILLISECONDS.toMinutes(endTime-startTime),TimeUnit.MILLISECONDS.toSeconds(endTime-startTime) -TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(endTime-startTime))));
// if(error)
// return false;
// else
// return true;
}
public void setCancel() {
cancel.set(true);
}
......@@ -201,8 +158,6 @@ public class BiggDataLoader {
private static ConcurrentLinkedQueue<MetaboliteContainer> metabolitesAliasesTester(ConcurrentLinkedQueue<MetaboliteContainer> queue) {
for(MetaboliteContainer metabolite : queue) {
for(MetaboliteContainer existant : queue) {
......@@ -211,8 +166,6 @@ public class BiggDataLoader {
existant.getFormula().equals(metabolite.getFormula()) &&
existant.getName() != "" && existant.getFormula() != "" &&
!existant.getExternalIdentifier().equals(metabolite.getExternalIdentifier())){
if(metabolite.getNames()!=null) {
......@@ -244,20 +197,14 @@ public class BiggDataLoader {
List<String> queueHelper = new ArrayList<String>();
HashMap<String,List<String>> hashMapReactions = new HashMap<String,List<String>>();
HashMap<String,String> enzymesNames = new HashMap<String,String>();
allEnzymesNames = new HashMap<String,String>();
String response = BiggUtils.fetchKegg(0, "http://rest.kegg.jp/", "list", "enzyme");
allEnzymes = Arrays.asList(response.split("\n"));
for(String enzyme : allEnzymes) {
if(enzyme.split("\t").length > 1) {
String ec = enzyme.split("\t")[0].substring(3);
String names = enzyme.split("\t")[1];
enzymesNames.put(ec, names);
}
if(enzyme.split("\\s+").length > 1) {
String ec = enzyme.split("\\s+")[0].substring(3);
String names = enzyme.split("\\s+")[1];
enzymesNames.put(ec, names);
allEnzymesNames.put(ec, names);
}
}
......@@ -292,20 +239,20 @@ public class BiggDataLoader {
}
}
boolean hasName = true; //used to check if the enzyme is retrieved from Kegg and has names. 1.1 or 1.1.1 were being inserted
for(Entry<String,List<String>> entry : hashMapReactions.entrySet()) {
boolean hasName = true;
ProteinContainer container = new ProteinContainer(entry.getKey());
//container.setEcnumber(entry.getKey());
container.setReactionsExternalIdentifiers(entry.getValue());
String name = "";
List<String> names = new ArrayList<String>();
if(enzymesNames.containsKey(entry.getKey())) {
if(allEnzymesNames.containsKey(entry.getKey())) {
String result = enzymesNames.get(entry.getKey());
String result = allEnzymesNames.get(entry.getKey());
String[] splittedNames = result.split(";");
List<String> splittedNamesList = Arrays.asList(splittedNames);
......@@ -323,8 +270,6 @@ public class BiggDataLoader {
}
else
hasName = false;
if(hasName)
queue.add(container);
......@@ -346,10 +291,8 @@ public class BiggDataLoader {
ReactionContainer container = new ReactionContainer(reactionResult.getExportedReactionId());
container.setSource(SourceType.BiGG);
//DbLinks
List<String> dbLinks = new ArrayList<String>();
List<ProteinContainer> proteins = new ArrayList<ProteinContainer>();
......@@ -364,18 +307,13 @@ public class BiggDataLoader {
for(DbLink link : dbLinksList) {
if(allEnzymes.contains(link.getId())) {
if(allEnzymesNames.containsKey(link.getId())) {
ProteinContainer protein = new ProteinContainer(link.getId());
//protein.setEcnumber(link.getId());
proteins.add(protein);
}
}
}
List<DbLink> dbLinksList = db.getValue();
for(DbLink link : dbLinksList) {
......@@ -477,7 +415,6 @@ public class BiggDataLoader {
for(BiggMetabolites biggMetabolite : reaction.getMetabolites()) {
String biggMet = biggMetabolite.getBiggId()+"_"+biggMetabolite.getCompartmentBiggId();
String[] stoich = new String[] {biggMetabolite.getStoichiometry().toString()};
for(String reac : reactantsFinal) {
if(biggMet.equals(reac)) {
......@@ -514,10 +451,7 @@ public class BiggDataLoader {
prodStoich.add(newMet);
}
}
}
}
container.setReactantsStoichiometry(reacStoich);
......@@ -536,7 +470,6 @@ public class BiggDataLoader {
container.setEquation(equation);
}
}
queue.add(container);
......@@ -550,8 +483,7 @@ public class BiggDataLoader {
private static ConcurrentLinkedQueue<ReactionContainer> reactionsAliasesTester(ConcurrentLinkedQueue<ReactionContainer> queue) {
for(ReactionContainer reaction : queue) {
for(ReactionContainer existant : queue) {
......@@ -592,9 +524,6 @@ public class BiggDataLoader {
skip = true;
break;
}
}
}
......
......@@ -5,195 +5,78 @@ import java.rmi.RemoteException;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.hibernate.service.spi.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.CompartmentContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.GeneContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.MetaboliteContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.ModuleContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.PathwaysHierarchyContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.ProteinContainer;
import pt.uminho.ceb.biosystems.merlin.core.containers.model.ReactionContainer;
import pt.uminho.ceb.biosystems.merlin.core.datatypes.WorkspaceData;
import pt.uminho.ceb.biosystems.merlin.core.datatypes.WorkspaceInitialData;
import pt.uminho.ceb.biosystems.merlin.services.model.ModelGenesServices;
import pt.uminho.ceb.biosystems.merlin.services.model.loaders.ModelDataLoader;
import pt.uminho.ceb.biosystems.merlin.utilities.datastructures.list.ListUtilities;
/**
* @author ODias
*
*/
public class BiggLoadMetabolicData implements Runnable{
private final static int LIST_SIZE = 1000;
private ConcurrentLinkedQueue<MetaboliteContainer> resultMetabolites;
private ConcurrentLinkedQueue<ProteinContainer> resultEnzymes;
private ConcurrentLinkedQueue<ReactionContainer> resultReactions;
private ConcurrentLinkedQueue<GeneContainer> resultGenes;
private ConcurrentLinkedQueue<ModuleContainer> resultModules;
private ConcurrentLinkedQueue<String[]> resultPathways;
private ConcurrentLinkedQueue<PathwaysHierarchyContainer> keggPathwaysHierarchy;
private ConcurrentLinkedQueue<String> enzymesPathwayList,orthologueEntities;
private BiggModelDataLoader metabolicDataLoader;
private ConcurrentLinkedQueue<Integer> reactionsPathwayList, metabolitesPathwayList, modulesPathwayList;
private ConcurrentHashMap<String,Integer> pathways_id;
private AtomicBoolean cancel;
// private long startTime;
private AtomicInteger dataSize;
// private AtomicInteger datum;
private boolean error, loadAll;
private AtomicBoolean addMetPathDataSize, addModPathDataSize, addReacPathDataSize, addEnzPathDataSize;
private String databaseName;
private ConcurrentLinkedQueue<String> compoundsWithBiologicalRoles;
private boolean importFromSBML;
private boolean error;
private ConcurrentLinkedQueue<CompartmentContainer> resultCompartments;
final static Logger logger = LoggerFactory.getLogger(BiggLoadMetabolicData.class);
/**
*
* Claudia
*
* @param databaseName
* @param workspaceMetabolicData
* @param databaseInitialData
* @param cancel
* @param dataSize
* @param b
* @param a
* @throws Exception
*/
public BiggLoadMetabolicData(String databaseName, WorkspaceData workspaceMetabolicData, WorkspaceInitialData databaseInitialData,
AtomicBoolean cancel, AtomicInteger dataSize) throws Exception {
AtomicBoolean cancel) throws Exception {
this.cancel = cancel;
this.dataSize = dataSize;
this.setResultMetabolites(workspaceMetabolicData.getResultMetabolites());
this.setResultReactions(workspaceMetabolicData.getResultReactions());
this.setResultCompartments(workspaceMetabolicData.getResultCompartments());
this.setKeggPathwaysHierarchy(workspaceMetabolicData.getResultPathwaysHierarchy());
this.setResultEnzymes(workspaceMetabolicData.getResultEnzymes());
this.setResultGenes(workspaceMetabolicData.getResultGenes());
this.compoundsWithBiologicalRoles = new ConcurrentLinkedQueue<String>();
this.metabolicDataLoader = new BiggModelDataLoader(databaseInitialData, compoundsWithBiologicalRoles, false, databaseName);
this.metabolicDataLoader = new BiggModelDataLoader(databaseInitialData, databaseName);
this.setError(false);
this.addMetPathDataSize = new AtomicBoolean(false);
this.addEnzPathDataSize = new AtomicBoolean(false);
this.addModPathDataSize = new AtomicBoolean(false);
this.addReacPathDataSize = new AtomicBoolean(false);
this.loadAll = false;
this.databaseName = databaseName;
}
@Override
public void run() {
// while(true) {
try {
if(!this.cancel.get()) {
logger.info("Loading Compartments...");
this.loadCompartments();
logger.info("Loading Pathways...");
this.loadPathways();
logger.info("Loading Enzymes...");
this.loadEnzymes();
logger.info("Loading Compounds...");
this.loadCompounds();
logger.info("Loading Genes...");
this.loadGenes();
logger.info("Loading Modules...");
this.loadModules();
logger.info("Loading Reactions...");
this.loadReactions();
if(loadAll) {
this.metabolicDataLoader.getDatabaseInitialData().setPathwaysIdentifier(this.getPathways_id());
if(this.addModPathDataSize.get()) {
this.dataSize = new AtomicInteger(this.dataSize.get() + this.modulesPathwayList.size());
this.addModPathDataSize.set(false);
}
this.loadModulesPathwayList();
if(this.addReacPathDataSize.get()) {
this.dataSize = new AtomicInteger(this.dataSize.get() + this.reactionsPathwayList.size());
this.addReacPathDataSize.set(false);
}
this.loadReactionsPathwayList();
if(this.addEnzPathDataSize.get()) {
this.dataSize = new AtomicInteger(this.dataSize.get() + this.enzymesPathwayList.size());
this.addEnzPathDataSize.set(false);
}
this.loadEnzymesPathwayList();
if(this.addMetPathDataSize.get()) {
this.dataSize = new AtomicInteger(this.dataSize.get() + this.metabolitesPathwayList.size());
this.addMetPathDataSize.set(false);
}
this.loadMetabolitePathwayList();
}
}
}
catch (RemoteException e) {e.printStackTrace(); this.setError(true);}
catch (Exception e) {e.printStackTrace(); this.setError(true);}
// }
}
/**
* @throws Exception
* @throws ServiceException
*/
public void loadGenes() throws Exception{
if(this.resultGenes!=null) {
if(this.importFromSBML){
ConcurrentHashMap<String, Integer> genesSeqIDs = new ConcurrentHashMap<>(ModelGenesServices.getGeneIDsByQuery(this.databaseName));
this.metabolicDataLoader.getDatabaseInitialData().getGenesIdentifier().putAll(genesSeqIDs);
}
while(!this.resultGenes.isEmpty()) {
GeneContainer geneList;
if((geneList = this.resultGenes.poll()) != null) {
this.metabolicDataLoader.loadBiggGene(geneList);
//this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Genes");
}
}
}
}
//////////////////
/**
* @throws SQLException
*/
......@@ -207,14 +90,11 @@ public class BiggLoadMetabolicData implements Runnable{
if((compartment = this.resultCompartments.poll()) != null) {
this.metabolicDataLoader.loadCompartment(compartment);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Genes");
}
}
}
}
/////////////////////////////
/**
* @throws Exception
......@@ -226,37 +106,15 @@ public class BiggLoadMetabolicData implements Runnable{
while(!this.resultMetabolites.isEmpty() && !this.cancel.get()) {
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Compounds");
@SuppressWarnings("unchecked")
ConcurrentLinkedQueue<MetaboliteContainer> containers = (ConcurrentLinkedQueue<MetaboliteContainer>) ListUtilities.getConcurrentList(this.resultMetabolites, LIST_SIZE);
this.metabolicDataLoader.loadBiggMetabolites(containers);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Compounds");
}
}
}
/**
* @throws RemoteException
* @throws SQLException
* @throws ServiceException
*/
// public void loadCompounds(Statement stmt) throws RemoteException, SQLException{
//
// if(this.resultMetabolites!=null) {
//
// while(!this.resultMetabolites.isEmpty() && !this.cancel.get()) {
//
// MetaboliteContainer metaboliteList;
// if((metaboliteList = this.resultMetabolites.poll()) != null) {
//
// this.keggLoader.loadMetabolite(metaboliteList, stmt);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize, "Loading Compounds");
// }
// }
// }
// }
/**
* @throws Exception
* @throws IOException
......@@ -268,26 +126,11 @@ public class BiggLoadMetabolicData implements Runnable{
while(!this.resultEnzymes.isEmpty() && !this.cancel.get()) {
// @SuppressWarnings("unchecked")
// ConcurrentLinkedQueue<ProteinContainer> containers = (ConcurrentLinkedQueue<ProteinContainer>) ListUtilities.getConcurrentList(this.resultEnzymes, LIST_SIZE);
// ProteinContainer enzymesList;
// if((enzymesList = this.resultEnzymes.poll()) != null) {
// for(ProteinContainer container : this.resultEnzymes) {
// this.metabolicDataLoader.loadBiggProtein(container);
// }
ProteinContainer enzyme;
if((enzyme = this.resultEnzymes.poll()) != null) {
this.metabolicDataLoader.loadBiggProtein(enzyme);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Genes");
}
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Enzymes");
// }
}
}
}
......@@ -302,7 +145,7 @@ public class BiggLoadMetabolicData implements Runnable{
while(!this.resultReactions.isEmpty() && !this.cancel.get()) {
ReactionContainer reactionContainer;// = this.resultReactions.poll();
ReactionContainer reactionContainer;
if((reactionContainer = this.resultReactions.poll()) != null) {
......@@ -320,9 +163,6 @@ public class BiggLoadMetabolicData implements Runnable{
String reactionIdentifier = reactionContainer.getExternalIdentifier();
String reactionEquation = reactionContainer.getEquation();
// System.out.println(reactionIdentifier);
// System.out.println(reactionEquation);
String message = "Reaction ".concat(reactionIdentifier).concat(" has the same products and metabolites: ")
.concat(reactionEquation).concat("\n reaction will be ignored!");
logger.warn(message);
......@@ -331,141 +171,11 @@ public class BiggLoadMetabolicData implements Runnable{
this.metabolicDataLoader.loadBiggReaction(reactionContainer);
}
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Reactions");
}
}
}
}
/**
* @throws RemoteException
* @throws SQLException
* @throws ServiceException
*/
public void loadModules() throws Exception{
if(this.resultModules!=null) {
while(!this.resultModules.isEmpty() && !this.cancel.get()) {
ModuleContainer moduleList;
if((moduleList =this.resultModules.poll()) != null) {
this.metabolicDataLoader.loadModule(moduleList);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Modules");
}
}
}
}
/**
* @throws RemoteException
* @throws SQLException
* @throws ServiceException
*/
public void loadPathways() throws Exception{
if(this.getKeggPathwaysHierarchy()!=null) {
while(!this.getKeggPathwaysHierarchy().isEmpty() && !this.cancel.get()) {
PathwaysHierarchyContainer pathwayContainer;
if((pathwayContainer = this.getKeggPathwaysHierarchy().poll()) != null) {
this.metabolicDataLoader.loadPathways(pathwayContainer);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Pathways");
}
}
}
}
/**
* @throws RemoteException
* @throws SQLException
* @throws ServiceException
*/
public void loadReactionsPathwayList() throws Exception{
if(this.getReactionsPathwayList() != null) {
while(!this.getReactionsPathwayList().isEmpty() && !this.cancel.get()) {
Integer reactionPathList;
if((reactionPathList = this.getReactionsPathwayList().poll()) != null) {
this.metabolicDataLoader.load_ReactionsPathway(reactionPathList);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Reactions Pathways");
}
}
}
}
/**
* @throws RemoteException
* @throws SQLException
* @throws ServiceException
*/
public void loadEnzymesPathwayList() throws Exception{
if(this.getEnzymesPathwayList()!=null) {
while(!this.getEnzymesPathwayList().isEmpty() && !this.cancel.get()) {
String enzymesPathwayList;
if((enzymesPathwayList = this.getEnzymesPathwayList().poll()) != null) {
this.metabolicDataLoader.load_EnzymesPathway(enzymesPathwayList);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Enzymes Pathways");
}
}
}
}
/**
* @throws RemoteException
* @throws SQLException
* @throws ServiceException
*/
public void loadModulesPathwayList() throws Exception{
if(this.getModulesPathwayList()!=null) {
while(!this.getModulesPathwayList().isEmpty() && !this.cancel.get()) {
Integer modulePathList;
if((modulePathList = this.getModulesPathwayList().poll()) != null) {
this.metabolicDataLoader.load_ModulePathway(modulePathList);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Modules Pathways");
}
}
}
}
/**
* @throws RemoteException
* @throws SQLException
* @throws ServiceException
*/
public void loadMetabolitePathwayList() throws Exception{
if(this.getMetabolitesPathwayList()!=null) {
while(!this.getMetabolitesPathwayList().isEmpty() && !this.cancel.get()) {
Integer metaPathList;
if((metaPathList = this.getMetabolitesPathwayList().poll()) != null) {
this.metabolicDataLoader.load_MetabolitePathway(metaPathList);
// this.progress.setTime((GregorianCalendar.getInstance().getTimeInMillis()-this.startTime), this.datum.incrementAndGet(), this.dataSize.get(), "Loading Metabolites Pathways");
}
}
}
}
/**
* @param resultReactions the resultReactions to set
*/
......@@ -482,60 +192,6 @@ public class BiggLoadMetabolicData implements Runnable{
return resultReactions;
}
/**
* @param resultPathways the resultPathways to set
*/
public void setResultPathways(ConcurrentLinkedQueue<String[]> resultPathways) {
this.resultPathways = resultPathways;
}
/**
* @return the resultPathways
*/
public ConcurrentLinkedQueue<String[]> getResultPathways() {
return resultPathways;
}
/**
* @param keggPathwaysHierarchy the kegg_Pathways_Hierarchy to set
*/
public void setKeggPathwaysHierarchy(ConcurrentLinkedQueue<PathwaysHierarchyContainer> keggPathwaysHierarchy) {
this.keggPathwaysHierarchy = keggPathwaysHierarchy;
}
/**
* @return the kegg_Pathways_Hierarchy
*/
public ConcurrentLinkedQueue<PathwaysHierarchyContainer> getKeggPathwaysHierarchy() {
return keggPathwaysHierarchy;
}
/**
* @param orthologueEntities the orthologueEntities to set
*/
public void setOrthologueEntities(ConcurrentLinkedQueue<String> orthologueEntities) {
this.orthologueEntities = orthologueEntities;
}
/**
* @return the orthologueEntities
*/
public ConcurrentLinkedQueue<String> getOrthologueEntities() {
return orthologueEntities;
}
/**
* @return the resultMetabolites
*/
......@@ -565,34 +221,6 @@ public class BiggLoadMetabolicData implements Runnable{
this.resultEnzymes = resultEnzymes;
}
/**
* @return the resultGenes
*/
public ConcurrentLinkedQueue<GeneContainer> getResultGenes() {
return resultGenes;
}
/**
* @param resultGenes the resultGenes to set
*/
public void setResultGenes(ConcurrentLinkedQueue<GeneContainer> resultGenes) {
this.resultGenes = resultGenes;
}
/**
* @return the resultModules
*/
public ConcurrentLinkedQueue<ModuleContainer> getResultModules() {
return resultModules;
}
/**
* @param resultModules the resultModules to set
*/
public void setResultModules(ConcurrentLinkedQueue<ModuleContainer> resultModules) {
this.resultModules = resultModules;
}
/**
* @return the resultCompartments
*/
......@@ -607,76 +235,6 @@ public class BiggLoadMetabolicData implements Runnable{
this.resultCompartments = resultCompartments;
}
/**
* @param reactionsPathwayList the reactionsPathwayList to set
*/
public void setReactionsPathwayList(ConcurrentLinkedQueue<Integer> reactionsPathwayList) {
this.reactionsPathwayList = reactionsPathwayList;
}
/**
* @return the reactionsPathwayList
*/
public ConcurrentLinkedQueue<Integer> getReactionsPathwayList() {
return this.reactionsPathwayList;
}
/**
* @param enzymesPathwayList the enzymesPathwayList to set
*/
public void setEnzymesPathwayList(ConcurrentLinkedQueue<String> enzymesPathwayList) {
this.enzymesPathwayList = enzymesPathwayList;
}
/**
* @return the enzymesPathwayList
*/
public ConcurrentLinkedQueue<String> getEnzymesPathwayList() {
return this.enzymesPathwayList;
}
/**
* @param metabolitesPathwayList the metabolitesPathwayList to set
*/
public void setMetabolitesPathwayList(ConcurrentLinkedQueue<Integer> metabolitesPathwayList) {
this.metabolitesPathwayList = metabolitesPathwayList;
}
/**
* @return the metabolitesPathwayList
*/
public ConcurrentLinkedQueue<Integer> getMetabolitesPathwayList() {
return this.metabolitesPathwayList;
}
/**
* @param modulesPathwayList the modulesPathwayList to set
*/
public void setModulesPathwayList(ConcurrentLinkedQueue<Integer> modulesPathwayList) {
this.modulesPathwayList = modulesPathwayList;
}
/**
* @return the modulesPathwayList
*/
public ConcurrentLinkedQueue<Integer> getModulesPathwayList() {
return modulesPathwayList;
}
/**
* @param pathways_id the pathways_id to set
*/
public void setPathways_id(ConcurrentHashMap<String,Integer> pathways_id) {
this.pathways_id = pathways_id;
}
/**
* @return the pathways_id
*/
public ConcurrentHashMap<String,Integer> getPathways_id() {
return this.pathways_id;
}
/**
* @param cancel
*/
......
......@@ -19,8 +19,7 @@ public class BiggModelMetabolitesServices extends ModelMetabolitesServices {
* @param
* @throws Exception
*/
public static void loadMetabolites(String databaseName, ConcurrentLinkedQueue<MetaboliteContainer> metabolites, ConcurrentHashMap<String,Integer> metabolites_id,
ConcurrentLinkedQueue<String> concurrentLinkedQueue, boolean importedFromSBML) throws Exception {
public static void loadMetabolites(String databaseName, ConcurrentLinkedQueue<MetaboliteContainer> metabolites, ConcurrentHashMap<String,Integer> metabolites_id) throws Exception {
for (MetaboliteContainer metaboliteContainer : metabolites) {
......@@ -31,26 +30,8 @@ public class BiggModelMetabolitesServices extends ModelMetabolitesServices {
if(!metabolites_id.containsKey(metaboliteContainer.getExternalIdentifier())){
String entry_type = null;
if(importedFromSBML){
entry_type="COMPOUND";
}
else{
if(metaboliteContainer.getExternalIdentifier().startsWith("C"))
{entry_type="COMPOUND";}
if(metaboliteContainer.getExternalIdentifier().startsWith("G"))
{entry_type="GLYCAN";}
if(metaboliteContainer.getExternalIdentifier().startsWith("D"))
{entry_type="DRUGS";}
if(metaboliteContainer.getExternalIdentifier().startsWith("B"))
{entry_type="BIOMASS";}
}
String name = null;
String formula = null;
String mw = null;
boolean chbr = false;
if(metaboliteContainer.getName()!=null)
name = (metaboliteContainer.getName());
......@@ -58,13 +39,7 @@ public class BiggModelMetabolitesServices extends ModelMetabolitesServices {
if(metaboliteContainer.getFormula()!=null)
formula = (metaboliteContainer.getFormula());
if(metaboliteContainer.getMolecular_weight()!=null)
mw = (metaboliteContainer.getMolecular_weight());
if(concurrentLinkedQueue.contains(metaboliteContainer.getExternalIdentifier()))
chbr = true;
Integer id = insertCompound(databaseName, name, null, entry_type, metaboliteContainer.getExternalIdentifier(), formula, mw, null, null, null, chbr);
Integer id = insertCompound(databaseName, name, null, null, metaboliteContainer.getExternalIdentifier(), formula, null, null, null, null, null);
metaboliteContainer.setMetaboliteID(id);
......
......@@ -355,6 +355,16 @@ public class BiggUtils {
return file.getAbsolutePath().concat("/");
}
public static boolean deleteDirectory(File directoryToBeDeleted) {
File[] allContents = directoryToBeDeleted.listFiles();
if (allContents != null) {
for (File file : allContents) {
deleteDirectory(file);
}
}
return directoryToBeDeleted.delete();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment