Skip to content

Commit

Permalink
I found time and have added the .find() function to the molecular c…
Browse files Browse the repository at this point in the history
…ontainers.

This lets you easily get the index of atoms in systems etc., e.g.

>>> idxs = mols.atoms().find(mols["element C"])

returns the indexes in `mols` for all of the carbon atoms.
  • Loading branch information
chryswoods committed Jan 11, 2023
1 parent 3718493 commit 53880ab
Show file tree
Hide file tree
Showing 31 changed files with 5,119 additions and 4,201 deletions.
221 changes: 110 additions & 111 deletions corelib/src/libs/SireMM/selectorbond.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,172 +36,171 @@ SIRE_BEGIN_HEADER

namespace SireMM
{
class SelectorBond;
class SelectorBond;
}

SIREMM_EXPORT QDataStream& operator<<(QDataStream&, const SireMM::SelectorBond&);
SIREMM_EXPORT QDataStream& operator>>(QDataStream&, SireMM::SelectorBond&);
SIREMM_EXPORT QDataStream &operator<<(QDataStream &, const SireMM::SelectorBond &);
SIREMM_EXPORT QDataStream &operator>>(QDataStream &, SireMM::SelectorBond &);

namespace SireMM
{

/** This provides a Selector<T>-style interface for multiple bonds */
class SIREMM_EXPORT SelectorBond :
public SireBase::ConcreteProperty<SelectorBond, SireMol::MoleculeView>
{
/** This provides a Selector<T>-style interface for multiple bonds */
class SIREMM_EXPORT SelectorBond : public SireBase::ConcreteProperty<SelectorBond, SireMol::MoleculeView>
{

friend QDataStream& ::operator<<(QDataStream&, const SelectorBond&);
friend QDataStream& ::operator>>(QDataStream&, SelectorBond&);
friend QDataStream & ::operator<<(QDataStream &, const SelectorBond &);
friend QDataStream & ::operator>>(QDataStream &, SelectorBond &);

public:
SelectorBond();
public:
SelectorBond();

SelectorBond(const Bond &bond);
SelectorBond(const Bond &bond);

SelectorBond(const SireMol::MoleculeData &molecule,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::MoleculeData &molecule,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const MoleculeView &molecule,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const MoleculeView &molecule,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const SireMol::MoleculeData &molecule,
const SireMol::AtomID &atom,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::MoleculeData &molecule,
const SireMol::AtomID &atom,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const SireMol::MoleculeData &molecule,
const SireMol::AtomID &atom0, const SireMol::AtomID &atom1,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::MoleculeData &molecule,
const SireMol::AtomID &atom0, const SireMol::AtomID &atom1,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const SireMol::MoleculeView &molecule,
const SireMol::AtomID &atom,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::MoleculeView &molecule,
const SireMol::AtomID &atom,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const SireMol::MoleculeView &molecule,
const SireMol::BondID &bond,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::MoleculeView &molecule,
const SireMol::BondID &bond,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const SireMol::MoleculeView &molecule,
const QList<SireMol::BondID> &bonds,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::MoleculeView &molecule,
const QList<SireMol::BondID> &bonds,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const SireMol::MoleculeView &molecule,
const SireMol::AtomID &atom0, const SireMol::AtomID &atom1,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::MoleculeView &molecule,
const SireMol::AtomID &atom0, const SireMol::AtomID &atom1,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const SireMol::Selector<SireMol::Atom> &atoms,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::Selector<SireMol::Atom> &atoms0,
const SireMol::Selector<SireMol::Atom> &atoms1,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::Selector<SireMol::Atom> &atoms,
const SireBase::PropertyMap &map = SireBase::PropertyMap());
SelectorBond(const SireMol::Selector<SireMol::Atom> &atoms0,
const SireMol::Selector<SireMol::Atom> &atoms1,
const SireBase::PropertyMap &map = SireBase::PropertyMap());

SelectorBond(const SelectorBond &other);
SelectorBond(const SelectorBond &other);

virtual ~SelectorBond();
virtual ~SelectorBond();

static const char* typeName();
static const char *typeName();

virtual const char* what() const
{
return SelectorBond::typeName();
}
virtual const char *what() const
{
return SelectorBond::typeName();
}

virtual SelectorBond* clone() const
{
return new SelectorBond(*this);
}
virtual SelectorBond *clone() const
{
return new SelectorBond(*this);
}

SelectorBond& operator=(const SelectorBond &bond);
SelectorBond &operator=(const SelectorBond &bond);

bool operator==(const SelectorBond &other) const;
bool operator!=(const SelectorBond &other) const;
bool operator==(const SelectorBond &other) const;
bool operator!=(const SelectorBond &other) const;

QString toString() const;
QString toString() const;

SireMol::MolViewPtr operator[](int i) const;
SireMol::MolViewPtr operator[](const SireBase::Slice &slice) const;
SireMol::MolViewPtr operator[](const QList<qint64> &idxs) const;
SireMol::MolViewPtr operator[](const SireMol::BondID &bond) const;
SireMol::MolViewPtr operator[](int i) const;
SireMol::MolViewPtr operator[](const SireBase::Slice &slice) const;
SireMol::MolViewPtr operator[](const QList<qint64> &idxs) const;
SireMol::MolViewPtr operator[](const SireMol::BondID &bond) const;

Bond operator()(int i) const;
SelectorBond operator()(int i, int j) const;
SelectorBond operator()(const SireBase::Slice &slice) const;
SelectorBond operator()(const QList<qint64> &idxs) const;
SelectorBond operator()(const SireMol::BondID &bond) const;
Bond operator()(int i) const;
SelectorBond operator()(int i, int j) const;
SelectorBond operator()(const SireBase::Slice &slice) const;
SelectorBond operator()(const QList<qint64> &idxs) const;
SelectorBond operator()(const SireMol::BondID &bond) const;

QList<SireMol::MolViewPtr> toList() const;
QList<SireMol::MolViewPtr> toList() const;

bool isSelector() const;
bool isSelector() const;

QList<SireMol::BondID> IDs() const;
QList<SireMol::BondID> IDs() const;

SelectorBond add(const Bond &bond) const;
SelectorBond add(const Bond &bond) const;

int count() const;
int size() const;
int nViews() const;
int count() const;
int size() const;
int nViews() const;

bool isEmpty() const;
bool selectedAll() const;
bool isEmpty() const;
bool selectedAll() const;

SireMol::MolViewPtr toSelector() const;
SireMol::MolViewPtr toSelector() const;

SireMol::AtomSelection selection() const;
SireMol::AtomSelection selection() const;

SelectorBond add(const SelectorBond &other) const;
SelectorBond add(const SelectorBond &other) const;

SelectorBond intersection(const SelectorBond &other) const;
SelectorBond intersection(const SelectorBond &other) const;

SelectorBond invert(const SireBase::PropertyMap &map) const;
SelectorBond invert() const;
SelectorBond invert(const SireBase::PropertyMap &map) const;
SelectorBond invert() const;

bool hasProperty(const SireBase::PropertyName &key) const;
bool hasMetadata(const SireBase::PropertyName &key) const;
bool hasMetadata(const SireBase::PropertyName &key,
const SireBase::PropertyName &metakey) const;
bool hasProperty(const SireBase::PropertyName &key) const;
bool hasMetadata(const SireBase::PropertyName &key) const;
bool hasMetadata(const SireBase::PropertyName &key,
const SireBase::PropertyName &metakey) const;

QStringList propertyKeys() const;
QStringList metadataKeys() const;
QStringList metadataKeys(const SireBase::PropertyName &key) const;
QStringList propertyKeys() const;
QStringList metadataKeys() const;
QStringList metadataKeys(const SireBase::PropertyName &key) const;

QList<SireBase::Properties> properties() const;
QList<SireBase::Properties> properties() const;

SireMol::Mover<SelectorBond> move() const;
SireMol::Evaluator evaluate() const;
SireMol::Mover<SelectorBond> move() const;
SireMol::Evaluator evaluate() const;

QList<SireBase::PropertyPtr> property(const SireBase::PropertyName &key) const;
QList<SireBase::PropertyPtr> property(const SireBase::PropertyName &key,
const Property &default_value) const;
QList<SireBase::PropertyPtr> property(const SireBase::PropertyName &key) const;
QList<SireBase::PropertyPtr> property(const SireBase::PropertyName &key,
const Property &default_value) const;

QList<SireUnits::Dimension::Length> lengths() const;
QList<SireUnits::Dimension::Length> lengths(const SireBase::PropertyMap &map) const;
QList<SireUnits::Dimension::Length> lengths() const;
QList<SireUnits::Dimension::Length> lengths(const SireBase::PropertyMap &map) const;

QList<SireUnits::Dimension::Length> measures() const;
QList<SireUnits::Dimension::Length> measures(const SireBase::PropertyMap &map) const;
QList<SireUnits::Dimension::Length> measures() const;
QList<SireUnits::Dimension::Length> measures(const SireBase::PropertyMap &map) const;

QList<SireCAS::Expression> potentials() const;
QList<SireCAS::Expression> potentials(const SireBase::PropertyMap &map) const;
QList<SireCAS::Expression> potentials() const;
QList<SireCAS::Expression> potentials(const SireBase::PropertyMap &map) const;

QList<SireUnits::Dimension::GeneralUnit> energies() const;
QList<SireUnits::Dimension::GeneralUnit> energies(
const SireBase::PropertyMap &map) const;
QList<SireUnits::Dimension::GeneralUnit> energies() const;
QList<SireUnits::Dimension::GeneralUnit> energies(
const SireBase::PropertyMap &map) const;

SireUnits::Dimension::GeneralUnit energy() const;
SireUnits::Dimension::GeneralUnit energy(
const SireBase::PropertyMap &map) const;
SireUnits::Dimension::GeneralUnit energy() const;
SireUnits::Dimension::GeneralUnit energy(
const SireBase::PropertyMap &map) const;

protected:
/** The IDs of the bond (holding AtomIdx IDs) */
QList<SireMol::BondID> bnds;
};
protected:
/** The IDs of the bond (holding AtomIdx IDs) */
QList<SireMol::BondID> bnds;
};

} // end of namespace SireMM

Q_DECLARE_METATYPE( SireMM::SelectorBond )
Q_DECLARE_METATYPE( SireMol::Mover<SireMM::SelectorBond> )
Q_DECLARE_METATYPE(SireMM::SelectorBond)
Q_DECLARE_METATYPE(SireMol::Mover<SireMM::SelectorBond>)

SIRE_EXPOSE_CLASS( SireMM::SelectorBond )
SIRE_EXPOSE_CLASS(SireMM::SelectorBond)

SIRE_EXPOSE_ALIAS( SireMol::Mover<SireMM::SelectorBond>, SireMol::Mover_SelectorBond_ )
SIRE_EXPOSE_ALIAS(SireMol::Mover<SireMM::SelectorBond>, SireMol::Mover_SelectorBond_)

#ifdef SIRE_INSTANTIATE_TEMPLATES

Expand Down
Loading

0 comments on commit 53880ab

Please sign in to comment.