Skip to content

Commit 685fd41

Browse files
MORGEN with output sdf file
1 parent 70a6066 commit 685fd41

File tree

1 file changed

+10
-36
lines changed

1 file changed

+10
-36
lines changed

src/main/java/AlgorithmicGroupTheory/MORGEN.java

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import java.io.FileNotFoundException;
33
import java.io.FileWriter;
44
import java.io.IOException;
5-
import java.io.PrintWriter;
65
import java.io.UnsupportedEncodingException;
76
import java.text.DecimalFormat;
87
import java.util.ArrayList;
@@ -35,7 +34,6 @@
3534
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
3635

3736
public class MORGEN {
38-
public static PrintWriter pWriter;
3937
public static int size=0;
4038
public static int total=0;
4139
public static int[] ys;
@@ -995,7 +993,6 @@ public static void generate(int[] degreeList) throws IOException, CloneNotSuppor
995993
break;
996994
}
997995
if(learningFromConnectivity) {
998-
pWriter.println("connectivity"+" "+Arrays.toString(indices));
999996
indices=connectivityIndices;
1000997
findR(indices);
1001998
y=ys[r];
@@ -1004,7 +1001,6 @@ public static void generate(int[] degreeList) throws IOException, CloneNotSuppor
10041001
callForward=false;
10051002
}else {
10061003
if(learningFromCanonicalTest) {
1007-
pWriter.println("canonical"+" "+Arrays.toString(indices));
10081004
indices=successor(nonCanonicalIndices,max.length);
10091005
findR(indices);
10101006
learningFromCanonicalTest=false;
@@ -1087,18 +1083,12 @@ public static int[][] addHydrogens(int[][] A, int index){
10871083
int hIndex=index;
10881084
int limit=0;
10891085
int hydrogen=0;
1090-
int hydrogens=0;
1091-
outer:
10921086
for(int i=0;i<index;i++) {
10931087
hydrogen=initialDegrees[i]-sum(A[i]);
1094-
hydrogens+=hydrogen;
10951088
limit=hIndex+hydrogen;
10961089
for(int j=hIndex;j<limit;j++) {
10971090
A[i][j]=1;
10981091
A[j][i]=1;
1099-
if(hydrogens==totalHydrogen) {
1100-
break outer;
1101-
}
11021092
}
11031093
if(hydrogen!=0) {
11041094
hIndex=hIndex+hydrogen;
@@ -1236,23 +1226,11 @@ public static int[][] forward(int lInverse, int cInverse, int maximalX,int i, in
12361226
mat2[k][l]=A[k][l];
12371227
}
12381228
}
1239-
if(connectivityTest(mat2)){
1240-
count++;
1241-
pWriter.println("can"+" "+count);
1242-
for(int s=0;s<10;s++) {
1243-
for(int k=0; k<s;k++) {
1244-
pWriter.print(" ");
1245-
}
1246-
for(int k=s+1; k<10;k++) {
1247-
pWriter.print(mat2[s][k]);
1248-
}
1249-
pWriter.println();
1250-
}
1251-
pWriter.println();
1229+
if(connectivityTest(mat2)){
12521230
output.add(mat2);
1253-
//IAtomContainer mol= buildC(addHydrogens(mat2,hIndex));
1254-
//outFile.write(mol);
1255-
//count++;
1231+
IAtomContainer mol= buildC(addHydrogens(mat2,hIndex));
1232+
outFile.write(mol);
1233+
count++;
12561234
callForward=false;
12571235
}else {
12581236
callForward=false;
@@ -1445,15 +1423,11 @@ public static List<int[][]> run() throws IOException, CDKException, CloneNotSupp
14451423
if(verbose) System.out.println("MORGEN is generating isomers of "+formula+"...");
14461424
getSymbolsOccurrences(formula);
14471425
initialDegrees();
1448-
//build(formula);
1449-
//outFile = new SDFWriter(new FileWriter(filedir+"output.sdf"));
1450-
FileWriter fWriter = new FileWriter(filedir+"dene.txt");
1451-
pWriter= new PrintWriter(fWriter);
1452-
pWriter.println("List of "+formula+"'s isomers: ");
1426+
build(formula);
1427+
outFile = new SDFWriter(new FileWriter(filedir+"output.sdf"));
14531428
structureGenerator();
14541429
if(verbose) System.out.println("The number of structures is: "+count);
1455-
//outFile.close();
1456-
pWriter.close();
1430+
outFile.close();
14571431
long endTime = System.nanoTime() - startTime;
14581432
double seconds = (double) endTime / 1000000000.0;
14591433
DecimalFormat d = new DecimalFormat(".###");
@@ -1512,7 +1486,7 @@ public static List<int[]> distributeHydrogens() throws FileNotFoundException, Un
15121486
if(!callHydrogenDistributor) {
15131487
degreeList.add(firstDegrees);
15141488
}else {
1515-
List<int[]> distributions= HydrogenDistributor.run(firstOccurrences,firstDegrees);
1489+
List<int[]> distributions = HydrogenDistributor.run(firstOccurrences, firstDegrees);
15161490
for(int[] dist: distributions) {
15171491
int[] newDegree= new int[size];
15181492
for(int i=0;i<size;i++) {
@@ -2347,9 +2321,9 @@ private Options setupOptions(String[] args){
23472321

23482322
public static void main(String[] args) throws IOException, CDKException, CloneNotSupportedException {
23492323
MORGEN gen = new MORGEN();
2350-
String[] arg= {"-f", "C10", "-v", "-d", "C:\\Users\\mehme\\Desktop\\"};
2324+
//String[] arg= {"-f", "C6H6", "-v", "-d", "C:\\Users\\mehme\\Desktop\\"};
23512325
try {
2352-
gen.parseArgs(arg);
2326+
gen.parseArgs(args);
23532327
MORGEN.run();
23542328
} catch (Exception e) {
23552329
if (MORGEN.verbose) e.getCause();

0 commit comments

Comments
 (0)