openmolecules.org

 
Home » DataWarrior » Functionality » DWAR file format (file format conversion)
DWAR file format [message #483] Thu, 07 March 2019 13:36 Go to next message
catalyst is currently offline  catalyst
Messages: 2
Registered: March 2019
Junior Member
hey folks,
i've been looking for a format specification for the DWAR file format; so far, no luck Confused . can somebody please direct me? thanks!
Re: DWAR file format [message #491 is a reply to message #483] Thu, 07 March 2019 18:26 Go to previous messageGo to next message
thomas is currently offline  thomas
Messages: 247
Registered: June 2014
Senior Member
there is no document that describes the entire file format, but there is open-source code that reads or writes it. In principal the files contains these sections:
- header with version and row count
- column properties assigning properties to columns identified by names. These include
- special types like idcode (encoded chemical structure), rxncode (encoded reaction), descriptors
- parent-child relationships, e.g. to associate a descriptor column to a parent idcode column
- detail type and access information in case the column contains references to details (images, html code)
- others
- the TAB delimited data table itself
- optionally encoded embedded details
- optionally encoded row lists
- optionally embedded macros
- the datawarrior template, which includes information about open views and filters
Re: DWAR file format [message #492 is a reply to message #491] Fri, 08 March 2019 16:43 Go to previous messageGo to next message
catalyst is currently offline  catalyst
Messages: 2
Registered: March 2019
Junior Member
thanks for the quick reply! could you please point me to some examples? I'm particularly interested in how to put 3D conformer data into the file.
Thanks again for your help!

[Updated on: Fri, 08 March 2019 16:45]

Report message to a moderator

Re: DWAR file format [message #493 is a reply to message #492] Sat, 09 March 2019 21:33 Go to previous message
thomas is currently offline  thomas
Messages: 247
Registered: June 2014
Senior Member
you could use something like the following Java method, which reads conformers from an SD-File,
creates a CompoundTableModel, populates it with the conformers, and uses a CompoundTableSaver
to write the table model into a native DataWarrior file.

If you need to write much larger files, this method may not be the appropriate approach, because
of the large memory footprint. I suggest that you contact me on my idorsia e-mail address (see
openmolecules.org about page) to find an optimal solution.

(the following depends on some files of the DataWarrior source code):


public static void createConformerDWARDemo() {
final int ROW_COUNT = 1000;

CompoundTableModel tableModel = new CompoundTableModel();
tableModel.initializeTable(ROW_COUNT, 3);

// this is a hack to prevent nullpointer exception and won't be necessary in the future
tableModel.setDetailHandler(new CompoundTableDetailHandler(tableModel));

final String IDENTIFIER_COLUMN_NAME = "ID";
final String STRUCTURE_COLUMN_NAME = "Structure";

// first column will contain the structure name/ID
tableModel.setColumnName(IDENTIFIER_COLUMN_NAME, 0);

// define second column to contain idcodes
tableModel.setColumnName(STRUCTURE_COLUMN_NAME, 1);
tableModel.setColumnProperty(1, CompoundTableConstants.cColumnPropertySpecialType, CompoundTableConstants.cColumnTypeIDCode);

// define third column to contain the 3D-coordinates and make it a child of the structure column
tableModel.setColumnName(CompoundTableConstants.cColumnType3 DCoordinates, 2);
tableModel.setColumnProperty(2, CompoundTableConstants.cColumnPropertySpecialType, CompoundTableConstants.cColumnType3DCoordinates);
tableModel.setColumnProperty(2, CompoundTableConstants.cColumnPropertyParentColumn, STRUCTURE_COLUMN_NAME);

// read some molecules from an SD-File that should contain 3-dimensional atom coordinates
SDFileParser parser = new SDFileParser("someFileName.sdf");
for (int row=0; row<ROW_COUNT && parser.next(); row++) {
StereoMolecule mol = parser.getMolecule();

Canonizer canonizer = new Canonizer(mol);
String id = "ID-"+(row+1);
String idcode = canonizer.getIDCode();
String coords = canonizer.getEncodedCoordinates();

tableModel.setTotalValueAt(id, row, 0);
tableModel.setTotalValueAt(idcode, row, 1);
tableModel.setTotalValueAt(coords, row, 2);
}
tableModel.finalizeTable(CompoundTableEvent.cSpecifierNoRunt imeProperties, null);

// the new JFrame() is also a hack, which can be replaced by null very soon
CompoundTableSaver saver = new CompoundTableSaver(new JFrame(), tableModel, null);
saver.saveNative(null, new File("someFileName.dwar"), false, false);
}

[Updated on: Sat, 09 March 2019 21:59]

Report message to a moderator

Previous Topic: exporting R groups of compounds
Next Topic: Toxicity screen
Goto Forum:
  


Current Time: Fri Dec 13 01:13:02 CET 2019

Total time taken to generate the page: 0.00355 seconds