	public static String mol2AdjList (String inchi, String filePath) {
        FileReader in = null;
		try {
			in = new FileReader(filePath);
		} catch (FileNotFoundException e) {
			String err = "Error reading .mol file: " + e.toString();
			System.out.println(err);
		}
		BufferedReader reader = new BufferedReader(in);
		String line = ChemParser.readMeaningfulLine(reader, true);
		while (!line.toUpperCase().endsWith("V2000")) {
			line = ChemParser.readMeaningfulLine(reader, true);
		}
		String molFile = "";
		while (line != null) {
			molFile += line + "\r";
			line = ChemParser.readMeaningfulLine(reader, true);
		}
		String[] molFileLines = molFile.split("[\r]",0);
		int numOfLines = molFileLines.length;
		StringTokenizer st = new StringTokenizer(molFileLines[numOfLines-1]);
		if (st.nextToken().equals("$$$$")) --numOfLines;
		st = new StringTokenizer(molFileLines[0]);
		int numOfAtoms = Integer.parseInt(st.nextToken());
		int numOfBonds = Integer.parseInt(st.nextToken());
		int numOfAtomLists = Integer.parseInt(st.nextToken());
		String obsoleteString1 = st.nextToken();
		String chiralFlag = st.nextToken();
		int stextEntries = Integer.parseInt(st.nextToken());
		String obsoleteString2 = st.nextToken();
		String obsoleteString3 = st.nextToken();
		String obsoleteString4 = st.nextToken();
		String obsoleteString5 = st.nextToken();
		int numOfMLines = Integer.parseInt(st.nextToken());
		String[] adjListElement = new String[numOfAtoms];
		String[] adjListRadical = new String[numOfAtoms];
		String[] adjListConnectivity = new String[numOfAtoms];
		for (int i=0; i<numOfAtoms; i++) {
			adjListConnectivity[i] = "";
			adjListRadical[i] = "0 ";
		}
		for (int i=1; i<numOfAtoms+1; i++) {
			st = new StringTokenizer(molFileLines[i]);
			double x_coord = Double.parseDouble(st.nextToken());
			double y_coord = Double.parseDouble(st.nextToken());
			double z_coord = Double.parseDouble(st.nextToken());
			adjListElement[i-1] = " " + st.nextToken() + " ";
			if (numOfAtoms == 1) {
				String totalLine = molFileLines[i];
				int length = totalLine.length();
				int valencyFlag = Integer.parseInt(totalLine.substring(length-15,length-12).trim());
				if (valencyFlag != 0) {
					if (valencyFlag == 1) {
						if (adjListElement[i-1].equals(" C ")) adjListRadical[i-1] = "3 ";
						else if (adjListElement[i-1].equals(" Si ")) adjListRadical[i-1] = "3 ";
						else if (adjListElement[i-1].equals(" N ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" O ")) adjListRadical[i-1] = "1 ";
						else if (adjListElement[i-1].equals(" S ")) adjListRadical[i-1] = "1 ";
					} else if (valencyFlag == 2) {
						if (adjListElement[i-1].equals(" C ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" Si ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" N ")) adjListRadical[i-1] = "1 ";
					} else if (valencyFlag == 3) {
						if (adjListElement[i-1].equals(" C ")) adjListRadical[i-1] = "1 ";
						else if (adjListElement[i-1].equals(" Si ")) adjListRadical[i-1] = "1 ";
					} else if (valencyFlag == 15) {
						if (adjListElement[i-1].equals(" C ")) adjListRadical[i-1] = "4 ";
						else if (adjListElement[i-1].equals(" Si ")) adjListRadical[i-1] = "4 ";
						else if (adjListElement[i-1].equals(" N ")) adjListRadical[i-1] = "3 ";
						else if (adjListElement[i-1].equals(" O ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" S ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" H ")) adjListRadical[i-1] = "1 ";
					}
				}
			}
		}
		int Counter = numOfAtoms+1;
		while (!molFileLines[Counter].startsWith("M")) {
			st = new StringTokenizer(molFileLines[Counter]);
			int atom1 = Integer.parseInt(st.nextToken());
			int atom2 = Integer.parseInt(st.nextToken());
			adjListConnectivity[atom1-1] += "{" + atom2;
			adjListConnectivity[atom2-1] += "{" + atom1;
			int connection = Integer.parseInt(st.nextToken());
			if (connection == 1) {
				adjListConnectivity[atom1-1] += ",S} ";
				adjListConnectivity[atom2-1] += ",S} ";
			} else if (connection == 2) {
				adjListConnectivity[atom1-1] += ",D} ";
				adjListConnectivity[atom2-1] += ",D} ";
			} else if (connection == 3) {
				adjListConnectivity[atom1-1] += ",T} ";
				adjListConnectivity[atom2-1] += ",T} ";
			} else if (connection == 4) {
				adjListConnectivity[atom1-1] += ",B} ";
				adjListConnectivity[atom2-1] += ",B} ";
			}
			++Counter;
		}
		for (int i=numOfLines-numOfMLines; i<numOfLines-1; i++) {
			st = new StringTokenizer(molFileLines[numOfLines-numOfMLines]);
			String M = st.nextToken();
			String RAD = st.nextToken();
                        if (RAD.equals("RAD")){
				int numOfRads = Integer.parseInt(st.nextToken());
				for (int j=0; j<numOfRads; j++) {
					int atom = Integer.parseInt(st.nextToken());
					int radType = Integer.parseInt(st.nextToken());
                                            if (radType == 1)
                                                    adjListRadical[atom-1] = "2S ";
                                            else if (radType == 2)
                                                    adjListRadical[atom-1] = "1 ";
                                            else if (radType== 3)
                                                    adjListRadical[atom-1] = "2T ";
                                            else
                                                    adjListRadical[atom-1] = "3 ";
				}
			}
			else {
				System.out.println("Ignoring unknown M flag " + RAD + " for " + inchi);
			}      
		}
		String adjList = "";
		for (int i=0; i<numOfAtoms-1; i++) {
			adjList += (i+1) + adjListElement[i] + adjListRadical[i] + adjListConnectivity[i] + "\r";
		}
		adjList += numOfAtoms + adjListElement[numOfAtoms-1] + adjListRadical[numOfAtoms-1] + adjListConnectivity[numOfAtoms-1];
		return adjList;
	}

	public static String mol2AdjList (String inchi, String filePath) {
        FileReader in = null;
		try {
			in = new FileReader(filePath);
		} catch (FileNotFoundException e) {
			String err = "Error reading .mol file: " + e.toString();
			System.out.println(err);
		}
		BufferedReader reader = new BufferedReader(in);
		String line = ChemParser.readMeaningfulLine(reader, true);
		while (!line.toUpperCase().endsWith("V2000")) {
			line = ChemParser.readMeaningfulLine(reader, false);
		}
		String molFile = "";
		while (line != null) {
			molFile += line + "\r";
			line = ChemParser.readMeaningfulLine(reader, true);
		}
		String[] molFileLines = molFile.split("[\r]",0);
		int numOfLines = molFileLines.length;
		StringTokenizer st = new StringTokenizer(molFileLines[numOfLines-1]);
		if (st.nextToken().equals("$$$$")) --numOfLines;
		st = new StringTokenizer(molFileLines[0]);
		int numOfAtoms = Integer.parseInt(molFileLines[0].substring(0,3).trim());
		int numOfBonds = Integer.parseInt(molFileLines[0].substring(3,6).trim());
		int numOfAtomLists = Integer.parseInt(molFileLines[0].substring(6,9).trim());
		String obsoleteString1 = molFileLines[0].substring(9,12);
		String chiralFlag = molFileLines[0].substring(12,15);
		int stextEntries = Integer.parseInt(molFileLines[0].substring(15,18).trim());
		String obsoleteString2 = molFileLines[0].substring(18,21);
		String obsoleteString3 = molFileLines[0].substring(21,24);
		String obsoleteString4 = molFileLines[0].substring(24,27);
		String obsoleteString5 = molFileLines[0].substring(27,30);
		int numOfMLines = Integer.parseInt(molFileLines[0].substring(30,33).trim());
		String[] adjListElement = new String[numOfAtoms];
		String[] adjListRadical = new String[numOfAtoms];
		String[] adjListConnectivity = new String[numOfAtoms];
		for (int i=0; i<numOfAtoms; i++) {
			adjListConnectivity[i] = "";
			adjListRadical[i] = "0 ";
		}
		for (int i=1; i<numOfAtoms+1; i++) {
			st = new StringTokenizer(molFileLines[i]);
			double x_coord = Double.parseDouble(st.nextToken());
			double y_coord = Double.parseDouble(st.nextToken());
			double z_coord = Double.parseDouble(st.nextToken());
			adjListElement[i-1] = " " + st.nextToken() + " ";
			if (numOfAtoms == 1) {
				String totalLine = molFileLines[i];
				int length = totalLine.length();
				int valencyFlag = Integer.parseInt(totalLine.substring(length-15,length-12).trim());
				if (valencyFlag != 0) {
					if (valencyFlag == 1) {
						if (adjListElement[i-1].equals(" C ")) adjListRadical[i-1] = "3 ";
						else if (adjListElement[i-1].equals(" Si ")) adjListRadical[i-1] = "3 ";
						else if (adjListElement[i-1].equals(" N ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" O ")) adjListRadical[i-1] = "1 ";
						else if (adjListElement[i-1].equals(" S ")) adjListRadical[i-1] = "1 ";
					} else if (valencyFlag == 2) {
						if (adjListElement[i-1].equals(" C ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" Si ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" N ")) adjListRadical[i-1] = "1 ";
					} else if (valencyFlag == 3) {
						if (adjListElement[i-1].equals(" C ")) adjListRadical[i-1] = "1 ";
						else if (adjListElement[i-1].equals(" Si ")) adjListRadical[i-1] = "1 ";
					} else if (valencyFlag == 15) {
						if (adjListElement[i-1].equals(" C ")) adjListRadical[i-1] = "4 ";
						else if (adjListElement[i-1].equals(" Si ")) adjListRadical[i-1] = "4 ";
						else if (adjListElement[i-1].equals(" N ")) adjListRadical[i-1] = "3 ";
						else if (adjListElement[i-1].equals(" O ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" S ")) adjListRadical[i-1] = "2 ";
						else if (adjListElement[i-1].equals(" H ")) adjListRadical[i-1] = "1 ";
					}
				}
			}
		}
		int Counter = numOfAtoms+1;
		while (!molFileLines[Counter].startsWith("M")) {
			st = new StringTokenizer(molFileLines[Counter]);
			int atom1 = Integer.parseInt(st.nextToken());
			int atom2 = Integer.parseInt(st.nextToken());
			adjListConnectivity[atom1-1] += "{" + atom2;
			adjListConnectivity[atom2-1] += "{" + atom1;
			int connection = Integer.parseInt(st.nextToken());
			if (connection == 1) {
				adjListConnectivity[atom1-1] += ",S} ";
				adjListConnectivity[atom2-1] += ",S} ";
			} else if (connection == 2) {
				adjListConnectivity[atom1-1] += ",D} ";
				adjListConnectivity[atom2-1] += ",D} ";
			} else if (connection == 3) {
				adjListConnectivity[atom1-1] += ",T} ";
				adjListConnectivity[atom2-1] += ",T} ";
			} else if (connection == 4) {
				adjListConnectivity[atom1-1] += ",B} ";
				adjListConnectivity[atom2-1] += ",B} ";
			}
			++Counter;
		}
		for (int i=numOfLines-numOfMLines; i<numOfLines-1; i++) {
			st = new StringTokenizer(molFileLines[numOfLines-numOfMLines]);
			String M = st.nextToken();
			String RAD = st.nextToken();
                        if (RAD.equals("RAD")){
				int numOfRads = Integer.parseInt(st.nextToken());
				for (int j=0; j<numOfRads; j++) {
					int atom = Integer.parseInt(st.nextToken());
					int radType = Integer.parseInt(st.nextToken());
                                            if (radType == 1)
                                                    adjListRadical[atom-1] = "2S ";
                                            else if (radType == 2)
                                                    adjListRadical[atom-1] = "1 ";
                                            else if (radType== 3)
                                                    adjListRadical[atom-1] = "2T ";
                                            else
                                                    adjListRadical[atom-1] = "3 ";
				}
			}
			else {
				System.out.println("Ignoring unknown M flag " + RAD + " for " + inchi);
			}      
		}
		String adjList = "";
		for (int i=0; i<numOfAtoms-1; i++) {
			adjList += (i+1) + adjListElement[i] + adjListRadical[i] + adjListConnectivity[i] + "\r";
		}
		adjList += numOfAtoms + adjListElement[numOfAtoms-1] + adjListRadical[numOfAtoms-1] + adjListConnectivity[numOfAtoms-1];
		return adjList;
	}
