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 a Maygen.Consumer instance, 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 <mehmetazizyirik@outlook.com> <0000-0001-7520-7215@orcid.org>
Belongs to CDK module:
structgen
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Maygen.Consumer
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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.
    void
    addOnes(int[] list, int number)
    Add number of 1s into an ArrayList
    void
    addPartition(int index, int[] newPartition, int[][] a, int[][] partitionList)
    Updating canonical partition list.
    boolean
    allIs0(int[] list)
    Checks whether all the entries are equal to 0 or not.
    int
    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.
    boolean
    backwardCriteria(int x, int lInverse, int l)
    The criteria to decide which function is needed: forward or backward.
    boolean
    biggerCheck(int index, int[] firstRow, int[] check, int[] partition)
    Checks two arrays in descending order.
    int[]
    buildArray(int[] partition)
    Building the copy of the partition array
    buildAtomContainerFromMatrix(int[][] mat, IAtomContainer atomContainer)
    Building an atom container for an adjacency matrix.
    buildContainer4SDF(int[][] mat)
    Building an atom container for an adjacency matrix.
    Building an atom container for SDF output from its symbols
    Building an atom container for an adjacency matrix.
     
    boolean
    Checking whether a molecular formula can represent a graph or not.
    boolean
    Checking whether a molecular formula can represent a graph or not.
    void
    candidatePermutations(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.
    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)
     
    boolean
    check(int index, int total, int[][] a, int[] newPartition, List<ArrayList<Permutation>> formerPermutations)
     
    void
    checkJustH(int[][][] max, int i, int j, int di)
     
    boolean
    checking whether a molecular formula is length 2 or not.
    void
     
    int
    cInverse(int i, int j, int[][] a, int[] degrees)
    Calculating the sum of the entries in the jth column until the ith row.
    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.
    void
    For several calls of the run function, setting the global variables.
    int[]
    cloneArray(int[] array)
    Cloning int array
    void
     
    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.
    boolean
    compareIndexwise(int[] array, int[] array2, int index1, int index2)
    Comparing two int arrays are equal or not for given range of entries.
    boolean
    connectivityTest(int[][] mat, int[] connectivityIndices, boolean[] learningFromConnectivity)
    Test whether an adjacency matrix is connected or disconnected.
    int
    csum(int i, int j, int[][][] max)
    Summing ith column entries starting from the jth row.
    cycleTranspositions(int index, int[] partition)
    Getting the list of cycle transpositions for a given atom partition and the row index
    void
    Building a degree 2 graph for a single element type.
    boolean
    descendingOrderCheck(int[] partition, int[] array)
    Checks a int array is in descending order or not with respect to a given atom partition.
    boolean
    descendingOrderCheck(int[] array, int f, int l)
    Checks subarray of specified range of entries, the array is descending order or not.
    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.
    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.
    void
    displayStatistic(long startTime, String localFormula)
     
    List<int[]>
    If there are hydrogens in the formula, calling the hydrogenDistributor.
    void
     
    void
    distributeSymbols(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.
    void
    distributeSymbolsNextSizeAboveGraphSize(int currentSize, boolean reversalIsSmaller)
     
    void
    doRun(String localFormula)
     
    void
    Emits a molecule to whomever is listening.
    boolean
    equalRowsCheck(int index, int[][] a, Permutation cycleTransposition, Permutation permutation)
    Comparing two arrays are equal.
    boolean
    equalSetCheck(int[] array1, int[] array2, int[] partition)
    Checks two int[] arrays are equal with respect to an atom partition.
    boolean
    equalSetCheck2(int[] partition, int[] array1, int[] array2)
    Checks two int[] arrays are equal with respect to an atom partition.
    extendFormula(String localFormula, int number, String symbol)
    Adding new entry to the new molecular formula
    void
    fillDegreeListHindexIsTwo(List<int[]> degreeList, List<int[]> distributions)
     
    int
    findIndex(int index, Permutation cycle)
    With the cycle permutation, mapping the row index to another row in the block.
    int
    findMatch(int[] max, int[] non, int value, int start)
    Find the matching entries index in compared two rows.
    int
    findMaximalIndexInComponent(int[] kValues, int value)
    Finding the maximal index in a component to compare with other components.
    void
    findR(int[] indices, int[] initialPartition, int[] r)
    Finding the R index of a block
    int
    findY(int r, int[] initialPartition)
    For a block index r, calculating its first row index.
    int
    findZ(int r, int[] initialPartition)
    For a block index r, calculating its last row index.
    int
    findZeros(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)
     
    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)
    Initialization of global variables for the generate of structures for given degree list.
    void
    generateFormulae(List<String> result, List<String> symbolList, Map<String,Integer[]> symbols, String localFormula, int index)
    Formulae generator for each element ranges
    int[][]
    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 indices
     
    getCanonicalCycle(int index, int total, int[][] a, int[] newPartition, Permutation cycleTransposition)
    Getting the canonical cycle of a row.
    getCanonicalPermutation(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.
     
    int
     
    int[]
    getCyclesList(int[] max, int[] non, int index, int[] values)
    For maximal and tested rows, getting the cycle lists
    getEqualPerm(Permutation cycleTransposition, int index, int[][] a, int[] newPartition)
    Getting the permutation making two rows identical.
     
    getFormulaList(String normalizedLocalFuzzyFormula)
    Generating list of formulae for the input fuzzy formula
    int
     
     
    getFuzzyFormulaRanges(String localFormula, List<String> symbolList)
    To get the fuzzy formula ranges for each element type in the molecular formula
     
    void
    getHigherValences(String localFormula)
    Reading the molecular formula and setting the higher valences.
    int
    getHydrogensInfoLengthIsOne(List<String> symbolList, String[] info, int hydrogens)
     
    void
    getLernenIndices(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.
    getNonCanonicalMakerPermutation(int[] array, Permutation cycle, int[] partition)
    Calculating the permutation, permuting the second row and making first row non maximal.
    int[]
     
    List<int[]>
     
    int[]
    getPartition(int[] degrees)
    Based on the new degrees and the former partition, getting the new atom partition.
    int[]
    Getting the partition of symbols
    int
    getPermutedIndex(Permutation permutation, int index)
    By a given permutation, checking which entry is mapped to the index.
    void
     
    int
     
    int[]
    getSubPartition(int[] degrees)
    Calculating the sub partitions for a given group of degrees.
    getSymbol(String[] info, Integer[] n)
     
     
    void
    Getting the symbol occurrences from the input local formula.
     
    int
     
    int
     
    int[]
    getTranspose(int[] indices)
    For an index pair, getting its transpose.
    boolean
     
    idPermutation(int localSize)
    Builds id permutation.
    int[]
    idValues(int localSize)
    Values for an id permutation for a given localSize
    int
    indexYZ(int[] initialPartition, int[] r)
    Based on the molecules automorphisms, testing an adjacency matrix is canonical or not.
    void
    initAC(String symbol)
    Building an atom container from a string of atom-implicit hydrogen information.
    initAC(IAtomContainer ac, String[] symbolArrayCopy)
    Building an atom container from a string of atom-implicit hydrogen information.
    void
    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 formula
    void
    Setting the initial atom container of a molecular formula with a single heavy atom
    void
    intAC(String formula)
    Setting the initial atom container of a molecular formula
    boolean
     
    boolean
     
    boolean
     
    boolean
    isReversalIsSmaller(int nextSize, int reversedLength, boolean reversalIsSmaller)
     
    boolean
     
    boolean
     
    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.
    int
    lInverse(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.
    int
    lsum(int i, int j, int[][][] max)
    Summing ith rows entries starting from the jth column.
    int
    lValue(int[] partEx, int degree)
    To calculate the number of conjugacy classes, used in cycle transposition calculation.
    int
    maximalEntry(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.
    void
    maximalMatrix(int[] degrees, int[][][] max)
    Possible maximal edge multiplicity for the atom pair (i,j).
    int
    minComponentIndex(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)
     
    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)
    Calling foward or backward function in a nextstep function.
     
    nValues(int index, int total, int[][] mat)
    Finding the neighbors of a given index.
    void
    orderDegreeSymbols(int[] degree, String[] symbol, int index0, int index1, int[] hydrogens)
    Ordering degrees, hydrogens and symbols in ascending order
    int[]
    partitionCriteria(int[] partEx, int degree)
    Partitioning criteria
    int[]
    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.
    void
    processFormula(String normalizedLocalFormula, long startTime)
     
    void
    processRun(String normalizedLocalFormula, long startTime)
     
    int[]
    refinedPartitioning(int[] partition, int[] row)
    Refining the input partition based on the row entries.
    void
    reOrder(int[] partition, int[] degrees, String[] symbols, int[] hydrogens)
    Re-order all the global variables based on the refined new partitioning.
    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.
    int[]
    row2compare(int index, int[][] a, Permutation cycleTransposition)
    For a row given by index, detecting the other row to compare in the block.
    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.
    boolean
    rowDescendingTest(int index, int[][] a, int[] partition, int[] nonCanonicalIndices, boolean[] learningFromCanonicalTest)
    The row descending test is the part of canonical test function.
    void
    run()
    Main function to initialize the global variables and calling the generate function.
    void
    runDistributeSymbols(int nextSize, int currentSize, int reversedLength, int leftEquivalents, int rightEquivalents, boolean reversalIsSmaller, int oxy2, int sul2, int reverse)
     
    void
    runDistributeSymbolsCheckNodeLabels(int oxy, int sul, int nextSize, int currentSize, int reversedLength, int leftEquivalents, boolean reversalIsSmaller)
     
    boolean
    setBiggest(int index, int[][] a, Permutation permutation, int[] partition)
    Checks whether there is a permutation making the row bigger in descending order.
    void
    setBoundary(boolean boundary)
     
    void
     
    void
    setFormula(String formula)
     
    void
    setFuzzyFormula(String fuzzyFormula)
     
    int[]
    setHydrogens(int[] degree)
    Calling the generate function for each degree values after the hydrogen distribution.
    void
    setLearningFromConnectivity(Set<Integer> zValues, int[] kValues, int[] connectivityIndices, boolean[] learningFromConnectivity)
    If matrix is not connected, setting learninfFromConnectivity global variables.
    void
    setLernenIndices(int rowIndex1, Permutation cycle, int[][] a, int[] secondRow, int[] partition, int[] nonCanonicalIndices, boolean[] learningFromCanonicalTest)
    Setting the nonCanonicalIndices global variable.
    void
    setMultiThread(boolean multiThread)
     
    void
    setSetElement(boolean setElement)
     
    void
    setSymbols(List<String> symbolList)
    Setting the firstSymbols and symbols global variables for the initial sorted list of symbols.
    void
    setTsvoutput(boolean tsvoutput)
     
    void
    setVerbose(boolean verbose)
     
    void
    setYZValues(int[] initialPartition, int[][] ys, int[][] zs)
    Setting the y and z values for each block.
    void
     
    void
     
    void
     
    void
    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.
    void
    structureGenerator(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.
    int
    sum(int[] array)
    Summing entries of an array.
    int
    sum(int[] list, int index)
    Summing entries of a list until a given index.
    void
    swap(int[] array, int i, int j)
     
    void
    swap(String[] array, int i, int j)
     
    int[]
    upperIndex(int index, int nextRowIndex, int[][] a, Permutation permutation)
    We need to calculate upperIndex.
    void
    upperTriangularC(int[] degrees, int[][][] max, int[][][] c)
    c; upper triangular matrix like given in 3.2.1.
    void
    upperTriangularL(int[] degrees, int[][][] max, int[][][] l)
    l; upper triangular matrix like given in 3.2.1.
     
     
    void
    writeSingleAtom(int[] hydrogens)
    Writing the single atom molecule in a output file.
    wValues(Set<Integer> nValues, int[] kFormer)
    Finding the W values of neighbors in the former connectivity partition.
    boolean
    zero(int[] array)
    For a row given by index, checking whether it is in maximal form or not.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • 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()
    • getSymbols

      public List<String> getSymbols()
    • 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[] array
      i - int first index
      j - 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 array
      index - 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[] array
      permutation - 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
    • sort

      public void sort(List<String> symbols, Set<Map.Entry<String,Integer>> set)
    • 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
    • normalizeFormula

      public String normalizeFormula(String formula)
    • validateFormula

      public String[] validateFormula(String formula)
    • validateFuzzyFormula

      public String[] validateFuzzyFormula(String formula)
    • 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 array
      array2 - int[] second array
      partition - 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[] array
      begin - int beginning index
      end - 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 partition
      array1 - int[] array
      array2 - 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[] array
      array2 - int[] array
      index1 - int beginning index
      index2 - 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 index
      a - int[][] adjacency matrix
      cycleTransposition - Permutation cycle transposition
      permutation - 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[] array
      index0 - int beginning index
      index1 - 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[] array
      partition - 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 index
      firstRow - int[] array
      check - int[] array
      partition - 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 index
      a - int[][] adjacency matrix
      permutation - Permutation permutation
      partition - 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 index
      a - the adjacency matrix
      cycles - the list of cycle transpositions
      partition - the atom partition
      nonCanonicalIndices - the nonCanonicalIndices
      learningFromCanonicalTest - 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 index
      cycle - Permutation cycle transposition
      a - int[][] adjacency matrix
      secondRow - int[] second row
      partition - int[] atom partition
      nonCanonicalIndices - the nonCanonicalIndices
      learningFromCanonicalTest - 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 array
      cycle - the cycle
      partition - 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 index
      a - int[][] adjacency matrix
      partition - int[] atom partition
      nonCanonicalIndices - int[] the indices of the non canonical entry
      learningFromCanonicalTest - 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 permutation
      index - 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 index
      nextRowIndex - int index of the row to compare
      a - int[][] adjacency matrix
      permutation - 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 index
      nextRowIndex - int index of the row to compare
      a - int[][] adjacency matrix
      permutation - 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 index
      nextRowIndex - int index of the row to compare
      a - int[][] adjacency matrix
      permutation - 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 matrix
      maximalIndices - 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[] indices
      b - 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 array
      array2 - int[] second array
      index1 - int beginning index
      index2 - 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 index
      partition - int[] atom partition
      firstRow - int[] first row
      secondRow - 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[] array
      f - int first index
      l - 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 partition
      array - 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 degrees
      max - the max
      l - 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[] valences
      max - the max
      c - 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 index
      j - int column index
      max - 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 index
      j - int row index
      max - 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 degrees
      max - 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 IAtomContainer
      symbolArrayCopy - the symbolArrayCopy
      degreeList - int[] valences
      initialPartition - the initial partition
      partitionList - the partitionList
      connectivityIndices - the connectivityIndices
      learningFromConnectivity - the learningFromConnectivity
      nonCanonicalIndices - the nonCanonicalIndices
      formerPermutations - the formerPermutations
      hydrogens - the hydrogens
      partSize - the partSize
      r - the r
      y - the y
      z - the z
      ys - the ys
      zs - the zs
      learningFromCanonicalTest - the learningFromCanonicalTest
      Throws:
      IOException - in case of IOException
      CDKException - in case of CDKException
      CloneNotSupportedException - 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 IAtomContainer
      symbolArrayCopy - the symbolArrayCopy
      a - the a matrix
      indices - the indices
      degrees - the degrees
      initialPartition - the initial partition
      partitionList - the partitionList
      callForward - the callForward
      connectivityIndices - the connectivityIndices
      learningFromConnectivity - the learningFromConnectivity
      nonCanonicalIndices - the nonCanonicalIndices
      formerPermutations - the formerPermutations
      hydrogens - the hydrogens
      partSize - the partSize
      r - the r
      y - the y
      z - the z
      max - the max
      l - the l
      c - the c
      ys - the ys
      zs - the zs
      learningFromCanonicalTest - the learningFromCanonicalTest
      flag - the flag
      Throws:
      IOException - in case of IOException
      CDKException - in case of CDKException
      CloneNotSupportedException - 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 matrix
      index - int beginning index for the hydrogen setting
      hydrogens - 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 indices
      initialPartition - int[] initial partition
      r - 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 matrix
      indices - the indices
      degrees - the degrees
      initialPartition - the initial partition
      callForward - the callForward
      r - the r
      max - the max
      l - the l
      c - the c
      flag - 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 IAtomContainer
      symbolArrayCopy - the symbolArrayCopy
      a - the adjacency matrix
      indices - the entry indices
      degrees - the degrees
      initialPartition - the initial partition
      partitionList - the partitionList
      callForward - the callForward
      connectivityIndices - the connectivityIndices
      learningFromConnectivity - the learningFromConnectivity
      nonCanonicalIndices - the nonCanonicalIndices
      formerPermutations - the formerPermutations
      hydrogens - the hydrogens
      partSize - the partSize
      r - the r
      y - the y
      z - the z
      max - the max
      l - the l
      c - the c
      ys - the ys
      zs - the zs
      learningFromCanonicalTest - the learningFromCanonicalTest
      Returns:
      int[][]
      Throws:
      IOException - in case of IOException
      CDKException - in case of CDKException
      CloneNotSupportedException - 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
      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 index
      j - int column index
      a - the adjacency matrix
      degrees - 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 index
      j - int column index
      a - the adjacency matrix
      degrees - 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 index
      i - the i
      localSize - int number
      degrees - int[] valences
      partition - 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

      Main function to initialize the global variables and calling the generate function.
      Throws:
      IOException - in case of IOException
      CloneNotSupportedException - in case of CloneNotSupportedException
      CDKException - in case of CDKException
    • closeFilesAndDisplayStatistic

      public void closeFilesAndDisplayStatistic(long startTime)
    • doRun

      public void doRun(String localFormula) throws IOException, CDKException, CloneNotSupportedException
      Throws:
      IOException
      CDKException
      CloneNotSupportedException
    • processRun

      public void processRun(String normalizedLocalFormula, long startTime) throws IOException, CDKException, CloneNotSupportedException
      Throws:
      IOException
      CDKException
      CloneNotSupportedException
    • processFormula

      public void processFormula(String normalizedLocalFormula, long startTime) throws IOException, CDKException, CloneNotSupportedException
      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 partition
      ys - the ys
      zs - the zs
    • findY

      public int findY(int r, int[] initialPartition)
      For a block index r, calculating its first row index.
      Parameters:
      r - int block index
      initialPartition - 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 index
      initialPartition - the initial partition
      Returns:
      int
    • writeSingleAtom

      public void writeSingleAtom(int[] hydrogens) throws IOException, CDKException, CloneNotSupportedException
      Writing the single atom molecule in a output file.
      Parameters:
      hydrogens - int[] hydrogens
      Throws:
      IOException - in case of IOException
      CDKException - in case of CDKException
      CloneNotSupportedException - 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) index
      total - 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 values
      kFormer - 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 total
      wValues - the wValues
      kFormer - 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 matrix
      connectivityIndices - the connectivityIndices
      learningFromConnectivity - 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 partition
      connectivityIndices - the connectivityIndices
      learningFromConnectivity - 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 partition
      value - 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 partition
      r - 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 result
      y - int first row of the tested block
      partitionList - the partitionList
      formerPermutations - 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 index
      cycles - the cycle transpositions
      formerPermutations - 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 index
      r - int block index
      a - int[][] adjacency matrix
      partition - int[] former partition
      newPartition - int[] canonical partition
      initialPartition - the initial partition
      partitionList - the partitionList
      nonCanonicalIndices - the nonCanonicalIndices
      formerPermutations - the formerPermutations
      y - the y
      ys - the ys
      learningFromCanonicalTest - the learningFromCanonicalTest
      Returns:
      boolean
    • addPartition

      public void addPartition(int index, int[] newPartition, int[][] a, int[][] partitionList)
      Updating canonical partition list.
      Parameters:
      index - row index
      newPartition - atom partition
      a - int[][] adjacency matrix
      partitionList - the partitionList
    • refinedPartitioning

      public int[] refinedPartitioning(int[] partition, int[] row)
      Refining the input partition based on the row entries.
      Parameters:
      partition - int[] atom partition
      row - 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 index
      a - int[][] adjacency matrix
      cycleTransposition - 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 index
      cycle - 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 row
      rowToCheck - int[] row to compare with
      partition - 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[] partition
      max - int[] max
      check - 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 row
      non - int[] non maximal row to test
      index - int row index
      values - 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[] max
      non - int[] non
      value - int value
      start - 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 transposition
      index - int row index
      a - int[][] adjacency matrices
      newPartition - 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 index
      total - int matrix size
      a - int[][] adjacency matrices
      newPartition - int[] refined atom partition
      cycleTransposition - 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 index
      partition - 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 partition
      degree - the degree
      Returns:
      the LValue
    • canonicalPartition

      public int[] canonicalPartition(int i, int[] partition)
      To get the canonical partition.
      Parameters:
      i - int row index
      partition - int[] partition
      Returns:
      int[]
    • addOnes

      public void addOnes(int[] list, int number)
      Add number of 1s into an ArrayList
      Parameters:
      list - the integer array
      number - the number
    • findZeros

      public int findZeros(int[] array)
    • partitionCriteria

      public int[] partitionCriteria(int[] partEx, int degree)
      Partitioning criteria
      Parameters:
      partEx - the former partition
      degree - 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 valences
      symbol - String[] atom symbols
      index0 - int first index
      index1 - int second index
      hydrogens - 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 partition
      degrees - int[] atom valences
      symbols - String[] atom symbols
      hydrogens - 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 partition
      degrees - int[] atom valences
      symbols - String[] atom symbols
      hydrogens - 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 localFormula
      symbolList - the symbol list
      Returns:
      the map of string ant integer array
    • getFuzzyFormulaRangesWithNewElements

      public Map<String,Integer[]> getFuzzyFormulaRangesWithNewElements(String localFormula, List<String> symbolList)
    • getSymbol

      public String getSymbol(String[] info, Integer[] n)
    • 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 string
      symbolList - list of string
      symbols - the symbols map
      localFormula - String localFormula
      index - int index
    • extendFormula

      public String extendFormula(String localFormula, int number, String symbol)
      Adding new entry to the new molecular formula
      Parameters:
      localFormula - String localFormula
      number - int number
      symbol - 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 occurred
      IOException - 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 IAtomContainer
      symbolArrayCopy - 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 matrix
      atomContainer - 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 IAtomContainer
      mat - 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, CloneNotSupportedException
      Building a degree 2 graph for a single element type.
      Throws:
      IOException - in case of IOException
      CDKException - in case of CDKException
      CloneNotSupportedException - 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 length
      index - 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, IOException
      Main function for the distribution of atom symbols: O and S for OnSm form formulae.
      Parameters:
      oxy - int number of oxygens to distribute
      sul - int number of sulfur to distribute
      nextSize - int length of the next labelling
      currentSize - int length of the current labelling
      reversedLength - int longest node labelling, equal to its reversal
      leftEquivalents - int the number of consequtively equivalent values at the left side of the array
      rightEquivalents - int the number of consequtively equivalent values at the left side of the array
      reversalIsSmaller - 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 CloneNotSupportedException
      CDKException - in case of CDKException
      IOException - 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
      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
      Throws:
      CDKException
      CloneNotSupportedException
      IOException
    • distributeSymbolsNextSizeAboveGraphSize

      public void distributeSymbolsNextSizeAboveGraphSize(int currentSize, boolean reversalIsSmaller) throws CloneNotSupportedException, CDKException, IOException
      Throws:
      CloneNotSupportedException
      CDKException
      IOException
    • isReversalIsSmaller

      public boolean isReversalIsSmaller(int nextSize, int reversedLength, boolean reversalIsSmaller)
    • distributeSulfurOxygen

      public void distributeSulfurOxygen(String localFormula) throws CDKException, CloneNotSupportedException, IOException
      Throws:
      CDKException
      CloneNotSupportedException
      IOException