Class Maygen
- java.lang.Object
-
- org.openscience.cdk.structgen.maygen.Maygen
-
public class Maygen extends Object
The main class of the MAYGEN package. The basic input is the molecular formula. For a molecular * formula, MAYGEN first distributes hydrogens, then for each distribution starting the generation process. The algorithm can be run in sequential or parallel mode. To collect the structures you provide aMaygen.Consumerinstance, here is basic usage:IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); SmilesGenerator smigen = new SmilesGenerator(SmiFlavor.Default); Maygen maygen = new Maygen(builder); maygen.setFormula("C3Cl2H4"); maygen.setConsumer(mol -> { try { System.out.println(smigen.create(mol)); } catch (CDKException ignore) { } }); maygen.run(); int count = maygen.getCount(); // number of structures generated- Author:
- MehmetAzizYirik
<0000-0001-7520-7215@orcid.org> - Belongs to CDK module:
- structgen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMaygen.Consumer
-
Field Summary
Fields Modifier and Type Field Description static Maygen.ConsumerNOOP_CONSUMER
-
Constructor Summary
Constructors Constructor Description Maygen(IChemObjectBuilder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]actArray(int[] array, Permutation permutation)Performing the permutation action on an int array.int[][]addHydrogens(int[][] a, int index, int[] hydrogens)After generating matrices, adding the hydrogen with respect to the pre-hydrogen distribution.voidaddOnes(int[] list, int number)Add number of 1s into an ArrayListvoidaddPartition(int index, int[] newPartition, int[][] a, int[][] partitionList)Updating canonical partition list.booleanallIs0(int[] list)Checks whether all the entries are equal to 0 or not.intatomOccurrence(String[] info)Getting the number of atoms' occurrences.int[][]backward(int[][] a, int[] indices, int[] degrees, int[] initialPartition, boolean[] callForward, int[] r, int[][][] max, int[][][] l, int[][][] c, boolean[] flag)Backward step in the algorithm.booleanbackwardCriteria(int x, int lInverse, int l)The criteria to decide which function is needed: forward or backward.booleanbiggerCheck(int index, int[] firstRow, int[] check, int[] partition)Checks two arrays in descending order.int[]buildArray(int[] partition)Building the copy of the partition arrayIAtomContainerbuildAtomContainerFromMatrix(int[][] mat, IAtomContainer atomContainer)Building an atom container for an adjacency matrix.IAtomContainerbuildContainer4SDF(int[][] mat)Building an atom container for an adjacency matrix.IAtomContainerbuildContainer4SDF(String[] symbols)Building an atom container for SDF output from its symbolsIAtomContainerbuildContainer4SDF(IAtomContainer ac, int[][] mat)Building an atom container for an adjacency matrix.String[]buildSymbolArray()booleancanBuildIsomer(String formula)Checking whether a molecular formula can represent a graph or not.booleancanBuildIsomerSingle(String formula)Checking whether a molecular formula can represent a graph or not.voidcandidatePermutations(int index, List<Permutation> cycles, List<ArrayList<Permutation>> formerPermutations)Calculating all candidate permutations for row canonical test.int[]canonicalPartition(int i, int[] partition)To get the canonical partition.booleancanonicalTest(int[][] a, int[] initialPartition, int[][] partitionList, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] partSize, int[] r, int[] y, int[] z, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest)booleancheck(int index, int total, int[][] a, int[] newPartition, List<ArrayList<Permutation>> formerPermutations)voidcheckJustH(int[][][] max, int i, int j, int di)booleancheckLengthTwoFormula(String[] atoms)checking whether a molecular formula is length 2 or not.voidcheckOxygenSulfur(String[] atoms)intcInverse(int i, int j, int[][] a, int[] degrees)Calculating the sum of the entries in the jth column until the ith row.voidclearFormers(boolean check, int y, int[][] partitionList, List<ArrayList<Permutation>> formerPermutations)When an adjacency matrix is non-canonical, cleaning the formerPermutations and partitionList from the first row of the tested block.voidclearGlobals()For several calls of the run function, setting the global variables.int[]cloneArray(int[] array)Cloning int arrayvoidcloseFilesAndDisplayStatistic(long startTime)booleancompare(int[] array1, int[] array2, int index1, int index2)Comparing two arrays for specific range of entries, whether the first array is bigger than the second one or not.booleancompareIndexwise(int[] array, int[] array2, int index1, int index2)Comparing two int arrays are equal or not for given range of entries.booleanconnectivityTest(int[][] mat, int[] connectivityIndices, boolean[] learningFromConnectivity)Test whether an adjacency matrix is connected or disconnected.intcsum(int i, int j, int[][][] max)Summing ith column entries starting from the jth row.List<Permutation>cycleTranspositions(int index, int[] partition)Getting the list of cycle transpositions for a given atom partition and the row indexvoiddegree2graph()Building a degree 2 graph for a single element type.booleandescendingOrderCheck(int[] partition, int[] array)Checks a int array is in descending order or not with respect to a given atom partition.booleandescendingOrderCheck(int[] array, int f, int l)Checks subarray of specified range of entries, the array is descending order or not.booleandescendingOrderUpperMatrixCheck(int index, int[] partition, int[] firstRow, int[] secondRow)Checks the first row is bigger than the second row just in the upper matrix.int[]descendingSort(int[] array, int index0, int index1)Sorting entries of a subarray specified by indices.int[]descendingSortWithPartition(int[] array, int[] partition)Sorting entries of a int array for a given atom partition.voiddisplayStatistic(long startTime, String localFormula)List<int[]>distributeHydrogens()If there are hydrogens in the formula, calling the hydrogenDistributor.voiddistributeSulfurOxygen(String localFormula)voiddistributeSymbols(int oxy, int sul, int nextSize, int currentSize, int reversedLength, int leftEquivalents, int rightEquivalents, boolean reversalIsSmaller)Main function for the distribution of atom symbols: O and S for OnSm form formulae.voiddistributeSymbolsNextSizeAboveGraphSize(int currentSize, boolean reversalIsSmaller)voiddoRun(String localFormula)voidemit(IAtomContainer mol)Emits a molecule to whomever is listening.booleanequalRowsCheck(int index, int[][] a, Permutation cycleTransposition, Permutation permutation)Comparing two arrays are equal.booleanequalSetCheck(int[] array1, int[] array2, int[] partition)Checks two int[] arrays are equal with respect to an atom partition.booleanequalSetCheck2(int[] partition, int[] array1, int[] array2)Checks two int[] arrays are equal with respect to an atom partition.StringextendFormula(String localFormula, int number, String symbol)Adding new entry to the new molecular formulavoidfillDegreeListHindexIsTwo(List<int[]> degreeList, List<int[]> distributions)intfindIndex(int index, Permutation cycle)With the cycle permutation, mapping the row index to another row in the block.intfindMatch(int[] max, int[] non, int value, int start)Find the matching entries index in compared two rows.intfindMaximalIndexInComponent(int[] kValues, int value)Finding the maximal index in a component to compare with other components.voidfindR(int[] indices, int[] initialPartition, int[] r)Finding the R index of a blockintfindY(int r, int[] initialPartition)For a block index r, calculating its first row index.intfindZ(int r, int[] initialPartition)For a block index r, calculating its last row index.intfindZeros(int[] array)int[][]forward(IAtomContainer ac, String[] symbolArrayCopy, int[][] a, int[] indices, int[] degrees, int[] initialPartition, int[][] partitionList, boolean[] callForward, int[] connectivityIndices, boolean[] learningFromConnectivity, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] hydrogens, int[] partSize, int[] r, int[] y, int[] z, int[][][] max, int[][][] l, int[][][] c, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest)Setting successor indices entry if there is a possible filling.int[][]forward(IAtomContainer ac, String[] symbolArrayCopy, int lInverse, int cInverse, int maximalX, int i, int j, int[][] a, int[] indices, int[] initialPartition, int[][] partitionList, boolean[] callForward, int[] connectivityIndices, boolean[] learningFromConnectivity, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] hydrogens, int[] partSize, int[] r, int[] y, int[] z, int[][][] max, int[][][] l, int[][][] c, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest)voidgenerate(IAtomContainer ac, String[] symbolArrayCopy, int[] degreeList, int[] initialPartition, int[][] partitionList, int[] connectivityIndices, boolean[] learningFromConnectivity, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] hydrogens, int[] partSize, int[] r, int[] y, int[] z, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest)Initialization of global variables for the generate of structures for given degree list.voidgenerateFormulae(List<String> result, List<String> symbolList, Map<String,Integer[]> symbols, String localFormula, int index)Formulae generator for each element rangesint[][]generateOnSmMat()Building an OnSm molecule for a given total number of atoms.int[]getBlocks(int[] array, int begin, int end)Getting a part of a int array specified by two entry indicesIChemObjectBuildergetBuilder()PermutationgetCanonicalCycle(int index, int total, int[][] a, int[] newPartition, Permutation cycleTransposition)Getting the canonical cycle of a row.PermutationgetCanonicalPermutation(int[] originalRow, int[] rowToCheck, int[] partition)Calculating the canonical permutation of a row.int[]getCanonicalPermutation2(int[] partition, int[] max, int[] check)Calculating the canonical permutation of a row.Maygen.ConsumergetConsumer()intgetCount()int[]getCyclesList(int[] max, int[] non, int index, int[] values)For maximal and tested rows, getting the cycle listsPermutationgetEqualPerm(Permutation cycleTransposition, int index, int[][] a, int[] newPartition)Getting the permutation making two rows identical.StringgetFormula()List<String>getFormulaList(String normalizedLocalFuzzyFormula)Generating list of formulae for the input fuzzy formulaintgetFuzzyCount()StringgetFuzzyFormula()Map<String,Integer[]>getFuzzyFormulaRanges(String localFormula, List<String> symbolList)To get the fuzzy formula ranges for each element type in the molecular formulaMap<String,Integer[]>getFuzzyFormulaRangesWithNewElements(String localFormula, List<String> symbolList)voidgetHigherValences(String localFormula)Reading the molecular formula and setting the higher valences.intgetHydrogensInfoLengthIsOne(List<String> symbolList, String[] info, int hydrogens)voidgetLernenIndices(int index, int[][] a, List<Permutation> cycles, int[] partition, int[] nonCanonicalIndices, boolean[] learningFromCanonicalTest)Get indices from "learning from canonical test" method.int[]getMaximumPair(int[] a, int[] b)Between two index pairs, getting the bigger indices.PermutationgetNonCanonicalMakerPermutation(int[] array, Permutation cycle, int[] partition)Calculating the permutation, permuting the second row and making first row non maximal.int[]getOccurrences()List<int[]>getOxygenSulfur()int[]getPartition(int[] degrees)Based on the new degrees and the former partition, getting the new atom partition.int[]getPartition(List<String> symbols)Getting the partition of symbolsintgetPermutedIndex(Permutation permutation, int index)By a given permutation, checking which entry is mapped to the index.voidgetSingleAtomVariables(String localFormula)intgetSize()int[]getSubPartition(int[] degrees)Calculating the sub partitions for a given group of degrees.StringgetSymbol(String[] info, Integer[] n)String[]getSymbolArray()voidgetSymbolOccurrences(String localFormula)Getting the symbol occurrences from the input local formula.List<String>getSymbols()intgetTotal()intgetTotalHydrogen()int[]getTranspose(int[] indices)For an index pair, getting its transpose.booleangetVerbose()PermutationidPermutation(int localSize)Builds id permutation.int[]idValues(int localSize)Values for an id permutation for a given localSizeintindexYZ(int[] initialPartition, int[] r)Based on the molecules automorphisms, testing an adjacency matrix is canonical or not.voidinitAC(String symbol)Building an atom container from a string of atom-implicit hydrogen information.IAtomContainerinitAC(IAtomContainer ac, String[] symbolArrayCopy)Building an atom container from a string of atom-implicit hydrogen information.voidinitialDegrees()Initial degree arrays are set based on the molecular formula.int[]initialKList(int total)Initializing the first connectivity partition.int[]initialPartition(int[] partition)Initial atom partition of the input molecular formulavoidinitSingleAC()Setting the initial atom container of a molecular formula with a single heavy atomvoidintAC(String formula)Setting the initial atom container of a molecular formulabooleanisBoundary()booleanisMultiThread()booleanisOnSm()booleanisReversalIsSmaller(int nextSize, int reversedLength, boolean reversalIsSmaller)booleanisSetElement()booleanisTsvoutput()int[]kValues(int total, Set<Integer> wValues, int[] kFormer)Finding the connectivity partition, so the smallest index in the neighborhood.int[]limit(int index, int nextRowIndex, int[][] a, Permutation permutation)Looking for the upper limit where the original entry is smaller.intlInverse(int i, int j, int[][] a, int[] degrees)Calculating the sum of the entries in the ith row until the jth column.int[]lowerIndex(int index, int nextRowIndex, int[][] a, Permutation permutation)Looking for the maximum index where the entry is not zero.intlsum(int i, int j, int[][][] max)Summing ith rows entries starting from the jth column.intlValue(int[] partEx, int degree)To calculate the number of conjugacy classes, used in cycle transposition calculation.intmaximalEntry(int min, int lInverse, int l, int cInverse, int c)Calculating the maximal entry for the indices.int[]maximalIndexWithNonZeroEntry(int[][] a, int[] maximalIndices)In case if the index' entry is zero, updating the index with next index with non-zero entry.voidmaximalMatrix(int[] degrees, int[][][] max)Possible maximal edge multiplicity for the atom pair (i,j).intminComponentIndex(Set<Integer> zValues, int[] kValues)Getting the minimum component index.int[]nextCount(int index, int i, int localSize, int[] degrees, int[] partition)Counting the occurrence of a value in a degree.int[]nextCount(int index, int i, int localSize, List<String> symbols, int[] partition)voidnextStep(IAtomContainer ac, String[] symbolArrayCopy, int[][] a, int[] indices, int[] degrees, int[] initialPartition, int[][] partitionList, boolean[] callForward, int[] connectivityIndices, boolean[] learningFromConnectivity, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] hydrogens, int[] partSize, int[] r, int[] y, int[] z, int[][][] max, int[][][] l, int[][][] c, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest, boolean[] flag)Calling foward or backward function in a nextstep function.StringnormalizeFormula(String formula)Set<Integer>nValues(int index, int total, int[][] mat)Finding the neighbors of a given index.voidorderDegreeSymbols(int[] degree, String[] symbol, int index0, int index1, int[] hydrogens)Ordering degrees, hydrogens and symbols in ascending orderint[]partitionCriteria(int[] partEx, int degree)Partitioning criteriaint[]permuteArray(int[] array, int i, int j)Permuting two entries of an Integer array.int[]predecessor(int[] indices, int localSize)Calculation of the former index pair in a matrix.voidprocessFormula(String normalizedLocalFormula, long startTime)voidprocessRun(String normalizedLocalFormula, long startTime)int[]refinedPartitioning(int[] partition, int[] row)Refining the input partition based on the row entries.voidreOrder(int[] partition, int[] degrees, String[] symbols, int[] hydrogens)Re-order all the global variables based on the refined new partitioning.intreverseComparison(int length, int index)The function to compare a node labelling array when the number of left consecutive entries is equal to the right consecutive entries.int[]row2compare(int index, int[][] a, Permutation cycleTransposition)For a row given by index, detecting the other row to compare in the block.booleanrowCanonicalTest(int index, int[] r, int[][] a, int[] partition, int[] newPartition, int[] initialPartition, int[][] partitionList, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] y, int[][] ys, boolean[] learningFromCanonicalTest)Canonical test for a row in the tested block.booleanrowDescendingTest(int index, int[][] a, int[] partition, int[] nonCanonicalIndices, boolean[] learningFromCanonicalTest)The row descending test is the part of canonical test function.voidrun()Main function to initialize the global variables and calling the generate function.voidrunDistributeSymbols(int nextSize, int currentSize, int reversedLength, int leftEquivalents, int rightEquivalents, boolean reversalIsSmaller, int oxy2, int sul2, int reverse)voidrunDistributeSymbolsCheckNodeLabels(int oxy, int sul, int nextSize, int currentSize, int reversedLength, int leftEquivalents, boolean reversalIsSmaller)booleansetBiggest(int index, int[][] a, Permutation permutation, int[] partition)Checks whether there is a permutation making the row bigger in descending order.voidsetBoundary(boolean boundary)voidsetConsumer(Maygen.Consumer consumer)voidsetFormula(String formula)voidsetFuzzyFormula(String fuzzyFormula)int[]setHydrogens(int[] degree)Calling the generate function for each degree values after the hydrogen distribution.voidsetLearningFromConnectivity(Set<Integer> zValues, int[] kValues, int[] connectivityIndices, boolean[] learningFromConnectivity)If matrix is not connected, setting learninfFromConnectivity global variables.voidsetLernenIndices(int rowIndex1, Permutation cycle, int[][] a, int[] secondRow, int[] partition, int[] nonCanonicalIndices, boolean[] learningFromCanonicalTest)Setting the nonCanonicalIndices global variable.voidsetMultiThread(boolean multiThread)voidsetSetElement(boolean setElement)voidsetSymbols(List<String> symbolList)Setting the firstSymbols and symbols global variables for the initial sorted list of symbols.voidsetTsvoutput(boolean tsvoutput)voidsetVerbose(boolean verbose)voidsetYZValues(int[] initialPartition, int[][] ys, int[][] zs)Setting the y and z values for each block.voidsingleAtomCheck(String[] atoms)voidsingleAtomCheckLengthIsBiggerThanOne(String[] atoms)voidsort(List<String> symbols, Set<Map.Entry<String,Integer>> set)voidsortAscending(List<String> symbols)The initializer function, reading the formula to set the degrees, partition and file directory variables.int[]sortWithPartition(int[] partitionList, int[] degrees, String[] symbols, int[] hydrogens)Sort arrays with partitions.voidstructureGenerator(String localFormula)After the hydrogen distribution, calling the structure generator functions.int[]successor(int[] indices, int localSize)Calculation of the next index pair in a matrix.intsum(int[] array)Summing entries of an array.intsum(int[] list, int index)Summing entries of a list until a given index.voidswap(int[] array, int i, int j)voidswap(String[] array, int i, int j)int[]upperIndex(int index, int nextRowIndex, int[][] a, Permutation permutation)We need to calculate upperIndex.voidupperTriangularC(int[] degrees, int[][][] max, int[][][] c)c; upper triangular matrix like given in 3.2.1.voidupperTriangularL(int[] degrees, int[][][] max, int[][][] l)l; upper triangular matrix like given in 3.2.1.String[]validateFormula(String formula)String[]validateFuzzyFormula(String formula)voidwriteSingleAtom(int[] hydrogens)Writing the single atom molecule in a output file.Set<Integer>wValues(Set<Integer> nValues, int[] kFormer)Finding the W values of neighbors in the former connectivity partition.booleanzero(int[] array)For a row given by index, checking whether it is in maximal form or not.
-
-
-
Field Detail
-
NOOP_CONSUMER
public static final Maygen.Consumer NOOP_CONSUMER
-
-
Constructor Detail
-
Maygen
public Maygen(IChemObjectBuilder builder)
-
-
Method Detail
-
getSize
public int getSize()
-
isBoundary
public boolean isBoundary()
-
setBoundary
public void setBoundary(boolean boundary)
-
setConsumer
public void setConsumer(Maygen.Consumer consumer)
-
getConsumer
public Maygen.Consumer getConsumer()
-
isSetElement
public boolean isSetElement()
-
setSetElement
public void setSetElement(boolean setElement)
-
isTsvoutput
public boolean isTsvoutput()
-
setTsvoutput
public void setTsvoutput(boolean tsvoutput)
-
getSymbolArray
public String[] getSymbolArray()
-
getBuilder
public IChemObjectBuilder getBuilder()
-
isMultiThread
public boolean isMultiThread()
-
setMultiThread
public void setMultiThread(boolean multiThread)
-
getCount
public int getCount()
-
getFuzzyCount
public int getFuzzyCount()
-
getFormula
public String getFormula()
-
setFormula
public void setFormula(String formula)
-
getFuzzyFormula
public String getFuzzyFormula()
-
setFuzzyFormula
public void setFuzzyFormula(String fuzzyFormula)
-
getTotal
public int getTotal()
-
getOccurrences
public int[] getOccurrences()
-
getOxygenSulfur
public List<int[]> getOxygenSulfur()
-
getTotalHydrogen
public int getTotalHydrogen()
-
isOnSm
public boolean isOnSm()
-
getVerbose
public boolean getVerbose()
-
setVerbose
public void setVerbose(boolean verbose)
-
permuteArray
public int[] permuteArray(int[] array, int i, int j)Permuting two entries of an Integer array.- Parameters:
array- Integer[] arrayi- int first indexj- int second index- Returns:
- int[]
-
sum
public int sum(int[] array)
Summing entries of an array.- Parameters:
array- int[]- Returns:
- int sum
-
sum
public int sum(int[] list, int index)Summing entries of a list until a given index.- Parameters:
list- the int arrayindex- the index- Returns:
- int sum
-
atomOccurrence
public int atomOccurrence(String[] info)
Getting the number of atoms' occurrences.- Parameters:
info- String[] atom info- Returns:
- int
-
actArray
public int[] actArray(int[] array, Permutation permutation)Performing the permutation action on an int array.- Parameters:
array- int[] arraypermutation- Permutation permutation- Returns:
- int[]
-
idValues
public int[] idValues(int localSize)
Values for an id permutation for a given localSize- Parameters:
localSize- int permutation localSize- Returns:
- int[]
-
idPermutation
public Permutation idPermutation(int localSize)
Builds id permutation.- Parameters:
localSize- int Permutation localSize- Returns:
- Permutation
-
sortAscending
public void sortAscending(List<String> symbols)
The initializer function, reading the formula to set the degrees, partition and file directory variables.- Parameters:
symbols- the symbols
-
singleAtomCheck
public void singleAtomCheck(String[] atoms)
-
singleAtomCheckLengthIsBiggerThanOne
public void singleAtomCheckLengthIsBiggerThanOne(String[] atoms)
-
checkOxygenSulfur
public void checkOxygenSulfur(String[] atoms)
-
getSingleAtomVariables
public void getSingleAtomVariables(String localFormula)
-
getSymbolOccurrences
public void getSymbolOccurrences(String localFormula)
Getting the symbol occurrences from the input local formula.- Parameters:
localFormula- String molecular formula
-
getHydrogensInfoLengthIsOne
public int getHydrogensInfoLengthIsOne(List<String> symbolList, String[] info, int hydrogens)
-
nextCount
public int[] nextCount(int index, int i, int localSize, List<String> symbols, int[] partition)
-
getPartition
public int[] getPartition(List<String> symbols)
Getting the partition of symbols- Parameters:
symbols- the list of symbols- Returns:
- int[]
-
setSymbols
public void setSymbols(List<String> symbolList)
Setting the firstSymbols and symbols global variables for the initial sorted list of symbols.- Parameters:
symbolList- the sorted list of atom symbols
-
canBuildIsomer
public boolean canBuildIsomer(String formula)
Checking whether a molecular formula can represent a graph or not.For a graph with n nodes, the sum of all its node degrees should be equal or bigger than 2*(n-1). Thus, the minimum number of nodes.
- Parameters:
formula- String molecular formula- Returns:
- boolean
-
canBuildIsomerSingle
public boolean canBuildIsomerSingle(String formula)
Checking whether a molecular formula can represent a graph or not. This is just for the case of molecular formulae with single heteroatoms.For a graph with n nodes, the sum of all its node degrees should be equal or bigger than 2*(n-1). Thus, the minimum number of nodes.
- Parameters:
formula- String molecular formula- Returns:
- boolean
-
initialDegrees
public void initialDegrees()
Initial degree arrays are set based on the molecular formula.
-
equalSetCheck
public boolean equalSetCheck(int[] array1, int[] array2, int[] partition)Checks two int[] arrays are equal with respect to an atom partition.- Parameters:
array1- int[] first arrayarray2- int[] second arraypartition- int[] atom partition- Returns:
- boolean
-
getBlocks
public int[] getBlocks(int[] array, int begin, int end)Getting a part of a int array specified by two entry indices- Parameters:
array- int[] arraybegin- int beginning indexend- int ending index- Returns:
- Integer[]
-
equalSetCheck2
public boolean equalSetCheck2(int[] partition, int[] array1, int[] array2)Checks two int[] arrays are equal with respect to an atom partition.- Parameters:
partition- int[] atom partitionarray1- int[] arrayarray2- int[] array- Returns:
- boolean
-
compareIndexwise
public boolean compareIndexwise(int[] array, int[] array2, int index1, int index2)Comparing two int arrays are equal or not for given range of entries.- Parameters:
array- int[] arrayarray2- int[] arrayindex1- int beginning indexindex2- int last index- Returns:
- boolean
-
equalRowsCheck
public boolean equalRowsCheck(int index, int[][] a, Permutation cycleTransposition, Permutation permutation)Comparing two arrays are equal. The second row's index and entries are permuted based on cycle transposition and given permutation.- Parameters:
index- int row indexa- int[][] adjacency matrixcycleTransposition- Permutation cycle transpositionpermutation- Permutation permutation- Returns:
- boolean
-
descendingSort
public int[] descendingSort(int[] array, int index0, int index1)Sorting entries of a subarray specified by indices.- Parameters:
array- int[] arrayindex0- int beginning indexindex1- int last index- Returns:
- int[]
-
descendingSortWithPartition
public int[] descendingSortWithPartition(int[] array, int[] partition)Sorting entries of a int array for a given atom partition.- Parameters:
array- int[] arraypartition- int[] atom partition- Returns:
- int[]
-
biggerCheck
public boolean biggerCheck(int index, int[] firstRow, int[] check, int[] partition)Checks two arrays in descending order. The second row is sorted in descending order just to check whether there is a possible permutations making the first row non-maximal.- Parameters:
index- int row indexfirstRow- int[] arraycheck- int[] arraypartition- int[] atom partition- Returns:
- boolean
-
setBiggest
public boolean setBiggest(int index, int[][] a, Permutation permutation, int[] partition)Checks whether there is a permutation making the row bigger in descending order.- Parameters:
index- int row indexa- int[][] adjacency matrixpermutation- Permutation permutationpartition- int[] atom partition- Returns:
- boolean
-
getLernenIndices
public void getLernenIndices(int index, int[][] a, List<Permutation> cycles, int[] partition, int[] nonCanonicalIndices, boolean[] learningFromCanonicalTest)Get indices from "learning from canonical test" method. Here, the entry makes the row non-canonical is detected. Its indices are set to nonCanonicalIndices global variables.- Parameters:
index- int row indexa- the adjacency matrixcycles- the list of cycle transpositionspartition- the atom partitionnonCanonicalIndices- the nonCanonicalIndiceslearningFromCanonicalTest- the learningFromCanonicalTest
-
setLernenIndices
public void setLernenIndices(int rowIndex1, Permutation cycle, int[][] a, int[] secondRow, int[] partition, int[] nonCanonicalIndices, boolean[] learningFromCanonicalTest)Setting the nonCanonicalIndices global variable.- Parameters:
rowIndex1- int first row indexcycle- Permutation cycle transpositiona- int[][] adjacency matrixsecondRow- int[] second rowpartition- int[] atom partitionnonCanonicalIndices- the nonCanonicalIndiceslearningFromCanonicalTest- the learningFromCanonicalTest
-
getNonCanonicalMakerPermutation
public Permutation getNonCanonicalMakerPermutation(int[] array, Permutation cycle, int[] partition)
Calculating the permutation, permuting the second row and making first row non maximal.- Parameters:
array- the arraycycle- the cyclepartition- the partition- Returns:
- the Permutation
-
zero
public boolean zero(int[] array)
For a row given by index, checking whether it is in maximal form or not. If not, the nonCanonicalIndices is set.- Parameters:
array- int[] array- Returns:
- boolean
-
rowDescendingTest
public boolean rowDescendingTest(int index, int[][] a, int[] partition, int[] nonCanonicalIndices, boolean[] learningFromCanonicalTest)The row descending test is the part of canonical test function.- Parameters:
index- int indexa- int[][] adjacency matrixpartition- int[] atom partitionnonCanonicalIndices- int[] the indices of the non canonical entrylearningFromCanonicalTest- boolean[] the boolean setting- Returns:
- boolean
-
getPermutedIndex
public int getPermutedIndex(Permutation permutation, int index)
By a given permutation, checking which entry is mapped to the index.- Parameters:
permutation- Permutation permutationindex- int entry index in the row- Returns:
- int
-
limit
public int[] limit(int index, int nextRowIndex, int[][] a, Permutation permutation)Looking for the upper limit where the original entry is smaller.- Parameters:
index- int row indexnextRowIndex- int index of the row to comparea- int[][] adjacency matrixpermutation- Permutation permutation from canonical test- Returns:
- int[]
-
lowerIndex
public int[] lowerIndex(int index, int nextRowIndex, int[][] a, Permutation permutation)Looking for the maximum index where the entry is not zero.- Parameters:
index- int row indexnextRowIndex- int index of the row to comparea- int[][] adjacency matrixpermutation- Permutation permutation from canonical test- Returns:
- int[]
-
upperIndex
public int[] upperIndex(int index, int nextRowIndex, int[][] a, Permutation permutation)We need to calculate upperIndex. First, we need our j index where the original row become smaller, then calculating the lower index. Based on these two values and the value of j in the permutation, we calculate our upper index.This upper index is used for the 'learning from canonical test' method.
- Parameters:
index- int row indexnextRowIndex- int index of the row to comparea- int[][] adjacency matrixpermutation- Permutation permutation from canonical test- Returns:
- int[]
-
maximalIndexWithNonZeroEntry
public int[] maximalIndexWithNonZeroEntry(int[][] a, int[] maximalIndices)In case if the index' entry is zero, updating the index with next index with non-zero entry.- Parameters:
a- int[][] adjacency matrixmaximalIndices- int[] maximal indices for canonical test- Returns:
- int[]
-
getTranspose
public int[] getTranspose(int[] indices)
For an index pair, getting its transpose.- Parameters:
indices- int[] indices- Returns:
- int[]
-
getMaximumPair
public int[] getMaximumPair(int[] a, int[] b)Between two index pairs, getting the bigger indices.- Parameters:
a- int[] indicesb- int[] indices- Returns:
- int[]
-
compare
public boolean compare(int[] array1, int[] array2, int index1, int index2)Comparing two arrays for specific range of entries, whether the first array is bigger than the second one or not.- Parameters:
array1- int[] first arrayarray2- int[] second arrayindex1- int beginning indexindex2- int last index- Returns:
- boolean
-
descendingOrderUpperMatrixCheck
public boolean descendingOrderUpperMatrixCheck(int index, int[] partition, int[] firstRow, int[] secondRow)Checks the first row is bigger than the second row just in the upper matrix.- Parameters:
index- int row indexpartition- int[] atom partitionfirstRow- int[] first rowsecondRow- int[] second row- Returns:
- boolean
-
descendingOrderCheck
public boolean descendingOrderCheck(int[] array, int f, int l)Checks subarray of specified range of entries, the array is descending order or not.- Parameters:
array- int[] arrayf- int first indexl- int last index- Returns:
- boolean
-
descendingOrderCheck
public boolean descendingOrderCheck(int[] partition, int[] array)Checks a int array is in descending order or not with respect to a given atom partition.- Parameters:
partition- int[] atom partitionarray- the int array- Returns:
- boolean
-
upperTriangularL
public void upperTriangularL(int[] degrees, int[][][] max, int[][][] l)l; upper triangular matrix like given in 3.2.1. For (i,j), after the index, giving the maximum line capacity.- Parameters:
degrees- the degreesmax- the maxl- the l
-
upperTriangularC
public void upperTriangularC(int[] degrees, int[][][] max, int[][][] c)c; upper triangular matrix like given in 3.2.1. For (i,j), after the index, giving the maximum column capacity.- Parameters:
degrees- int[] valencesmax- the maxc- the c
-
lsum
public int lsum(int i, int j, int[][][] max)Summing ith rows entries starting from the jth column.- Parameters:
i- int row indexj- int column indexmax- the max- Returns:
- the lsum
-
csum
public int csum(int i, int j, int[][][] max)Summing ith column entries starting from the jth row.- Parameters:
i- int column indexj- int row indexmax- the max- Returns:
- the csum
-
maximalMatrix
public void maximalMatrix(int[] degrees, int[][][] max)Possible maximal edge multiplicity for the atom pair (i,j).- Parameters:
degrees- the degreesmax- the max
-
checkJustH
public void checkJustH(int[][][] max, int i, int j, int di)
-
generate
public void generate(IAtomContainer ac, String[] symbolArrayCopy, int[] degreeList, int[] initialPartition, int[][] partitionList, int[] connectivityIndices, boolean[] learningFromConnectivity, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] hydrogens, int[] partSize, int[] r, int[] y, int[] z, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest) throws IOException, CloneNotSupportedException, CDKException
Initialization of global variables for the generate of structures for given degree list.- Parameters:
ac- the IAtomContainersymbolArrayCopy- the symbolArrayCopydegreeList- int[] valencesinitialPartition- the initial partitionpartitionList- the partitionListconnectivityIndices- the connectivityIndiceslearningFromConnectivity- the learningFromConnectivitynonCanonicalIndices- the nonCanonicalIndicesformerPermutations- the formerPermutationshydrogens- the hydrogenspartSize- the partSizer- the ry- the yz- the zys- the yszs- the zslearningFromCanonicalTest- the learningFromCanonicalTest- Throws:
IOException- in case of IOExceptionCDKException- in case of CDKExceptionCloneNotSupportedException- in case of CloneNotSupportedException
-
successor
public int[] successor(int[] indices, int localSize)Calculation of the next index pair in a matrix.- Parameters:
indices- int[] index pair.localSize- int row length.- Returns:
- int[]
-
predecessor
public int[] predecessor(int[] indices, int localSize)Calculation of the former index pair in a matrix.- Parameters:
indices- int[] index pair.localSize- int row length.- Returns:
- int[]
-
nextStep
public void nextStep(IAtomContainer ac, String[] symbolArrayCopy, int[][] a, int[] indices, int[] degrees, int[] initialPartition, int[][] partitionList, boolean[] callForward, int[] connectivityIndices, boolean[] learningFromConnectivity, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] hydrogens, int[] partSize, int[] r, int[] y, int[] z, int[][][] max, int[][][] l, int[][][] c, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest, boolean[] flag) throws IOException, CloneNotSupportedException, CDKException
Calling foward or backward function in a nextstep function.- Parameters:
ac- the IAtomContainersymbolArrayCopy- the symbolArrayCopya- the a matrixindices- the indicesdegrees- the degreesinitialPartition- the initial partitionpartitionList- the partitionListcallForward- the callForwardconnectivityIndices- the connectivityIndiceslearningFromConnectivity- the learningFromConnectivitynonCanonicalIndices- the nonCanonicalIndicesformerPermutations- the formerPermutationshydrogens- the hydrogenspartSize- the partSizer- the ry- the yz- the zmax- the maxl- the lc- the cys- the yszs- the zslearningFromCanonicalTest- the learningFromCanonicalTestflag- the flag- Throws:
IOException- in case of IOExceptionCDKException- in case of CDKExceptionCloneNotSupportedException- in case of CloneNotSupportedException
-
addHydrogens
public int[][] addHydrogens(int[][] a, int index, int[] hydrogens)After generating matrices, adding the hydrogen with respect to the pre-hydrogen distribution.- Parameters:
a- the adjacency matrixindex- int beginning index for the hydrogen settinghydrogens- the hydrogens- Returns:
- the adjacency matrix
-
findR
public void findR(int[] indices, int[] initialPartition, int[] r)Finding the R index of a block- Parameters:
indices- int[] entry indicesinitialPartition- int[] initial partitionr- int[] r
-
backwardCriteria
public boolean backwardCriteria(int x, int lInverse, int l)The criteria to decide which function is needed: forward or backward.- Parameters:
x- the value in the adjacency matrix a[i][j]lInverse- lInverse value of indices {i,j}l- the l parameter- Returns:
- the criteria
-
backward
public int[][] backward(int[][] a, int[] indices, int[] degrees, int[] initialPartition, boolean[] callForward, int[] r, int[][][] max, int[][][] l, int[][][] c, boolean[] flag)Backward step in the algorithm.- Parameters:
a- the adjacency matrixindices- the indicesdegrees- the degreesinitialPartition- the initial partitioncallForward- the callForwardr- the rmax- the maxl- the lc- the cflag- the flag- Returns:
- the int[][]
-
forward
public int[][] forward(IAtomContainer ac, String[] symbolArrayCopy, int[][] a, int[] indices, int[] degrees, int[] initialPartition, int[][] partitionList, boolean[] callForward, int[] connectivityIndices, boolean[] learningFromConnectivity, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] hydrogens, int[] partSize, int[] r, int[] y, int[] z, int[][][] max, int[][][] l, int[][][] c, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest) throws IOException, CloneNotSupportedException, CDKException
Setting successor indices entry if there is a possible filling.- Parameters:
ac- the IAtomContainersymbolArrayCopy- the symbolArrayCopya- the adjacency matrixindices- the entry indicesdegrees- the degreesinitialPartition- the initial partitionpartitionList- the partitionListcallForward- the callForwardconnectivityIndices- the connectivityIndiceslearningFromConnectivity- the learningFromConnectivitynonCanonicalIndices- the nonCanonicalIndicesformerPermutations- the formerPermutationshydrogens- the hydrogenspartSize- the partSizer- the ry- the yz- the zmax- the maxl- the lc- the cys- the yszs- the zslearningFromCanonicalTest- the learningFromCanonicalTest- Returns:
- int[][]
- Throws:
IOException- in case of IOExceptionCDKException- in case of CDKExceptionCloneNotSupportedException- in case of CloneNotSupportedException
-
forward
public int[][] forward(IAtomContainer ac, String[] symbolArrayCopy, int lInverse, int cInverse, int maximalX, int i, int j, int[][] a, int[] indices, int[] initialPartition, int[][] partitionList, boolean[] callForward, int[] connectivityIndices, boolean[] learningFromConnectivity, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] hydrogens, int[] partSize, int[] r, int[] y, int[] z, int[][][] max, int[][][] l, int[][][] c, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest) throws IOException, CloneNotSupportedException, CDKException
-
maximalEntry
public int maximalEntry(int min, int lInverse, int l, int cInverse, int c)Calculating the maximal entry for the indices.- Parameters:
min- int minimum of l, c amd maximal matrices for {i,j} indices.lInverse- int Linverse value of {i,j}l- int l value of {i,j}cInverse- int Cinverse value of {i,j}c- int c value of {i,j}- Returns:
- int max
-
lInverse
public int lInverse(int i, int j, int[][] a, int[] degrees)Calculating the sum of the entries in the ith row until the jth column.- Parameters:
i- int row indexj- int column indexa- the adjacency matrixdegrees- the degrees- Returns:
- int
-
cInverse
public int cInverse(int i, int j, int[][] a, int[] degrees)Calculating the sum of the entries in the jth column until the ith row.- Parameters:
i- int row indexj- int column indexa- the adjacency matrixdegrees- the degrees- Returns:
- int
-
getPartition
public int[] getPartition(int[] degrees)
Based on the new degrees and the former partition, getting the new atom partition.- Parameters:
degrees- int[] new atom valences- Returns:
- int[]
-
getSubPartition
public int[] getSubPartition(int[] degrees)
Calculating the sub partitions for a given group of degrees.- Parameters:
degrees- int[] valences- Returns:
- int[]
-
nextCount
public int[] nextCount(int index, int i, int localSize, int[] degrees, int[] partition)Counting the occurrence of a value in a degree.- Parameters:
index- the indexi- the ilocalSize- int numberdegrees- int[] valencespartition- int[] partition- Returns:
- int
-
checkLengthTwoFormula
public boolean checkLengthTwoFormula(String[] atoms)
checking whether a molecular formula is length 2 or not. The length is counted based on the number of isotopes.- Parameters:
atoms- String[] atom symbols- Returns:
- boolean
-
run
public void run() throws IOException, CDKException, CloneNotSupportedExceptionMain function to initialize the global variables and calling the generate function.- Throws:
IOException- in case of IOExceptionCloneNotSupportedException- in case of CloneNotSupportedExceptionCDKException- in case of CDKException
-
closeFilesAndDisplayStatistic
public void closeFilesAndDisplayStatistic(long startTime)
-
doRun
public void doRun(String localFormula) throws IOException, CDKException, CloneNotSupportedException
-
processRun
public void processRun(String normalizedLocalFormula, long startTime) throws IOException, CDKException, CloneNotSupportedException
-
processFormula
public void processFormula(String normalizedLocalFormula, long startTime) throws IOException, CDKException, CloneNotSupportedException
-
displayStatistic
public void displayStatistic(long startTime, String localFormula)
-
distributeHydrogens
public List<int[]> distributeHydrogens()
If there are hydrogens in the formula, calling the hydrogenDistributor. This is the pre-hydrogen distribution. Then, the new list of degrees is defined for each hydrogen distribution.- Returns:
- the list of integer array
-
fillDegreeListHindexIsTwo
public void fillDegreeListHindexIsTwo(List<int[]> degreeList, List<int[]> distributions)
-
setYZValues
public void setYZValues(int[] initialPartition, int[][] ys, int[][] zs)Setting the y and z values for each block. y is the beginning index and z is the last index of a block in the adjacency matrix.- Parameters:
initialPartition- the initial partitionys- the yszs- the zs
-
findY
public int findY(int r, int[] initialPartition)For a block index r, calculating its first row index.- Parameters:
r- int block indexinitialPartition- the initial partition- Returns:
- int
-
findZ
public int findZ(int r, int[] initialPartition)For a block index r, calculating its last row index.- Parameters:
r- int block indexinitialPartition- the initial partition- Returns:
- int
-
writeSingleAtom
public void writeSingleAtom(int[] hydrogens) throws IOException, CDKException, CloneNotSupportedExceptionWriting the single atom molecule in a output file.- Parameters:
hydrogens- int[] hydrogens- Throws:
IOException- in case of IOExceptionCDKException- in case of CDKExceptionCloneNotSupportedException- in case of CloneNotSupportedException
-
setHydrogens
public int[] setHydrogens(int[] degree)
Calling the generate function for each degree values after the hydrogen distribution.- Parameters:
degree- int[] degree- Returns:
- int[]
-
structureGenerator
public void structureGenerator(String localFormula)
After the hydrogen distribution, calling the structure generator functions.- Parameters:
localFormula- String localFormula
-
clearGlobals
public void clearGlobals()
For several calls of the run function, setting the global variables.
-
nValues
public Set<Integer> nValues(int index, int total, int[][] mat)
Finding the neighbors of a given index.- Parameters:
index- int row (atom) indextotal- int number of atoms.mat- the adjacency matrix- Returns:
- the nValues
-
wValues
public Set<Integer> wValues(Set<Integer> nValues, int[] kFormer)
Finding the W values of neighbors in the former connectivity partition.- Parameters:
nValues- the N valueskFormer- the K values of the former step- Returns:
- the wValues
-
kValues
public int[] kValues(int total, Set<Integer> wValues, int[] kFormer)Finding the connectivity partition, so the smallest index in the neighborhood.- Parameters:
total- the totalwValues- the wValueskFormer- the K values of the former step- Returns:
- int[]
-
initialKList
public int[] initialKList(int total)
Initializing the first connectivity partition.- Parameters:
total- int number of atoms.- Returns:
- int[]
-
connectivityTest
public boolean connectivityTest(int[][] mat, int[] connectivityIndices, boolean[] learningFromConnectivity)Test whether an adjacency matrix is connected or disconnected.- Parameters:
mat- int[][] adjacency matrixconnectivityIndices- the connectivityIndiceslearningFromConnectivity- the learningFromConnectivity- Returns:
- boolean
-
setLearningFromConnectivity
public void setLearningFromConnectivity(Set<Integer> zValues, int[] kValues, int[] connectivityIndices, boolean[] learningFromConnectivity)
If matrix is not connected, setting learninfFromConnectivity global variables.- Parameters:
zValues- the minimum index values of each atom's neighborhoods.kValues- the connectivity partitionconnectivityIndices- the connectivityIndiceslearningFromConnectivity- the learningFromConnectivity
-
minComponentIndex
public int minComponentIndex(Set<Integer> zValues, int[] kValues)
Getting the minimum component index. Here, components are compared based on their last indices and sizes.- Parameters:
zValues- the minimum index values of each atom's neighborhoods.kValues- the connectivity partition- Returns:
- int
-
findMaximalIndexInComponent
public int findMaximalIndexInComponent(int[] kValues, int value)Finding the maximal index in a component to compare with other components.- Parameters:
kValues- int[] connectivity partitionvalue- int minimum neighborhood index- Returns:
- int
-
allIs0
public boolean allIs0(int[] list)
Checks whether all the entries are equal to 0 or not.- Parameters:
list- int[]- Returns:
- boolean
-
indexYZ
public int indexYZ(int[] initialPartition, int[] r)Based on the molecules automorphisms, testing an adjacency matrix is canonical or not.- Parameters:
initialPartition- the initial partitionr- the r- Returns:
- int
-
canonicalTest
public boolean canonicalTest(int[][] a, int[] initialPartition, int[][] partitionList, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] partSize, int[] r, int[] y, int[] z, int[][] ys, int[][] zs, boolean[] learningFromCanonicalTest)
-
clearFormers
public void clearFormers(boolean check, int y, int[][] partitionList, List<ArrayList<Permutation>> formerPermutations)When an adjacency matrix is non-canonical, cleaning the formerPermutations and partitionList from the first row of the tested block.- Parameters:
check- boolean canonical test resulty- int first row of the tested blockpartitionList- the partitionListformerPermutations- the formerPermutations
-
candidatePermutations
public void candidatePermutations(int index, List<Permutation> cycles, List<ArrayList<Permutation>> formerPermutations)Calculating all candidate permutations for row canonical test.The DFS multiplication of former automorphisms list with the list of cycle transpositions of the row.
- Parameters:
index- int row indexcycles- the cycle transpositionsformerPermutations- the formerPermutations
-
rowCanonicalTest
public boolean rowCanonicalTest(int index, int[] r, int[][] a, int[] partition, int[] newPartition, int[] initialPartition, int[][] partitionList, int[] nonCanonicalIndices, List<ArrayList<Permutation>> formerPermutations, int[] y, int[][] ys, boolean[] learningFromCanonicalTest)Canonical test for a row in the tested block.- Parameters:
index- int row indexr- int block indexa- int[][] adjacency matrixpartition- int[] former partitionnewPartition- int[] canonical partitioninitialPartition- the initial partitionpartitionList- the partitionListnonCanonicalIndices- the nonCanonicalIndicesformerPermutations- the formerPermutationsy- the yys- the yslearningFromCanonicalTest- the learningFromCanonicalTest- Returns:
- boolean
-
addPartition
public void addPartition(int index, int[] newPartition, int[][] a, int[][] partitionList)Updating canonical partition list.- Parameters:
index- row indexnewPartition- atom partitiona- int[][] adjacency matrixpartitionList- the partitionList
-
refinedPartitioning
public int[] refinedPartitioning(int[] partition, int[] row)Refining the input partition based on the row entries.- Parameters:
partition- int[] atom partitionrow- int[] row- Returns:
- int[]
-
row2compare
public int[] row2compare(int index, int[][] a, Permutation cycleTransposition)For a row given by index, detecting the other row to compare in the block. For the detection of the next row index, cycle transposition is used.- Parameters:
index- int row indexa- int[][] adjacency matrixcycleTransposition- Permutation cycle transposition- Returns:
- int[]
-
findIndex
public int findIndex(int index, Permutation cycle)With the cycle permutation, mapping the row index to another row in the block.- Parameters:
index- int row indexcycle- Permutation cycle transposition- Returns:
- int
-
cloneArray
public int[] cloneArray(int[] array)
Cloning int array- Parameters:
array- int[] array- Returns:
- int[]
-
getCanonicalPermutation
public Permutation getCanonicalPermutation(int[] originalRow, int[] rowToCheck, int[] partition)
Calculating the canonical permutation of a row.In a block, the original and the other rows are compared; if there is a permutation mapping rows to each other, canonical permutation, else id permutation is returned.
- Parameters:
originalRow- int[] original rowrowToCheck- int[] row to compare withpartition- int[] partition- Returns:
- Permutation
-
getCanonicalPermutation2
public int[] getCanonicalPermutation2(int[] partition, int[] max, int[] check)Calculating the canonical permutation of a row.In a block, the original and the other rows are compared; if there is a permutation mapping rows to each other, canonical permutation, else id permutation is returned.
- Parameters:
partition- int[] partitionmax- int[] maxcheck- int[] check- Returns:
- int[]
-
getCyclesList
public int[] getCyclesList(int[] max, int[] non, int index, int[] values)For maximal and tested rows, getting the cycle lists- Parameters:
max- int[] maximal rownon- int[] non maximal row to testindex- int row indexvalues- int[] values- Returns:
- int[]
-
findMatch
public int findMatch(int[] max, int[] non, int value, int start)Find the matching entries index in compared two rows.- Parameters:
max- int[] maxnon- int[] nonvalue- int valuestart- int start- Returns:
- int
-
getEqualPerm
public Permutation getEqualPerm(Permutation cycleTransposition, int index, int[][] a, int[] newPartition)
Getting the permutation making two rows identical.- Parameters:
cycleTransposition- Permutation cycle transpositionindex- int row indexa- int[][] adjacency matricesnewPartition- int[] refined atom partition- Returns:
- Permutation
-
getCanonicalCycle
public Permutation getCanonicalCycle(int index, int total, int[][] a, int[] newPartition, Permutation cycleTransposition)
Getting the canonical cycle of a row.- Parameters:
index- int row indextotal- int matrix sizea- int[][] adjacency matricesnewPartition- int[] refined atom partitioncycleTransposition- Permutation cycle transposition- Returns:
- Permutation
-
check
public boolean check(int index, int total, int[][] a, int[] newPartition, List<ArrayList<Permutation>> formerPermutations)
-
cycleTranspositions
public List<Permutation> cycleTranspositions(int index, int[] partition)
Getting the list of cycle transpositions for a given atom partition and the row index- Parameters:
index- int row indexpartition- int[] atom partition- Returns:
- the list of permutations
-
lValue
public int lValue(int[] partEx, int degree)To calculate the number of conjugacy classes, used in cycle transposition calculation.- Parameters:
partEx- int[] former atom partitiondegree- the degree- Returns:
- the LValue
-
canonicalPartition
public int[] canonicalPartition(int i, int[] partition)To get the canonical partition.- Parameters:
i- int row indexpartition- int[] partition- Returns:
- int[]
-
addOnes
public void addOnes(int[] list, int number)Add number of 1s into an ArrayList- Parameters:
list- the integer arraynumber- the number
-
findZeros
public int findZeros(int[] array)
-
partitionCriteria
public int[] partitionCriteria(int[] partEx, int degree)Partitioning criteria- Parameters:
partEx- the former partitiondegree- degree of the partitioning.- Returns:
- the partition criteria
-
orderDegreeSymbols
public void orderDegreeSymbols(int[] degree, String[] symbol, int index0, int index1, int[] hydrogens)Ordering degrees, hydrogens and symbols in ascending order- Parameters:
degree- int[] atom valencessymbol- String[] atom symbolsindex0- int first indexindex1- int second indexhydrogens- int[] hydrogens array
-
swap
public void swap(String[] array, int i, int j)
-
swap
public void swap(int[] array, int i, int j)
-
sortWithPartition
public int[] sortWithPartition(int[] partitionList, int[] degrees, String[] symbols, int[] hydrogens)Sort arrays with partitions.- Parameters:
partitionList- int[] atom partitiondegrees- int[] atom valencessymbols- String[] atom symbolshydrogens- int[] hydrogens- Returns:
- int array
-
initialPartition
public int[] initialPartition(int[] partition)
Initial atom partition of the input molecular formula- Parameters:
partition- int[] atom partition- Returns:
- int[]
-
buildArray
public int[] buildArray(int[] partition)
Building the copy of the partition array- Parameters:
partition- int[] atom partition- Returns:
- int[]
-
reOrder
public void reOrder(int[] partition, int[] degrees, String[] symbols, int[] hydrogens)Re-order all the global variables based on the refined new partitioning.- Parameters:
partition- int[] atom partitiondegrees- int[] atom valencessymbols- String[] atom symbolshydrogens- int[] hydrogens
-
getFuzzyFormulaRanges
public Map<String,Integer[]> getFuzzyFormulaRanges(String localFormula, List<String> symbolList)
To get the fuzzy formula ranges for each element type in the molecular formula- Parameters:
localFormula- String molecular localFormulasymbolList- the symbol list- Returns:
- the map of string ant integer array
-
getFuzzyFormulaRangesWithNewElements
public Map<String,Integer[]> getFuzzyFormulaRangesWithNewElements(String localFormula, List<String> symbolList)
-
generateFormulae
public void generateFormulae(List<String> result, List<String> symbolList, Map<String,Integer[]> symbols, String localFormula, int index)
Formulae generator for each element ranges- Parameters:
result- the list of stringsymbolList- list of stringsymbols- the symbols maplocalFormula- String localFormulaindex- int index
-
extendFormula
public String extendFormula(String localFormula, int number, String symbol)
Adding new entry to the new molecular formula- Parameters:
localFormula- String localFormulanumber- int numbersymbol- String symbol- Returns:
- String
-
getFormulaList
public List<String> getFormulaList(String normalizedLocalFuzzyFormula)
Generating list of formulae for the input fuzzy formula- Parameters:
normalizedLocalFuzzyFormula- String normalizedLocalFuzzyFormula- Returns:
- the list of string
-
emit
public void emit(IAtomContainer mol) throws CDKException, IOException
Emits a molecule to whomever is listening.- Parameters:
mol- molecule to emit- Throws:
CDKException- a CDK exception occurredIOException- an IO exception occurred
-
initSingleAC
public void initSingleAC()
Setting the initial atom container of a molecular formula with a single heavy atom
-
intAC
public void intAC(String formula)
Setting the initial atom container of a molecular formula- Parameters:
formula- the formula
-
initAC
public IAtomContainer initAC(IAtomContainer ac, String[] symbolArrayCopy)
Building an atom container from a string of atom-implicit hydrogen information.- Parameters:
ac- IAtomContainer IAtomContainersymbolArrayCopy- String[] symbol array of atoms- Returns:
- IAtomContainer
-
initAC
public void initAC(String symbol)
Building an atom container from a string of atom-implicit hydrogen information.- Parameters:
symbol- String symbol
-
buildAtomContainerFromMatrix
public IAtomContainer buildAtomContainerFromMatrix(int[][] mat, IAtomContainer atomContainer)
Building an atom container for an adjacency matrix.- Parameters:
mat- int[][] adjacency matrixatomContainer- IAtomContainer atomContainer- Returns:
- IAtomContainer
-
buildContainer4SDF
public IAtomContainer buildContainer4SDF(IAtomContainer ac, int[][] mat) throws CloneNotSupportedException
Building an atom container for an adjacency matrix.- Parameters:
ac- IAtomContainer IAtomContainermat- int[][] adjacency matrix- Returns:
- IAtomContainer
- Throws:
CloneNotSupportedException- in case of CloneNotSupportedException
-
buildContainer4SDF
public IAtomContainer buildContainer4SDF(int[][] mat) throws CloneNotSupportedException
Building an atom container for an adjacency matrix.- Parameters:
mat- int[][] adjacency matrix- Returns:
- IAtomContainer
- Throws:
CloneNotSupportedException- in case of CloneNotSupportedException
-
buildContainer4SDF
public IAtomContainer buildContainer4SDF(String[] symbols) throws CloneNotSupportedException
Building an atom container for SDF output from its symbols- Parameters:
symbols- String[] atom symbols- Returns:
- IAtomContainer
- Throws:
CloneNotSupportedException- in case of CloneNotSupportedException
-
generateOnSmMat
public int[][] generateOnSmMat()
Building an OnSm molecule for a given total number of atoms.- Returns:
- int[][]
-
degree2graph
public void degree2graph() throws IOException, CDKException, CloneNotSupportedExceptionBuilding a degree 2 graph for a single element type.- Throws:
IOException- in case of IOExceptionCDKException- in case of CDKExceptionCloneNotSupportedException- in case of CloneNotSupportedException
-
getHigherValences
public void getHigherValences(String localFormula)
Reading the molecular formula and setting the higher valences.- Parameters:
localFormula- String formula
-
reverseComparison
public int reverseComparison(int length, int index)The function to compare a node labelling array when the number of left consecutive entries is equal to the right consecutive entries.From this comparison, function returns :
1: if node labelling is same as its reversal.
0: if node labelling is smaller than its reversal.
-1: if node labelling is bigger than its reversal.
Reversal check helps to avoid duplicates, easy way of rotational symmetry check.
- Parameters:
length- int node labelling lengthindex- int starting index in the array- Returns:
- the result
-
buildSymbolArray
public String[] buildSymbolArray()
-
distributeSymbols
public void distributeSymbols(int oxy, int sul, int nextSize, int currentSize, int reversedLength, int leftEquivalents, int rightEquivalents, boolean reversalIsSmaller) throws CDKException, CloneNotSupportedException, IOExceptionMain function for the distribution of atom symbols: O and S for OnSm form formulae.- Parameters:
oxy- int number of oxygens to distributesul- int number of sulfur to distributenextSize- int length of the next labellingcurrentSize- int length of the current labellingreversedLength- int longest node labelling, equal to its reversalleftEquivalents- int the number of consequtively equivalent values at the left side of the arrayrightEquivalents- int the number of consequtively equivalent values at the left side of the arrayreversalIsSmaller- boolean from the reversal comparison, using the boolean variable to know reveral is smaller than the bode labelling or not.- Throws:
CloneNotSupportedException- in case of CloneNotSupportedExceptionCDKException- in case of CDKExceptionIOException- in case of IOException
-
runDistributeSymbolsCheckNodeLabels
public void runDistributeSymbolsCheckNodeLabels(int oxy, int sul, int nextSize, int currentSize, int reversedLength, int leftEquivalents, boolean reversalIsSmaller) throws CDKException, CloneNotSupportedException, IOException
-
runDistributeSymbols
public void runDistributeSymbols(int nextSize, int currentSize, int reversedLength, int leftEquivalents, int rightEquivalents, boolean reversalIsSmaller, int oxy2, int sul2, int reverse) throws CDKException, CloneNotSupportedException, IOException
-
distributeSymbolsNextSizeAboveGraphSize
public void distributeSymbolsNextSizeAboveGraphSize(int currentSize, boolean reversalIsSmaller) throws CloneNotSupportedException, CDKException, IOException
-
isReversalIsSmaller
public boolean isReversalIsSmaller(int nextSize, int reversedLength, boolean reversalIsSmaller)
-
distributeSulfurOxygen
public void distributeSulfurOxygen(String localFormula) throws CDKException, CloneNotSupportedException, IOException
-
-