構造式検索エンジンがあるので、実際に検索できるwebアプリを作ってみた

クエリを書くのには JSME Molecule Editor http://peter-ertl.com/jsme/ を利用した。
*javascriptベースの化合物描画ツール。BSD licenseライセンス
*器は、dhtmlxにて作成

#iframe(https://web.chaperone.jp/c/index.html,style=width:100%;height:500px;)

全体はdhtmlxのdhtmlxLayoutを使ってフレーム分けさせて、左側には検索構造式を描いて、右側にはその結果をパネルで表示させた。
*dhtmlxのソースは、https://web.chaperone.jp/c/index.htmlから参照してください
*dhtmlxのフリー版でenableSmartRendering機能を使うにはXMLでのデータ受け渡しが必要。

構造式のパネル表示部分

dhtmlxDataViewをライブラリに使ってます。

  myDataView = myLayout.cells("b").attachDataView({
     type:{
          template:"#mol#",
          height:80,
          width:80
     }
  });
  myDataView.load("dv.php","xml");

として、こんな感じのphpスクリプトにした
*以前pythonで描いたがphpで作り直した

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
<?php
$posStart = 0;
$count = 500;
if ( isset($_GET['posStart']) ) $posStart = $_GET['posStart'];
if ( isset($_GET['count'])    ) $count = $_GET['count'];
if ( isset($_POST['mol'])    )  $mol = $_POST['mol'];
 
$dsn = "pgsql:dbname=chemdb host=localhost port=5432";
$user="caster";
$password="caster";
 
$dbh = new PDO($dsn, $user, $password);
$sql = "SELECT pubchem_compound_cid FROM pubchem WHERE 1=1";
 
if ( $posStart == 0 ){
    $sqlCount = "SELECT count(*) as cnt FROM (".$sql.") as tbl";
    $sth = $dbh->query($sqlCount);
    $res = $sth->fetch(PDO::FETCH_NUM);
    $output="<data total_count='".$res[0]."' pos='".$posStart."'>";
    $sth = null;
    $res = null;
}else{
    $output="<data pos='".$posStart."'>";
}
if ( $mol ){
  $_SESSION['mol'] = $mol;
  $sql .= " and rdkit_smiles @> '".$mol."' LIMIT :limit OFFSET :offset";
}else{
  $sql .= " LIMIT :limit OFFSET :offset";
}
 
$sth = $dbh->prepare($sql);
$sth->execute(array(':limit'=> $count, ':offset'=> $posStart) );
while($res = $sth->fetch(PDO::FETCH_NUM)){
    $output .= "<item id='".$res[0]."'><mol><![CDATA[<IMG SRC='http://web.chaperone.jp/depict?".$res[0]."' />]]></mol></item>";
}
$output .= "</data>";
 
$dbh = null;
header("Content-Type: text/xml");
print $output;
?>

部分構造検索

JSMEで描いた構造式はsmilesにもmol形式でも取り出せる。ここではmol形式でクエリーを受け取ってRDKitに流してみる。
まずはボタンの制御のためにjqueryライブラリを設置して、検索ボタンを押下したらJSMEと連携してMOLデータを取得する

$(function() {
  $('#run').click(function(e){
      if ( jsmeApplet.smiles() != "" ){
         $.ajax({
            type: "POST",
            url: "dv.php",
            data: {"mol": jsmeApplet.smiles()}
         }).done(function(data){
            myDataView.clearAll();
            myDataView.parse(data,"xml");
         });
      }
  });
});

こんな感じで。詳しくは現物http://web.chaperone.jp/c/index.htmlのソースをご覧下さい。

smilesではなくMDL MOL形式から検索するには

JSMEには描いた構造式をsmilesで出力する機能の他に、MDL MOL形式での出力も可能である。
このMDL MOL形式のままで検索するには、RDKitのmol_from_ctab関数を使用する。
具体的には

鴻鴻
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
SELECT pubchem_compound_cid FROM pubchem WHERE 1=1 and rdkit_smiles @> mol_from_ctab('C1=CC=CC=C1
JME 2016-07-31 Wed Oct 25 00:13:04 GMT+900 2017
 
  6  6  0  0  0  0  0  0  0  0999 V2000
    2.4249    0.7000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.4249    2.1000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.2124    2.8000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    2.1000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.7000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.2124    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  2  3  2  0  0  0  0
  3  4  1  0  0  0  0
  4  5  2  0  0  0  0
  5  6  1  0  0  0  0
  6  1  2  0  0  0  0
M  END
'::cstring);

な感じで直接MDL MOLを入れ込んで、末尾に「::cstring」を加える。これで行けます。

最新の60件
2025-02-17 2025-02-15 2025-02-14 2025-02-12 2025-02-03 2025-02-02 2025-02-01 2025-01-27 2025-01-26 2025-01-25 2025-01-24 2025-01-23 2025-01-20 2025-01-13 2025-01-12 2025-01-08 2024-12-30 2024-12-29 2024-12-22 2024-12-20 2024-12-17 2024-12-15 2024-12-14 2024-12-12 2024-12-11 2024-12-10 2024-12-09 2024-12-08 2024-11-28 2024-11-22 2024-11-15 2024-11-14 2024-11-12 2024-11-06 2024-11-05 2024-11-04 2024-11-02 2024-11-01 2024-10-28 2024-10-27 2024-10-23 2024-10-18 2024-10-17 2024-10-15 2024-10-14

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2017-10-26 (木) 00:34:12