示例#1
0
 function fix_search_items($item)
 {
     $data = array('chemspider:id' => $item->CSID, 'chem:molecular-formula' => preg_replace('/_\\{(\\d+)\\}/', '$1', $item->MF), 'chem:smiles' => $item->SMILES, 'iupac:inchi' => $item->InChI, 'iupac:inchikey' => $item->InChIKey, 'chem:molecular-weight' => $item->MolecularWeight, 'dc:title' => $item->CommonName, 'misc:image' => url('http://www.chemspider.com/ImagesHandler.ashx', array('w' => 200, 'h' => 200, 'id' => $item->CSID)), 'rdf:uri' => url('http://www.chemspider.com/' . urlencode($item->CSID)));
     if ($data['iupac:inchi']) {
         $properties = mol2stdinchi($data['iupac:inchi']);
         $data['iupac:stdinchi'] = $properties['iupac:stdinchi'];
         $data['iupac:stdinchikey'] = $properties['iupac:stdinchikey'];
     }
     return $data;
 }
示例#2
0
function parse_sdf($sdf){
  $items = array();
  foreach (explode('$$$$', $sdf) as $item){
    if (preg_match('/^(.+?\nM\s+END\n)(.*)/s', $item, $matches)){
      list(, $structure, $text) = $matches;

      $item = array();
      preg_match_all('/>\s+<(\w+)>(?:\r|\n)(.+?)(?:\r|\n){2}/s', $text, $meta_matches, PREG_SET_ORDER);
      foreach ($meta_matches as $m)
        $item['meta-' . $m[1]] = $m[2];

      $item['chem:mol'] = $structure;
      $item = array_merge($item, mol2stdinchi($structure));

      $items[] = $item;
    }
  }
  return $items;
}
示例#3
0
文件: CHEBI.php 项目: hubgit/libapi
 function parse_item($item)
 {
     $synonyms = array();
     foreach ($item->Synonyms as $name) {
         $synonyms[] = $name->data;
     }
     $names = array();
     foreach ($item->IupacNames as $name) {
         $names[] = $name->data;
     }
     $mol = null;
     if (!empty($item->ChemicalStructures)) {
         foreach ($item->ChemicalStructures as $structure) {
             if ($structure->defaultStructure == true) {
                 $mol = $structure->structure;
             }
         }
         if (is_null($mol)) {
             $mol = $item->ChemicalStructures[0]->structure;
         }
         $inchi = mol2stdinchi($mol);
     }
     return array('chebi:id' => $item->chebiId, 'dc:title' => $item->chebiAsciiName, 'iupac:inchi' => $item->inchi, 'iupac:inchikey' => preg_replace('/^InChIKey=/', '', $item->inchiKey), 'iupac:stdinchi' => $inchi['iupac:stdinchi'], 'iupac:stdinchikey' => $inchi['iupac:stdinchikey'], 'chem:molecular-formula' => $item->Formulae ? $item->Formulae[0]->data : null, 'chem:mol' => $mol, 'chem:smiles' => $item->smiles, 'misc:synonyms' => $synonyms, 'iupac:name' => $names, 'misc:image' => url('http://www.ebi.ac.uk/chebi/displayImage.do', array('defaultImage' => 'true', 'imageIndex' => 0, 'chebiId' => $item->chebiId)), 'rdf:uri' => url('http://www.ebi.ac.uk/chebi/searchId.do', array('chebiId' => $item->chebiId)));
 }