User 247a2c5018
25-03-2016 15:52:26
Hi,
i used your examples : https://marvinjs-demo.chemaxon.com/latest/examples/example-more-images-immediately.html, to edit the structures retrieved after a substructure search and a similarity search :
<?php for ($i=0;$i<count($ligdata);$i++) {
$tabstru[$ligdata[$i]["STRU_ID"]]=str_replace(chr(10),'\n',$tabstru[$ligdata[$i]["STRU_ID"]]);
?>
<script>
var molecules = new Array("<?php echo $tabstru[$ligdata[$i]["STRU_ID"]];?>");
var marvin;
$(document).ready(function handleDocumentReady (e) {
// load marvin namespace in a separate frame to avoid css conflict
// the display attribute of this iframe cannot be "none", but you can hide it somewhere
$('body').append($('<iframe>', { id: "marvinjs-iframe", src: "marvinjs/marvinpack.html"}));
// wait for the reference of marvin namespace from the iframe
MarvinJSUtil.getPackage("#marvinjs-iframe").then(function (marvinNameSpace) {
// the reference to the namespace is arrived but there is no guaranty that its initalization has been finished
// because of it, wait till the ready state to be sure the whole API is available
marvinNameSpace.onReady(function() {
marvin = marvinNameSpace;
exportImages();
});
},function (error) {
alert("Cannot retrieve marvin instance from iframe:"+error);
});
});
function exportImages() {
// initalize table
$("#imageContainer").empty();
// iterate the array of molecule sources to create images
$.each(molecules, function(index, value) {
var imgData = marvin.ImageExporter.molToDataUrl(value);
// create a new cell with the new image and append to the table
if(imgData != null) {
var molCell = $('<div>', { class: "mol-cell"});
$("#imageContainer").append(molCell);
molCell.append($('<span>', { text: (index+1) }));
var img = $('<img>');
img.attr('src', imgData);
img.attr('data-mol', escape(value));
molCell.append(img);
}
});
// close table
$("#imageContainer").append($('<div>', { class: "table-bottom"}));
}
</script>
<div id="imageContainer" class="image-container">
<p>Preparation of the page is in progress ...</p>
</div>
<?php> } ?>
I have only one structure which is edited into an image instead of 2, by example :
the output of : var molecules = new Array("<?php echo $tabstru[$ligdata[$i]["STRU_ID"]];?>");
is :
var molecules = new Array("\n Mrv0541 03251616412D \n\n 7 7 0 0 0 0 999 V2000\n -2.5290 -0.4705 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -2.5302 -1.2974 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8158 -1.7099 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.0998 -1.2969 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.1027 -0.4669 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8176 -0.0580 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.8200 0.7665 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0\n 3 4 2 0 0 0 0\n 4 5 1 0 0 0 0\n 2 3 1 0 0 0 0\n 5 6 2 0 0 0 0\n 6 1 1 0 0 0 0\n 1 2 2 0 0 0 0\n 6 7 1 0 0 0 0\nM END\n");
var molecules = new Array("\n Mrv0541 03251616412D \n\n 8 8 0 0 0 0 999 V2000\n -0.0056 -0.8453 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -0.0068 -1.6721 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.7077 -2.0847 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.4236 -1.6716 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.4207 -0.8417 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.7059 -0.4327 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.7034 0.3918 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0\n 0.7075 -2.9092 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0\n 4 5 1 0 0 0 0\n 2 3 1 0 0 0 0\n 5 6 2 0 0 0 0\n 6 1 1 0 0 0 0\n 1 2 2 0 0 0 0\n 6 7 1 0 0 0 0\n 3 4 2 0 0 0 0\n 3 8 1 0 0 0 0\nM END\n");
Any idea?
Kiet