problems to edit images from molecules

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



ChemAxon f052bdfe3c

29-03-2016 14:43:00

I am sorry for the late reply. We only have some educated guess about this issue, since hard to check all the aspects without the generated HTML source. 


The PHP code what you sent, is not standalone application, and not seeing the whole, we might get to the wrong conclusion.  After take a look at this code snipplet we are curious while do you insert your JS code into a loop? We afraid that inserting  the JavaScript code multiple times might cause the problem.


The generated HTML source would be more informative for us to be able to give you more help


Best regards,


Efi 

User 247a2c5018

29-03-2016 15:06:33

Hi,


I attach the code with marvinview : codewithmarvinview.php, which returns 1 or n structures. 


and the code with marvinjs  : codewithmarvinjs.php which returns only one structure . Clearly the loop with  JS code doesn't return good results. How can I rewrite my js code to have the same result with marvin view?


May be it is helpul for you.


thanks


best regards,


Kiet

User 247a2c5018

01-04-2016 15:17:39

Hi,


 


any idea to solve my problem?


thanks


bests


 


Kiet

ChemAxon 76c88f5366

04-04-2016 08:37:42

Dear Kiet,


As we can see, this problem is more complex, and you would need more support than we can offer you via forum posts.


The good news is that there are other ways how we can help you. One way is the consultancy service, where our experienced colleges could give you an extensive and maintainable solution for you, especially for your needs.


As far as I understood, your sales contacted you in email about this.
If you need more information, please do not hesitate to ask her, or us ([email protected]). 


Our wish is to find the best solution, that fits you best.


Best regards,
Eszter