Skip to content

Commit

Permalink
Merged cdk-1.4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Oct 2, 2011
2 parents c72d442 + a7cbe48 commit 3a8307c
Show file tree
Hide file tree
Showing 23 changed files with 1,012 additions and 230 deletions.
1 change: 1 addition & 0 deletions src/META-INF/test-data.cdkdepends
@@ -1,6 +1,7 @@
cdk-annotation.jar
cdk-interfaces.jar
cdk-core.jar
cdk-standard.jar
cdk-data.jar
cdk-nonotify.jar
cdk-test.jar
Expand Down
1 change: 1 addition & 0 deletions src/META-INF/test-datadebug.cdkdepends
@@ -1,6 +1,7 @@
cdk-annotation.jar
cdk-interfaces.jar
cdk-core.jar
cdk-standard.jar
cdk-data.jar
cdk-datadebug.jar
cdk-test.jar
Expand Down
1 change: 1 addition & 0 deletions src/META-INF/test-nonotify.cdkdepends
@@ -1,6 +1,7 @@
cdk-annotation.jar
cdk-interfaces.jar
cdk-core.jar
cdk-standard.jar
cdk-data.jar
cdk-nonotify.jar
cdk-test.jar
Expand Down
1 change: 1 addition & 0 deletions src/META-INF/test-silent.cdkdepends
Expand Up @@ -2,6 +2,7 @@ cdk-annotation.jar
cdk-interfaces.jar
cdk-core.jar
cdk-silent.jar
cdk-standard.jar
cdk-test.jar
cdk-test-interfaces.jar
cdk-diff.jar
2 changes: 1 addition & 1 deletion src/main/net/sf/cdk/tools/MakeJavafilesFiles.java
Expand Up @@ -214,7 +214,7 @@ public String[] getModuleAndSet(File file) {
index = line.indexOf("@cdk.set");
String set = "";
if (index != -1) {
index += 11;
index += 8;
// skip the first chars
while (Character.isWhitespace(line.charAt(index))) index++;
while (index < line.length() &&
Expand Down
56 changes: 47 additions & 9 deletions src/main/net/sf/cdk/tools/bibtex/BibTeXMLEntry.java
@@ -1,6 +1,4 @@
/* $Revision: 6707 $ $Author: egonw $ $Date: 2006-07-30 16:38:18 -0400 (Sun, 30 Jul 2006) $
*
* Copyright (C) 2007 Egon Willighagen <egonw@users.sf.net>
/* Copyright (C) 2007,2011 Egon Willighagen <egonw@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand Down Expand Up @@ -65,16 +63,40 @@ public String toHTML() {
getString(article, "pages", "?-?")
);
}
// b:article
results = entry.query("./b:misc", context);
// b:thesis
results = entry.query("./b:phdthesis", context);
for (int i=0; i<results.size(); i++) {
Element misc = (Element)results.get(i);
Element thesis = (Element)results.get(i);
// the obligatory fields
return formatMisc(
getString(misc, "author", "?Authors?"),
getString(misc, "title", "?Title?")
return formatThesis(
getString(thesis, "author", "?Authors?"),
getString(thesis, "title", "?Title?"),
getString(thesis, "year", "19??"),
getString(thesis, "adress", "?Institute?")
);
}
// b:phdthesis
results = entry.query("./b:book", context);
for (int i=0; i<results.size(); i++) {
Element book = (Element)results.get(i);
// the obligatory fields
return formatBook(
getString(book, "author", "?Authors?"),
getString(book, "title", "?Title?"),
getString(book, "year", "19??"),
getString(book, "publisher", "?Publisher?")
);
}
// b:misc
results = entry.query("./b:misc", context);
for (int i=0; i<results.size(); i++) {
Element misc = (Element)results.get(i);
// the obligatory fields
return formatMisc(
getString(misc, "author", "?Authors?"),
getString(misc, "title", "?Title?")
);
}
return "Unknown BibTeXML type: " + ((Element)entry).getAttributeValue("id");
}

Expand All @@ -92,6 +114,22 @@ protected String formatMisc(String authors, String title) {
return buffer.toString();
}

protected String formatThesis(String authors, String title, String year, String institute) {
StringBuffer buffer = new StringBuffer();
buffer.append(authors).append(", <i>").append(title).append("</i>, ");
buffer.append("<b>").append(year).append("</b>, ");
buffer.append(institute);
return buffer.toString();
}

protected String formatBook(String authors, String title, String year, String publisher) {
StringBuffer buffer = new StringBuffer();
buffer.append(authors).append(", <i>").append(title).append("</i>, ");
buffer.append("<b>").append(year).append("</b>, ");
buffer.append(publisher);
return buffer.toString();
}

/**
* @param node Parent for the child.
* @param childElement Localname of the child element.
Expand Down
59 changes: 59 additions & 0 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -155,6 +155,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGadolinum(atomContainer, atom);
} else if ("Ge".equals(atom.getSymbol())) {
type = perceiveGermanium(atomContainer, atom);
} else if ("Co".equals(atom.getSymbol())) {
type = perceiveCobalt(atomContainer, atom);
} else if ("Br".equals(atom.getSymbol())) {
type = perceiveBromine(atomContainer, atom);
} else if ("V".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -2370,6 +2372,63 @@ private IAtomType perceiveBromine(IAtomContainer atomContainer, IAtom atom) thro
private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom, String symbol) {
return countAttachedBonds(container, atom, IBond.Order.DOUBLE, symbol);
}

private IAtomType perceiveCobalt(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == +2)) {
IAtomType type = getAtomType("Co.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == +3)) {
IAtomType type = getAtomType("Co.3plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() == CDKConstants.UNSET ||
atom.getFormalCharge() == 0)) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 2) {
IAtomType type = getAtomType("Co.2");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 4) {
IAtomType type = getAtomType("Co.4");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 6) {
IAtomType type = getAtomType("Co.6");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 1) {
IAtomType type = getAtomType("Co.1");
if (isAcceptable(atom, atomContainer, type)) return type;
} else {
IAtomType type = getAtomType("Co.metallic");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == +1)) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 2) {
IAtomType type = getAtomType("Co.plus.2");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 4) {
IAtomType type = getAtomType("Co.plus.4");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 1) {
IAtomType type = getAtomType("Co.plus.1");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 6) {
IAtomType type = getAtomType("Co.plus.6");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 5) {
IAtomType type = getAtomType("Co.plus.5");
if (isAcceptable(atom, atomContainer, type)) return type;
} else {
IAtomType type = getAtomType("Co.plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
}
return null;
}

private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) {
return countAttachedBonds(container, atom, IBond.Order.DOUBLE, null);
Expand Down
65 changes: 64 additions & 1 deletion src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1494,7 +1494,7 @@
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.3plus">
<at:formalCharge>3</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
Expand All @@ -1508,6 +1508,69 @@
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.plus.6">
<at:formalCharge>1</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>6</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.plus.2">
<at:formalCharge>1</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>2</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.2">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>2</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.6">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>6</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.plus.4">
<at:formalCharge>1</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>4</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.4">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>4</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.plus.5">
<at:formalCharge>1</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>5</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.plus.1">
<at:formalCharge>1</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>1</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.1">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
<at:formalNeighbourCount>1</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Cu.plus">
<at:formalCharge>1</at:formalCharge>
Expand Down
2 changes: 1 addition & 1 deletion src/main/org/openscience/cdk/io/CMLWriter.java
Expand Up @@ -109,7 +109,7 @@
*
* @cdk.keyword file format, CML
*/
@TestClass("org.openscience.cdk.io.CMLWriterTest")
@TestClass("org.openscience.cdk.io.CML2WriterTest")
public class CMLWriter extends DefaultChemObjectWriter {

private OutputStream output;
Expand Down
4 changes: 2 additions & 2 deletions src/main/org/openscience/cdk/io/MDLV2000Reader.java
Expand Up @@ -747,11 +747,11 @@ private IAtomContainer readAtomContainer(IAtomContainer molecule) throws CDKExce
int charge = Integer.parseInt(token.trim());
outputContainer.getAtom(atomNumber - 1).setFormalCharge(charge);
}
} else if (line.matches("^A \\d+")) {
} else if (line.matches("A\\s{1,4}\\d+")) {
// Reads the pseudo atom property from the mol file

// The atom number of the to replaced atom
int aliasAtomNumber = Integer.parseInt(line.replaceFirst("^A ", "")) - RGroupCounter;
int aliasAtomNumber = Integer.parseInt(line.replaceFirst("A\\s{1,4}", "")) - RGroupCounter;
line = input.readLine(); linecount++;
String[] aliasArray = line.split("\\\\");
// name of the alias atom like R1 odr R2 etc.
Expand Down
1 change: 1 addition & 0 deletions src/main/org/openscience/cdk/qsar/DescriptorEngine.java
Expand Up @@ -645,6 +645,7 @@ public static List<String> getDescriptorClassNameByPackage(String packageName, S
String[] jars;
if (jarFileNames == null) {
String classPath = System.getProperty("java.class.path");
logger.debug("Dictionary classpath: ", classPath);
jars = classPath.split(File.pathSeparator);
} else {
jars = jarFileNames;
Expand Down
6 changes: 5 additions & 1 deletion src/main/org/openscience/cdk/tools/LoggingTool.java
Expand Up @@ -264,7 +264,11 @@ public void debug(Object object, Object... objects) {
StringBuilder result = new StringBuilder();
result.append(object.toString());
for (Object obj : objects) {
result.append(obj.toString());
if (obj == null) {
result.append("null");
} else {
result.append(obj.toString());
}
}
debugString(result.toString());
}
Expand Down
Expand Up @@ -93,9 +93,9 @@ public int compare(IAtomContainer o1, IAtomContainer o2) {
if (o1 == null && o2 == null)
return 0;
if (o1 == null)
return -1;
if (o2 == null)
return 1;
if (o2 == null)
return -1;

// Check for correct instances
if (!(o1 instanceof IAtomContainer) && !(o2 instanceof IAtomContainer))
Expand Down

0 comments on commit 3a8307c

Please sign in to comment.