On Oct 24, 2014, at 3:15 AM, ftorazyne wrote:
> Your code returns
 ...
> Trying words of length 4
> Trying words of length 5
> Trying words of length 6

I don't know the registration system well enough to figure out how it can be 
that the formats are registered, but not available in any form.

> and uses FindFormat() function. I searched its definition with grep and
> didn't find it.


It starts as you said in obconversion.cpp:

  bool OBConversion::SetInFormat(const char* inID)
  {
    if(inID)
      pInFormat = FindFormat(inID);
    return pInFormat && !(pInFormat->Flags() & NOTREADABLE);
  }

which calls another function further on down in that file:

  OBFormat* OBConversion::FindFormat(const char* ID)
  {
    return OBFormat::FindType(ID);
  }

Here's the complicated part. FindType is defined in
the MAKE_PLUGIN(BaseClass) macro in include/openbabel/plugin.h 

  static BaseClass* FindType(const char* ID) {\
    if (!ID || *ID==0 || *ID==' ') {\
      return Default();\
    }\
    return static_cast<BaseClass*>(BaseFindType(Map(),ID));\
  }

This is use for fingerprint, forcefield, descriptor, format
and charge model registration. See include/fingerprint.h where
it has "MAKE_PLUGIN(OBFingerprint)" to see it in use.

The BaseFindType is in src/plugin.cpp and is a simple function:


OBPlugin* OBPlugin::BaseFindType(PluginMapType& Map, const char* ID)
{
  // Make sure the plugins are loaded
  if (AllPluginsLoaded == 0) {
    OBPlugin::LoadAllPlugins();
  }

  if(!ID || !*ID)
    return NULL;
  PluginMapType::iterator itr = Map.find(ID);
  if(itr==Map.end())
    return NULL;
  else
    return itr->second;
}


although LoadAllPlugins() is more complicated.

For what it's worth, my local copy of OpenBabel hasn't
been updated for a year or so. I don't see any relevant
changes in version control though.

I traced obconversion.GetSupportedInputFormat() as well,
and it's quite simple. Starting from obconversion.cpp:

  std::vector<std::string> OBConversion::GetSupportedInputFormat()
  {
    vector<string> vlist;
    OBPlugin::ListAsVector("formats", "in", vlist);
    return vlist;
  }

it goes directly to plugin.cpp, and the core loop is:

        for(itr=Map.begin(); itr!=Map.end(); ++itr)
        {
          if(*(itr->first)=='_')//no listing when ID starts with '_'
            continue;
          if(onlyIDs)
            vlist.push_back(itr->first);
          else
          {
            string txt;
            if((itr->second)->Display(txt, param, itr->first))
              vlist.push_back(txt);
          }
        }

Basically, if it can do the following:

import openbabel as ob
print "plugins", repr(ob.OBPlugin_ListAsString("plugins", None))
print "formats", repr(ob.OBPlugin_ListAsString("formats", "ids"))

then I can't see why it can't recognize the "smi" format.

FWIW, I get:

>>> import openbabel as ob
>>> ob.OBPlugin_ListAsString("plugins", None)
'charges\ndescriptors\nfingerprints\nforcefields\nformats\nloaders\nops\n'
>>> ob.OBPlugin_ListAsString("formats", "ids")
'abinit\nacesin\nacesout\nacr\nadf\nadfout\nalc\narc\nascii\naxsf\nbgf\nbox\nbs\nc09out\nc3d1\nc3d2\ncac\ncaccrt\ncache\ncacint\ncan\ncar\ncastep\nccc\ncdx\ncdxml\ncht\ncif\nck\ncml\ncmlr\ncom\nCONFIG\nCONTCAR\ncopy\ncrk2d\ncrk3d\ncsr\ncssr\nct\ncub\ncube\ndat\ndmol\ndx\nent\nfa\nfasta\nfch\nfchk\nfck\nfeat\nfh\nfhiaims\nfix\nfps\nfpt\nfract\nfs\nfsa\ng03\ng09\ng92\ng94\ng98\ngal\ngam\ngamess\ngamin\ngamout\ngau\ngjc\ngjf\ngot\ngpr\ngr96\ngro\ngukin\ngukout\ngzmat\nhin\nHISTORY\ninchi\ninchikey\ninp\nins\njin\njout\nk\nlmpdat\nlog\nmcdl\nmcif\nmdl\nml2\nmmcif\nmmd\nmmod\nmna\nmol\nmol2\nmold\nmolden\nmolf\nmolreport\nmoo\nmop\nmopcrt\nmopin\nmopout\nmp\nmpc\nmpd\nmpo\nmpqc\nmpqcin\nmrv\nmsi\nmsms\nnul\nnw\nnwo\nobapi\nout\noutmol\noutput\npaint\npc\npcm\npdb\npdbqt\npng\npos\nPOSCAR\npov\npqr\npqs\nprep\npwscf\nqcin\nqcout\nreport\nres\nrsmi\nrxn\nsd\nsdf\nsmi\nsmiles\nsvg\nsy2\nt41\ntdd\ntext\ntherm\ntmol\ntxt\ntxyz\nunixyz\nVASP\nvmol\nxed\nxml\nxsf\nxyz\nyob\nzin\n'





                                Andrew
                                da...@dalkescientific.com



------------------------------------------------------------------------------
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to