forked from OpenChemistry/avogadrolibs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an explicit sdf format which writes properties
Signed-off-by: Geoff Hutchison <[email protected]>
- Loading branch information
Showing
12 changed files
with
164 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/****************************************************************************** | ||
This source file is part of the Avogadro project. | ||
This source code is released under the 3-Clause BSD License, (see "LICENSE"). | ||
******************************************************************************/ | ||
|
||
#include "sdfformat.h" | ||
|
||
namespace Avogadro::Io { | ||
|
||
SdfFormat::SdfFormat() : MdlFormat() | ||
{ | ||
m_writeProperties = true; | ||
} | ||
|
||
SdfFormat::~SdfFormat() {} | ||
|
||
bool SdfFormat::read(std::istream& in, Core::Molecule& mol) | ||
{ | ||
return MdlFormat::read(in, mol); | ||
} | ||
|
||
bool SdfFormat::write(std::ostream& out, const Core::Molecule& mol) | ||
{ | ||
return MdlFormat::write(out, mol); | ||
} | ||
|
||
std::vector<std::string> SdfFormat::fileExtensions() const | ||
{ | ||
std::vector<std::string> ext; | ||
ext.emplace_back("sdf"); | ||
return ext; | ||
} | ||
|
||
std::vector<std::string> SdfFormat::mimeTypes() const | ||
{ | ||
std::vector<std::string> mime; | ||
mime.emplace_back("chemical/x-mdl-molfile"); | ||
return mime; | ||
} | ||
|
||
} // namespace Avogadro::Io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/****************************************************************************** | ||
This source file is part of the Avogadro project. | ||
This source code is released under the 3-Clause BSD License, (see "LICENSE"). | ||
******************************************************************************/ | ||
|
||
#ifndef AVOGADRO_IO_SDFFORMAT_H | ||
#define AVOGADRO_IO_SDFFORMAT_H | ||
|
||
#include "fileformat.h" | ||
#include "mdlformat.h" | ||
|
||
namespace Avogadro { | ||
namespace Io { | ||
|
||
/** | ||
* @class SdfFormat sdfformat.h <avogadro/io/sdfformat.h> | ||
* @brief Implementation of the generic SDF format. | ||
* @author Marcus D. Hanwell | ||
* | ||
* Differs from the MDL / Mol format in that it includes properties | ||
* | ||
* Currently just supports V2000 of the format. | ||
*/ | ||
|
||
class AVOGADROIO_EXPORT SdfFormat : public MdlFormat | ||
{ | ||
public: | ||
SdfFormat(); | ||
~SdfFormat() override; | ||
|
||
Operations supportedOperations() const override | ||
{ | ||
return ReadWrite | MultiMolecule | File | Stream | String; | ||
} | ||
|
||
FileFormat* newInstance() const override { return new SdfFormat; } | ||
std::string identifier() const override { return "Avogadro: SDF"; } | ||
std::string name() const override { return "SDF"; } | ||
std::string description() const override | ||
{ | ||
return "Generic format that contains atoms, bonds, positions."; | ||
} | ||
|
||
std::string specificationUrl() const override | ||
{ | ||
return "http://help.accelrysonline.com/ulm/onelab/1.0/content/ulm_pdfs/" | ||
"direct/" | ||
"reference/ctfileformats2016.pdf"; | ||
/* for previous (2011) version, see: | ||
https://web.archive.org/web/20180329184712/http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip | ||
*/ | ||
} | ||
|
||
std::vector<std::string> fileExtensions() const override; | ||
std::vector<std::string> mimeTypes() const override; | ||
|
||
bool read(std::istream& in, Core::Molecule& molecule) override; | ||
bool write(std::ostream& out, const Core::Molecule& molecule) override; | ||
|
||
protected: | ||
bool m_writeProperties = true; | ||
}; | ||
|
||
} // namespace Io | ||
} // namespace Avogadro | ||
|
||
#endif // AVOGADRO_IO_MDLFORMAT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters