Commit 90a25607 authored by cfrainay's avatar cfrainay
Browse files

fix missing optional files exceptions in metaborank, precursor and scope network

parent 2abf493a
#
# Copyright INRAE (2022)
#
# contact-metexplore@inrae.fr
#
# This software is a computer program whose purpose is to [describe
# functionalities and technical features of your software].
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "https://cecill.info/licences/Licence_CeCILL_V2.1-en.html".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
#
# Extra logging related to initialization of Log4j
# Set to debug or trace if log4j initialization is failing
status = error
# Name of the configuration
name = ConsoleLogConfigDemo
# Console appender configuration
appender.console.type = Console
appender.console.name = consoleLogger
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Root logger level
rootLogger.level = error
# Root logger referring to console appender
rootLogger.appenderRef.stdout.ref = consoleLogger
\ No newline at end of file
......@@ -39,18 +39,17 @@ import fr.inrae.toulouse.metexplore.met4j_chemUtils.chemicalSimilarity.Fingerpri
import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioMetabolite;
import fr.inrae.toulouse.metexplore.met4j_core.biodata.BioNetwork;
import fr.inrae.toulouse.metexplore.met4j_graph.computation.analyze.centrality.EigenVectorCentrality;
import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.ReactionProbabilityWeight;
import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.SimilarityWeightPolicy;
import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.WeightUtils;
import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.WeightsFromFile;
import fr.inrae.toulouse.metexplore.met4j_graph.computation.connect.weighting.*;
import fr.inrae.toulouse.metexplore.met4j_graph.computation.transform.GraphFilter;
import fr.inrae.toulouse.metexplore.met4j_graph.computation.utils.RankUtils;
import fr.inrae.toulouse.metexplore.met4j_graph.core.GraphFactory;
import fr.inrae.toulouse.metexplore.met4j_graph.core.WeightingPolicy;
import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.CompoundGraph;
import fr.inrae.toulouse.metexplore.met4j_graph.core.compound.ReactionEdge;
import fr.inrae.toulouse.metexplore.met4j_graph.io.Bionetwork2BioGraph;
import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.JsbmlReader;
import fr.inrae.toulouse.metexplore.met4j_io.jsbml.reader.Met4jSbmlReaderException;
import fr.inrae.toulouse.metexplore.met4j_io.utils.StringUtils;
import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.AbstractMet4jApplication;
import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.EnumFormats;
import fr.inrae.toulouse.metexplore.met4j_toolbox.generic.annotations.Format;
......@@ -228,15 +227,18 @@ public class MetaboRank extends AbstractMet4jApplication {
}
public void setEdgeWeights(CompoundGraph graph, String localFilePath) {
Boolean defaultWeight = (localFilePath==null || localFilePath.isEmpty() || localFilePath.isBlank());
//import weights from file
WeightsFromFile<BioMetabolite, ReactionEdge, CompoundGraph> wp = new WeightsFromFile<>(localFilePath, true);
WeightingPolicy wp = (defaultWeight) ? new DefaultWeightPolicy() : new WeightsFromFile<>(localFilePath, true);
//set weights to edges
wp.setWeight(graph);
//remove weights below 0.0
int nb = GraphFilter.weightFilter(graph, 0.0, "<=");
System.err.println(nb + " edges removed");
//remove edges without NaN weight
WeightUtils.removeEdgeWithNaNWeight(graph);
if (!defaultWeight) {
//remove weights below 0.0
int nb = GraphFilter.weightFilter(graph, 0.0, "<=");
System.err.println(nb + " edges removed");
//remove edges without NaN weight
WeightUtils.removeEdgeWithNaNWeight(graph);
}
//remove disconnected nodes
graph.removeIsolatedNodes();
System.err.println("weights computed.");
......
......@@ -41,12 +41,12 @@ public class PrecursorNetwork extends AbstractMet4jApplication {
@Option(name = "-o", usage = "output file: path to the .gml file where the results precursor network will be exported", required = true)
public String output;
//oprtions
//options
@ParameterType(name = InputFile)
@Option(name = "-sc", aliases = {"--sides"}, usage = "an optional file containing list of ubiquitous compounds to be considered already available")
public String sideCompoundFile = null;
@ParameterType(name = InputFile)
@Option(name = "-ir", aliases = {"--ignore"}, usage = "an optional file containing list of reaction to ignore (forbid inclusion in scope")
@Option(name = "-ir", aliases = {"--ignore"}, usage = "an optional file containing list of reaction to ignore (forbid inclusion in scope)")
public String reactionToIgnoreFile = null;
public static void main(String[] args) throws IOException, Met4jSbmlReaderException {
......@@ -64,10 +64,10 @@ public class PrecursorNetwork extends AbstractMet4jApplication {
BioCollection<BioMetabolite> targets = mapper.map(targetsFilePath).stream()
.map(BioMetabolite.class::cast)
.collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
BioCollection<BioMetabolite> bootstraps = mapper.map(sideCompoundFile).stream()
BioCollection<BioMetabolite> bootstraps = (sideCompoundFile==null) ? new BioCollection<>() : mapper.map(sideCompoundFile).stream()
.map(BioMetabolite.class::cast)
.collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
BioCollection<BioReaction> forbidden = mapper.map(reactionToIgnoreFile).stream()
BioCollection<BioReaction> forbidden = (reactionToIgnoreFile==null) ? new BioCollection<>() : mapper.map(reactionToIgnoreFile).stream()
.map(BioReaction.class::cast)
.collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
......
......@@ -72,17 +72,12 @@ public class ScopeNetwork extends AbstractMet4jApplication {
BioCollection<BioMetabolite> seeds = mapper.map(seedsFilePath).stream()
.map(BioMetabolite.class::cast)
.collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
BioCollection<BioMetabolite> bootstraps = mapper.map(sideCompoundFile).stream()
BioCollection<BioMetabolite> bootstraps = (sideCompoundFile==null) ? new BioCollection<>() : mapper.map(sideCompoundFile).stream()
.map(BioMetabolite.class::cast)
.collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
BioCollection<BioReaction> forbidden = new BioCollection<>();
if (reactionToIgnoreFile != null) {
forbidden = mapper.map(reactionToIgnoreFile).stream()
BioCollection<BioReaction> forbidden = (reactionToIgnoreFile==null) ? new BioCollection<>() : mapper.map(reactionToIgnoreFile).stream()
.map(BioReaction.class::cast)
.collect(BioCollection::new, BioCollection::add, BioCollection::addAll);
}
ScopeCompounds scopeComp = new ScopeCompounds(graph, seeds, bootstraps, forbidden);
if (includeSides) scopeComp.includeBootstrapsInScope();
......
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