Bugs item #3018188, was opened at 2010-06-18 15:53
Message generated for change (Tracker Item Submitted) made by fab5
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=428740&aid=3018188&group_id=40728

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Command-line Tools
Group: 2.3.x
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Fabian (fab5)
Assigned to: Nobody/Anonymous (nobody)
Summary: mol2formats.cpp : ReadMolecule()   efficiency

Initial Comment:

Hi,

Just a small efficiency issue when reading very large mol2-files 
(formats/mol2format.cpp) in 

bool MOL2Format::ReadMolecule(OBBase* pOb, OBConversion* pConv). 

The assignment of neighbor bond information to atoms is using an unnecessary 
amount of time and could
be split up into two loops (clearing and assigning). While stepping through the 
bond list, adding said 
bond directly to the "Begin" and "End" atom would make the function more 
efficient instead of always searching 
for the correct atom in the entire bond list (which can take a couple of 
seconds for very large
molecules). However the order of the neighbor bonds for a particular atom might 
be different than
before (does this matter?).

Hope this helps
Fabian

PS> I didn't check the other file formats if the same applies there too.


Original version starting on line 291 :

    for (patom = mol.BeginAtom(apos); patom; patom = mol.NextAtom(apos))
      {
        patom->ClearBond();
        for (pbond = mol.BeginBond(bpos); pbond; pbond = mol.NextBond(bpos))
          {
            if (patom == pbond->GetBeginAtom() || patom == pbond->GetEndAtom())
              {
                patom->AddBond(pbond);
              }
          }
      }



New version:

    for (patom = mol.BeginAtom(apos); patom; patom = mol.NextAtom(apos))
      {
        patom->ClearBond();
      }

    for (pbond = mol.BeginBond(bpos); pbond; pbond = mol.NextBond(bpos))
      {
        patom = pbond->GetBeginAtom();
        patom->AddBond(pbond);
        patom = pbond->GetEndAtom();
        patom->AddBond(pbond);
      }


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=428740&aid=3018188&group_id=40728

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
OpenBabel-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to