public class Utilities extends Object
This class contains static methods for parsing compound masses, writing graph information, and merging property files.
The public methods can be called directly from the command line by executing
java -jar massbalance.jar utilities [method] [args...]
,
where method
is the method name and args...
are the method arguments.
The following method arguments are supported and will be translated from the given string argument:
MetabolicGraph
: pass the file name of the deserialized object.
int
: pass the integer argument.
String
: pass the String argument.
boolean
: pass 'true' or 'false'.
ArrayList<String>
: pass a list of strings as ['String1','String2',...].
An overview of the available methods is printed by executing the main class without arguments.
Modifier and Type | Field and Description |
---|---|
static boolean |
sbml |
static org.sbml.libsbml.SBMLDocument |
sbmlDocument |
static String |
sbmlMessage |
static Throwable |
sbmlThrowable |
Constructor and Description |
---|
Utilities() |
Modifier and Type | Method and Description |
---|---|
static void |
appendColumns(String inputFile1,
String inputFile2,
String outputFile,
int offset)
Appends the tab-separated tokens from each line in inputFile2 to the corresponding
lines in inputFile1 and prints the resulting lines to outputFile.
|
static void |
appendDeltaG(String compoundsFile,
String databaseFile,
String outputFile,
int hydrogenTolerance)
Searches the compounds from compoundsFile in the databaseFile by case-insensitive name and sum formula,
and prints the compounds with deltaG to outputFile.
|
static void |
appendDeltaGFromKEGG(String compoundsFile,
String databaseFile,
String outputFile)
Searches a KEGG ID in compoundsFile, matches the compound in databaseFile and appends
the deltaG and uncertainties to the compounds in outputFile.
|
static int |
appendFile(String inputFile,
String outputFile)
Appends the content from inputFile to the end of outputFile.
|
static void |
appendFiles(String firstInputFile,
int numberOfFiles,
String outputFile)
Appends the content from inputFile and the next numberOfFiles-1 inputFiles with
successive index numbers to the end of outputFile.
|
static void |
avgClassSizes(String classesFile)
Prints the number of single and double mass equivalence classes and their average sizes.
|
static long |
binomialCoefficient(long n,
long k)
Calculates the binomial coefficient (n over k).
|
static void |
checkBalance(MetabolicGraph graph)
Determines the mass-balance of the reactions in the given graph and prints
unbalanced reactions.
|
static void |
checkNetworks(String networkName,
String inputDir,
String randomization,
int from,
int to,
String outputFile)
Checks certain properties of the original network and the given range of randomized networks,
e.g. the number of isolated compound nodes or the number of reactions containing a cycle.
|
static void |
compoundAliasMap(String compoundsFile,
String massesFile,
String outputFile)
Maps compound strings with their masses from 2 files: one contains the compound strings and
aliases, the other maps the aliases to sum formulas.
|
static void |
compoundMassesMap(String compoundsFile,
String massesFile,
String outputFile)
Maps a list of compounds from compoundsFile to a list containing compound synonyms and masses in massesFile.
|
static int |
countIsolatedNodes(MetabolicGraph graph)
Counts the number of isolated nodes in the graph, i.e. nodes with an in-degree and out-degree of 0.
|
static void |
countReactions(MetabolicGraph graph,
boolean print)
Counts the number of reactions, reversible, cyclic, zero-degree reactions, and the average
and maximum reaction degrees.
|
static void |
countReactionsWithCycles(MetabolicGraph graph)
Counts the number of reactions which contain a cycle, i.e. a substrate which is also a product.
|
static void |
createGraph(String networkFile,
String outputFile,
boolean reversible,
boolean compartments)
Creates a graph from the biocyc or flat file input directory and deserializes it to the output file name.
|
static void |
deltaGDifferences(String databaseFile,
int hydrogenTolerance)
Parses the sum formulas and deltaG values from the databaseFile and determines
the differences in deltaGf between compounds which have an equal sum formula
up to the specified hydrogenTolerance in the number of hydrogen atoms.
|
static void |
findTransporters(MetabolicGraph graph,
ArrayList<String> compoundNames,
boolean exclusive)
Finds and prints all transport reactions in which the given compounds are involved.
|
static long |
gcd(long[] values)
Calculates the greatest common divisor the given values.
|
static org.sbml.libsbml.SBMLDocument |
initSBML(String sbmlFile)
Checks if there is SBML support, then validates and returns
the SBMLDocument.
|
static void |
joinLines(String inputFile1,
String inputFile2,
String outputFile)
Searches in inputFile2 for the first string of each line in inputFile1, and
joins the remaining strings in outputFile.
|
static void |
joinSimilarSynonyms(String compoundsFile,
String databaseFile,
String outputFile,
double maxDistance,
int hydrogenTolerance)
Parses the compounds file for synonyms (more than one name for a compound) and searches
similar synonyms with similar sum formula in databaseFile.
|
static void |
joinSynonyms(String inputMap,
String databaseFile,
String outputFile,
boolean caseSensitive,
int minMatch,
int minAdd)
Parses the inputMap file for synonyms and searches all synonyms in databaseFile.
|
static long |
lcm(int x,
int y)
Returns the least common integer multiple for x and y, determined
by dividing x*y by the greatest common divisors.
|
static double |
linearDependent(double[] a,
double[] b)
Tests a and b for linear dependence.
|
static void |
main(String[] args)
The main method can be used to call the public methods of this class
directly from the command line by executing
java -jar massbalance.jar utilities [method] [args...] |
static void |
matchStrings(String templateFile,
String databaseFile,
String outputFile,
double maxDistance) |
static void |
maxDoubleClass(String classesFile)
Prints the largest pair equivalence class, including implicit pairs.
|
static void |
maxExplicitDoubleClass(String classesFile)
Prints the largest pair equivalence class, excluding implicit pairs.
|
static void |
maxSingleClass(String classesFile)
Prints the largest single equivalence class.
|
static double |
parseCoefficient(String s)
Parses a string and returns the stoichiometric coefficient, or -1 if
the string is not a stoichiometric coefficient, i.e., a double number
enclosed by DELIMITER_COEFFICIENT_START and DELIMITER_COEFFICIENT_END.
|
static int[] |
parseInChIString(String name,
String InChI,
BufferedWriter infoWriter)
Parses an InChI string and returns an int[ELEMENTS.length] containing the mass vector.
|
static int[] |
parseMass(String massString,
BufferedWriter infoWriter)
Parses a string of format CXHYNZ..., where C,H,N are chemical elements followed by the
number of atoms X,Y,Z.
|
static ArrayList<String> |
parseTokens(String input,
String delimiter,
boolean lowercase)
Parses the input string and returns a list of tokens separated by delimiter.
|
static void |
printCoefficients(MetabolicGraph graph)
Prints the stoichiometric coefficients of the given graph,
i.e., its edge weights.
|
static void |
printCompartmentInfo(MetabolicGraph graph)
Prints the number of compounds, reactions, and transporters associated with each compartment.
|
static void |
printCompoundIndices(MetabolicGraph graph,
ArrayList<String> compounds)
Prints the indices in the sorted lists of compounds from the given compounds list.
|
static void |
printDeadEnds(MetabolicGraph graph,
String output) |
static void |
printEquivalenceClass(String classesFile,
String compound)
Prints the equivalence classes in which the given compound is contained.
|
static void |
printExampleReactions(String networkFile)
Prints some example reactions of the graph with in- and out-degree smaller than 4.
|
static void |
printExternalCompoundIndices(MetabolicGraph graph)
Prints the sorted stoichiometric matrix indices of all compounds in a compartment
starting with "ext", "ex", or "e".
|
static void |
printHubCompounds(MetabolicGraph graph,
int number)
Prints the number of compounds given by number with largest degree.
|
static void |
printLargeCoefficients(MetabolicGraph graph,
int min)
Print all reactions in the given graph that have a coefficient at least as large as min.
|
static void |
printMappedIndices(MetabolicGraph graph,
String mappingFile,
String indexFile)
Maps the compound names given in indexFile to the pair of corresponding names given in mappingFile,
and prints the indices of the mapped compounds in the sorted stoichiometric matrix.
|
static void |
printMass(MetabolicGraph graph,
String compoundString) |
static void |
printMasses(String compoundsFile,
String networkFile,
String infoFile)
Print all compounds with masses and the largest integer factorization.
|
static void |
printMaxCoefficient(MetabolicGraph graph)
Searches for the largest coefficient in the network and prints the
corresponding reaction.
|
static void |
printMaxDeltaGr(MetabolicGraph graph,
boolean reversible,
boolean excludeTransprorters)
Searches for the largest deltaGr in the network and prints the
corresponding reaction.
|
static void |
printPathway(MetabolicGraph graph)
Prints a particular type of pathway, if present:
A -> B+D
B+D -> C
where D is a cofactor (has a large degree), and B not.
|
static void |
printReaction(MetabolicGraph graph,
String reaction,
boolean printMass,
boolean printDeltaG)
Prints the reaction equation from the given graph.
|
static void |
printReaction(MetabolicGraph graph,
Vertex reaction,
boolean printMass,
boolean printDeltaG)
Prints the equation of the given reaction.
|
static void |
printReactionIndices(MetabolicGraph graph,
ArrayList<String> reactions)
Prints the indices in the sorted lists of reactions from the given reaction list.
|
static void |
printReactions(MetabolicGraph graph)
Prints all reaction equations of the given graph.
|
static void |
printReactions(MetabolicGraph graph,
ArrayList<String> reactions)
Prints the reaction equations from the given graph.
|
static void |
printSmallDegreeReactions(MetabolicGraph graph)
Prints all reactions with in-degree+out-degree < 3 in the graph.
|
static void |
printTCACycleReactions(MetabolicGraph graph)
Prints reactions containing TCA cycle intermediaries from ecoli, satisfying
additional conditions.
|
static void |
reachable(ArrayList<String> substrateNames,
ArrayList<String> productNames,
MetabolicGraph graph) |
static void |
select(String inputFile,
String outputFile,
boolean append)
Writes every tenth element from every line of the input file to the output file.
|
static void |
summary(MetabolicGraph graph)
Print the summary statistics for the given graph:
- number of compounds and those containing only CHNOPS
- number of reactions, unbalanced and unannotated reactions
- reversibility of the graph, number of vertices and edges
- sizes of connected and strongly connected components
|
static void |
testGraphs(String inputDir,
String version,
boolean massbalance,
int from,
int to)
Tests the serialized graphs in the given directory of the given species version.
|
static void |
validateSBML(org.sbml.libsbml.SBMLDocument sbmlDoc)
Performs an internal consistency check of the SBML Document.
|
static void |
writeBioCycWeights(String compoundsDir,
String outputPath)
Prints the molecular weights of all compounds in the given biocyc directory.
|
static void |
writeCompartments(String reactionsFile)
Prints all compartments in the given network.
|
static void |
writeLines(String inputFile,
int from,
int to)
Prints the lines in the given from-to range of the given inputFile.
|
public static boolean sbml
public static String sbmlMessage
public static Throwable sbmlThrowable
public static org.sbml.libsbml.SBMLDocument sbmlDocument
public static void main(String[] args)
The main method can be used to call the public methods of this class
directly from the command line by executing
java -jar massbalance.jar utilities [method] [args...]
where method
is the method name and args...
are the method arguments. The following method arguments are supported
and will be translated from the given string argument:
MetabolicGraph
: pass the file name of the deserialized object.
int
: pass the integer argument.
String
: pass the String argument.
boolean
: pass 'true' or 'false'.
ArrayList<String>
: pass a list of strings as ['String1','String2',...].
An overview of the available methods is printed by executing the main class without arguments.
public static void select(String inputFile, String outputFile, boolean append) throws IOException
inputFile
- outputFile
- IOException
public static void writeLines(String inputFile, int from, int to) throws IOException
inputFile
- from
- to
- IOException
public static int appendFile(String inputFile, String outputFile) throws IOException
inputFile
- outputFile
- IOException
public static void appendFiles(String firstInputFile, int numberOfFiles, String outputFile) throws IOException
firstInputFile
- numberOfFiles
- outputFile
- IOException
public static void appendColumns(String inputFile1, String inputFile2, String outputFile, int offset) throws IOException
inputFile1
- inputFile2
- outputFile
- offset
- IOException
public static void joinLines(String inputFile1, String inputFile2, String outputFile) throws IOException
inputFile1
- inputFile2
- outputFile
- IOException
public static void maxSingleClass(String classesFile) throws IOException, InterruptedException
classesFile
- IOException
InterruptedException
public static void maxExplicitDoubleClass(String classesFile) throws IOException, InterruptedException
classesFile
- IOException
InterruptedException
public static void maxDoubleClass(String classesFile) throws IOException, InterruptedException
classesFile
- IOException
InterruptedException
public static void printEquivalenceClass(String classesFile, String compound) throws IOException, InterruptedException
compound
- IOException
InterruptedException
public static void avgClassSizes(String classesFile) throws IOException, InterruptedException
classesFile
- IOException
InterruptedException
public static void writeCompartments(String reactionsFile) throws IOException
reactionsFile
- IOException
public static void printCompartmentInfo(MetabolicGraph graph)
graph
- public static void testGraphs(String inputDir, String version, boolean massbalance, int from, int to) throws IOException, ClassNotFoundException
inputDir
- version
- massbalance
- IOException
ClassNotFoundException
public static void createGraph(String networkFile, String outputFile, boolean reversible, boolean compartments) throws IOException, ClassNotFoundException
networkFile
- outputFile
- reversible
- compartments
- IOException
ClassNotFoundException
public static void checkNetworks(String networkName, String inputDir, String randomization, int from, int to, String outputFile) throws IOException, ClassNotFoundException
networkName
- inputDir
- randomization
- from
- to
- IOException
ClassNotFoundException
public static int countIsolatedNodes(MetabolicGraph graph)
graph
- public static void countReactionsWithCycles(MetabolicGraph graph)
graph
- public static void checkBalance(MetabolicGraph graph)
graph
- public static void countReactions(MetabolicGraph graph, boolean print) throws IOException
graph
- print
- IOException
public static void printReactionIndices(MetabolicGraph graph, ArrayList<String> reactions) throws IOException, ClassNotFoundException
graph
- reactions
- IOException
ClassNotFoundException
public static void printCompoundIndices(MetabolicGraph graph, ArrayList<String> compounds) throws IOException, ClassNotFoundException
graph
- compounds
- IOException
ClassNotFoundException
public static void findTransporters(MetabolicGraph graph, ArrayList<String> compoundNames, boolean exclusive) throws IOException, ClassNotFoundException
graph
- compoundNames
- exclusive
- IOException
ClassNotFoundException
public static void printExternalCompoundIndices(MetabolicGraph graph)
graph
- public static void summary(MetabolicGraph graph)
graph
- public static void printExampleReactions(String networkFile) throws IOException
networkFile
- IOException
public static void printCoefficients(MetabolicGraph graph)
graph
- public static void printMasses(String compoundsFile, String networkFile, String infoFile) throws IOException
compoundsFile
- networkFile
- infoFile
- IOException
public static void printLargeCoefficients(MetabolicGraph graph, int min)
graph
- min
- public static void printMaxCoefficient(MetabolicGraph graph)
graph
- public static void printMaxDeltaGr(MetabolicGraph graph, boolean reversible, boolean excludeTransprorters)
graph
- public static void printMass(MetabolicGraph graph, String compoundString)
public static void printReactions(MetabolicGraph graph)
graph
- public static void printDeadEnds(MetabolicGraph graph, String output) throws IOException
IOException
public static void printReaction(MetabolicGraph graph, Vertex reaction, boolean printMass, boolean printDeltaG)
graph
- reaction
- public static void printReaction(MetabolicGraph graph, String reaction, boolean printMass, boolean printDeltaG)
graph
- reaction
- public static void printReactions(MetabolicGraph graph, ArrayList<String> reactions)
graph
- reactions
- public static void printSmallDegreeReactions(MetabolicGraph graph)
graph
- public static void printHubCompounds(MetabolicGraph graph, int number)
graph
- number
- public static void printPathway(MetabolicGraph graph)
graph
- public static void printTCACycleReactions(MetabolicGraph graph)
graph
- public static int[] parseInChIString(String name, String InChI, BufferedWriter infoWriter) throws IOException
InChI
- IOException
public static int[] parseMass(String massString, BufferedWriter infoWriter) throws IOException
massString
- IOException
public static double parseCoefficient(String s)
s
- public static long gcd(long[] values)
values
- public static long lcm(int x, int y)
x
- y
- public static long binomialCoefficient(long n, long k)
n
- k
- public static double linearDependent(double[] a, double[] b)
a
- b
- public static void printMappedIndices(MetabolicGraph graph, String mappingFile, String indexFile) throws IOException
graph
- mappingFile
- indexFile
- IOException
public static void compoundAliasMap(String compoundsFile, String massesFile, String outputFile) throws IOException
compoundsFile
- massesFile
- outputFile
- IOException
public static void appendDeltaG(String compoundsFile, String databaseFile, String outputFile, int hydrogenTolerance) throws IOException
compoundsFile
- databaseFile
- outputFile
- hydrogenTolerance
- IOException
public static void appendDeltaGFromKEGG(String compoundsFile, String databaseFile, String outputFile) throws IOException
compoundsFile
- databaseFile
- outputFile
- IOException
public static void deltaGDifferences(String databaseFile, int hydrogenTolerance) throws IOException
databaseFile
- hydrogenTolerance
- IOException
public static ArrayList<String> parseTokens(String input, String delimiter, boolean lowercase)
input
- delimiter
- lowercase
- public static void joinSynonyms(String inputMap, String databaseFile, String outputFile, boolean caseSensitive, int minMatch, int minAdd) throws IOException
inputMap
- databaseFile
- outputFile
- IOException
public static void joinSimilarSynonyms(String compoundsFile, String databaseFile, String outputFile, double maxDistance, int hydrogenTolerance) throws IOException
compoundsFile
- databaseFile
- outputFile
- maxDistance
- hydrogenTolerance
- IOException
public static void matchStrings(String templateFile, String databaseFile, String outputFile, double maxDistance) throws IOException
IOException
public static void compoundMassesMap(String compoundsFile, String massesFile, String outputFile) throws IOException
compoundsFile
- massesFile
- outputFile
- IOException
public static void reachable(ArrayList<String> substrateNames, ArrayList<String> productNames, MetabolicGraph graph) throws IOException
IOException
public static org.sbml.libsbml.SBMLDocument initSBML(String sbmlFile)
validateSBML(SBMLDocument)
).
For some reason, the SBML Model is not stored properly as
static variable. Therefore, we store the SBMLDocument, which
avoids multiple validations.sbmlFile
- public static void validateSBML(org.sbml.libsbml.SBMLDocument sbmlDoc)
sbmlDoc
- public static void writeBioCycWeights(String compoundsDir, String outputPath) throws IOException
compoundsDir
- outputPath
- IOException