Is there an example of displaying CD_STRUCTURE in Marvin?

User 0908c5ccdd

20-09-2007 08:55:35

My Marvin viewer is working really well on my ASP.NET pages. I can retrieve chemistry using the CD_SMILES column and display the structures on the page. This works fine. However I wasn't sure how to go about using the mol file in CD_STRUCTURE to display the results as this is stored in a BLOB type column. I need to start using the mol file as it contains the enhanced stereochemistry that is missing in the SMILES string.





Q1. Are there any examples on how to translate the BLOB field so that it can be sent to the Marvin viewer using the method I'm using below?





Q2. Also, is there a way to avoid having to declare the variable (sSMILES in this case) publicly?





So far a simplified version of my code looks like this:





Code:



<div>


    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="select cd_smiles from compounds where cd_id = 1">


    </asp:SqlDataSource>


    <script language= "Javascript1.1" src="Marvin/marvin.js"></script>


    <script language="Javascript1.1">


    <!--


    mview_begin("Marvin/", 200, 200);


    mview_param("mol", "<%= convertForJavaScript(sSMILES) %>")


    mview_param("background", "#F5F5FF");


    mview_end();


    !-->


    </script>                 


</div>








and the VB.NET code is:





Code:
Imports System.Data





Partial Class _Default


    Inherits System.Web.UI.Page





    Public sSMILES As String





    Public Function convertForJavaScript(ByVal t)





        t = Replace(t, "\", "\\")      ' replace \ with \\


        t = Replace(t, vbCrLf, "\n")   ' replace CrLf with \n


        t = Replace(t, vbCr, "\n")     ' replace single Cr with \n


        t = Replace(t, vbLf, "\n")     ' replace single Lf with \n


        t = Replace(t, """", "\""")    ' replace " with \"


        t = Replace(t, "'", "\'")      ' replace ' with \'


        convertForJavaScript = t





    End Function





    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load





        Dim SmilesFound As DataView = _


            CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView)





        sSMILES = SmilesFound(0)("CD_SMILES").ToString()





    End Sub





End Class

ChemAxon a3d59b832c

20-09-2007 09:12:55

Hi Stephen,





My two cents: The cd_smiles column contains molecules in ChemAxon extended smiles (cxsmiles) format, which also represents enhanced stereo. See:


http://www.chemaxon.com/marvin/doc/user/cxsmiles-doc.html





But surely, there may be other features not translatable to cxsmiles, and in the rows of molecules with such features the cd_smiles is null. So you are right, it is safer to use the cd_structure column for display. My colleagues will answer the questions soon.





Regards,


Szabolcs

ChemAxon aa7c50abf8

20-09-2007 09:17:31

Please, for both questions see the searchresults.aspx and the InteropUtil.cs file in the ASP.NET example in the examples\ChemAxon.NET\ASP.NET directory. In particular, look at the ASPNETUtil.readBytesAsCharArray(OdbcDataReader reader, int colIdx) procedure and the way it is used in searchresults.aspx