All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.ac.ebi.beam.BondBasedConfiguration Maven / Gradle / Ivy

There is a newer version: 1.3.6
Show newest version
package uk.ac.ebi.beam;

/** @author John May */
final class BondBasedConfiguration {

    static Configuration.DoubleBond configurationOf(Graph g,
                                                    int x, int u, int v, int y) {

        Edge e = g.edge(u, v);

        if (e.bond() != Bond.DOUBLE)
            throw new IllegalArgumentException("atoms u,v are not labelled as a double bond");

        Edge e1 = g.edge(u, x);
        Edge e2 = g.edge(v, y);

        Bond b1 = e1.bond(u);
        Bond b2 = e2.bond(v);

        if (b1 == Bond.IMPLICIT || b1 == Bond.SINGLE)
            return Configuration.DoubleBond.UNSPECIFIED;
        if (b2 == Bond.IMPLICIT || b2 == Bond.SINGLE)
            return Configuration.DoubleBond.UNSPECIFIED;

        return b1 == b2 ? Configuration.DoubleBond.TOGETHER
                        : Configuration.DoubleBond.OPPOSITE;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy