My initial concern was that Avogadro, in conjuction with OpenBabel,
did really weird things when attempting to insert a SMILES fragment
such as "FS(F)(F)(F)(F)F": two of the fluorine atoms are superposed,
and the UFF optimization performed by default did not succeed in
splitting them (manual manipulation works, though).  Furthermore,
attempting to insert the SMILES fragment "F[U](F)(F)(F)(F)F" failed
completely, freezing Avogadro.

My understanding from the source code is this is an OpenBabel issue
(as well as a missed opportunity for a warning in avogadro):  the
current code results in atoms with atom->GetHyb() == 0, and the
builder.cpp code fails to deal with these in rather bad ways.

I don't have a fix that's of sufficient quality to go into the code
yet, but maybe the attached patch is good as a proof of concept, at
least:  it introduces new GetHyb() values of 4 and 5 for atoms such as
P in PF5 and S in SF6, respectively (I'm not a chemist, but the
wikipedia article appears to refer to those as sp3d hybridisation and
sp3d2 hybridisation, respectively).  It adds INTHYB patterns for
recognising 5-valent and 6-valent atoms, as well as forcing
(incorrectly, for testing) Mo and Cr to always have the new hyb
values.  It adds support for those hyb values in builder.cpp, but only
in the 0/3-dimensional case.

Does it make sense to have new GetHyb() values, and if so, are 4 and 5
the right choices?  Are there hypervalent molecules with double bonds
which are not tetrahedral in shape (my understanding is H3PO4 is
tetrahedral around the P atom)?  (Again going on wikipedia, sulfur
trioxide might be planar, but the UFF optimisation disagrees.  This is
potentially a bug in the UFF implementation).

Is it intentional that GetHyb() returns 0 for unrecognised atoms?  If
so, should builder.cpp deal with this?  As a fallback, would random
atom positioning be better than having several atoms at the same
coordinates?

In order to see this code in action, it might be helpful to apply this
patch to git avogadro to remove the UFF optimisation:

diff --git a/libavogadro/src/extensions/insertfragmentextension.cpp
b/libavogadro/src/extensions/insertfragmentextension.cpp
index a937194..52741d9 100644
--- a/libavogadro/src/extensions/insertfragmentextension.cpp
+++ b/libavogadro/src/extensions/insertfragmentextension.cpp
@@ -114,14 +114,16 @@ namespace Avogadro {
           {
             builder.Build(obfragment);

-            OBForceField* pFF =  OBForceField::FindForceField("UFF");
-            if (pFF && pFF->Setup(obfragment)) {
-              pFF->ConjugateGradients(250, 1.0e-4);
-              pFF->UpdateCoordinates(obfragment);
-            }
+           if (0) {
+             OBForceField* pFF =  OBForceField::FindForceField("UFF");
+             if (pFF && pFF->Setup(obfragment)) {
+               pFF->ConjugateGradients(250, 1.0e-4);
+               pFF->UpdateCoordinates(obfragment);
+             }
+           }

             fragment.setOBMol(&obfragment);
-            fragment.addHydrogens();
+            //fragment.addHydrogens();
             fragment.center();
           }
       }

(end of patch).
Index: src/builder.cpp
===================================================================
--- src/builder.cpp	(revision 3640)
+++ src/builder.cpp	(working copy)
@@ -143,11 +143,13 @@
 
   vector3 OBBuilder::GetNewBondVector(OBAtom *atom, double length) 
   {
-    vector3 bond1, bond2, bond3, v1, v2, newbond;
+    vector3 bond1, bond2, bond3, bond4, bond5, v1, v2, newbond;
     
     bond1 = VZero;
     bond2 = VZero;
     bond3 = VZero;
+    bond4 = VZero;
+    bond5 = VZero;
     
     if (atom == NULL)
       return VZero;
@@ -226,222 +228,377 @@
           newbond = bond1 - v2 * tan(DEG_TO_RAD*60.0);
         else if (atom->GetHyb() == 3)
           newbond = bond1 - v2 * tan(DEG_TO_RAD*70.5);
-        
+	else if (atom->GetHyb() == 4) {
+	  /* the first two atoms are the axial ones;  the third, fourth, and fifth atom are equatorial */
+          newbond = bond1;
+	} else if (atom->GetHyb() == 5) {
+          newbond = bond1 - v2 * tan(DEG_TO_RAD*90.0);
+	}
+
         newbond = newbond.normalize();
         newbond *= length;
         newbond += atom->GetVector();
         return newbond;
       }
-    
-    //
-    //    \         \
-    //     X  --->   X--*
-    //    /         /
-    //
-    if (atom->GetValence() == 2) {
-      FOR_NBORS_OF_ATOM (nbr, atom) {
-        if (bond1 == VZero)
-          bond1 = atom->GetVector() - nbr->GetVector();
-        else
-          bond2 = atom->GetVector() - nbr->GetVector();
-      }
+      
+      //	
+      //    \	      \
+      //     X  --->   X--*
+      //    /         /
+      //
+      if (atom->GetValence() == 2) {
+	FOR_NBORS_OF_ATOM (nbr, atom) {
+	  if (bond1 == VZero)
+	    bond1 = atom->GetVector() - nbr->GetVector();
+	  else if (bond2 == VZero)
+	    bond2 = atom->GetVector() - nbr->GetVector();
+	}
 
-      bond1 = bond1.normalize();
-      bond2 = bond2.normalize();
-      v1 = bond1 + bond2;
-      v1 = v1.normalize();
-     
-      if (atom->GetHyb() == 2)
-        newbond = v1;
-      if (atom->GetHyb() == 3) {
-        v2 = cross(bond1, bond2);
-        //v1 = v1.normalize();
-        newbond = v2 + v1 * tan(DEG_TO_RAD*35.25);
+	bond1 = bond1.normalize();
+	bond2 = bond2.normalize();
+	v1 = bond1 + bond2;
+	v1 = v1.normalize();
+	
+	if (atom->GetHyb() == 2)
+	  newbond = v1;
+	if (atom->GetHyb() == 3) {
+	  v2 = cross(bond1, bond2);
+	  //v1 = v1.normalize();
+	  newbond = v2 + v1 * tan(DEG_TO_RAD*35.25);
+	}
+	if (atom->GetHyb() == 4) {
+	  /* add the first equatorial atom, orthogonally to bond1 (and bond2 = -bond1) */
+	  /* is atom order correct?  I don't think it matters, but I might have to ask a chemist
+	   * whether PClF4 would be more likely to have an equatorial or axial Cl-P bond */
+          v1 = cross(bond1, VY);
+	  if (v1 == VZero) // This corner-case happened to me, where bond1 was -VY (Noel)
+	    v1 = cross(bond1, VX);
+	  v1 = v1.normalize();
+	  newbond = v1;
+	}
+	if (atom->GetHyb() == 5) {
+	  v2 = cross(bond1, bond2);
+	  newbond = v2;
+	}
+      
+	newbond = newbond.normalize();
+	newbond *= length;
+	newbond += atom->GetVector();
+	return newbond;
       }
       
-      newbond = newbond.normalize();
-      newbond *= length;
-      newbond += atom->GetVector();
-      return newbond;
-    }
     
-    
-    //
-    //    \          \
-    //   --X  --->  --X--*
-    //    /          /
-    //
-    if (atom->GetValence() == 3) {
-      FOR_NBORS_OF_ATOM (nbr, atom) {
-        if (bond1 == VZero)
-          bond1 = atom->GetVector() - nbr->GetVector();
-        else if (bond2 == VZero)
-          bond2 = atom->GetVector() - nbr->GetVector();
-        else
-          bond3 = atom->GetVector() - nbr->GetVector();
+      /* UFF:
+       *    b lg dg  o  y
+       *  b - 45 30 45 30
+       * lg    - 45  0 45
+       * dg       - 45 30
+       *  o          - 45
+       *  y             -
+
+       * 94s:
+       *    b lg dg  o  y
+       *  b - 34 34 34 34
+       * lg    - 48 21 48
+       * dg       - 48 21
+       *  o          - 48
+       *  y             -
+
+      //
+      //    \	       \
+      //   --X  --->  --X--*
+      //    /          /
+      //
+      */
+      if (atom->GetValence() == 3) {
+	if (atom->GetHyb() == 3) {
+	  FOR_NBORS_OF_ATOM (nbr, atom) {
+	    if (bond1 == VZero)
+	      bond1 = atom->GetVector() - nbr->GetVector();
+	    else if (bond2 == VZero)
+	      bond2 = atom->GetVector() - nbr->GetVector();
+	    else if (bond3 == VZero)
+	      bond3 = atom->GetVector() - nbr->GetVector();
+	  }
+	
+	  bond1 = bond1.normalize();
+	  bond2 = bond2.normalize();
+	  bond3 = bond3.normalize();
+	  newbond = bond1 + bond2 + bond3;
+	  newbond = newbond.normalize();
+	  newbond *= length;
+	  newbond += atom->GetVector();
+	  return newbond;
+	}
+      
+	if (atom->GetHyb() == 4) {
+	  FOR_NBORS_OF_ATOM (nbr, atom) {
+	    if (bond1 == VZero)
+	      bond1 = atom->GetVector() - nbr->GetVector();
+	    else if (bond2 == VZero)
+	      bond2 = atom->GetVector() - nbr->GetVector();
+	    else if (bond3 == VZero)
+	      bond3 = atom->GetVector() - nbr->GetVector();
+	  }
+	  
+	  bond1 = bond1.normalize();
+	  bond2 = bond2.normalize();
+	  bond3 = bond3.normalize();
+
+          v1 = cross(bond1, bond3);
+	  v1 = v1.normalize();
+
+	  newbond = v1 + tan(DEG_TO_RAD*30.0) * bond3;
+	  newbond = newbond.normalize();
+	  newbond *= length;
+	  newbond += atom->GetVector();
+	  return newbond;
+
+	}
+
+	if (atom->GetHyb() == 5) {
+	  FOR_NBORS_OF_ATOM (nbr, atom) {
+	    if (bond1 == VZero)
+	      bond1 = atom->GetVector() - nbr->GetVector();
+	    else if (bond2 == VZero)
+	      bond2 = atom->GetVector() - nbr->GetVector();
+	    else if (bond3 == VZero)
+	      bond3 = atom->GetVector() - nbr->GetVector();
+	  }
+
+	  /* the way things work, newbond is equal to bond1, but will show up at -bond1 next time around */
+	  newbond = bond1;
+	  newbond = newbond.normalize();
+	  newbond *= length;
+	  newbond += atom->GetVector();
+	  return newbond;
+	}
       }
-          
-      bond1 = bond1.normalize();
-      bond2 = bond2.normalize();
-      bond3 = bond3.normalize();
-      newbond = bond1 + bond2 + bond3;
-      newbond = newbond.normalize();
-      newbond *= length;
-      newbond += atom->GetVector();
-      return newbond;
-    }
 
-  } else {
-    ////////////
-    //   2D   //
-    ////////////
-    OBBondIterator i;
+      if (atom->GetValence() == 4) {
+	if (atom->GetHyb() == 5) {
+	  FOR_NBORS_OF_ATOM (nbr, atom) {
+	    if (bond1 == VZero)
+	      bond1 = atom->GetVector() - nbr->GetVector();
+	    else if (bond2 == VZero)
+	      bond2 = atom->GetVector() - nbr->GetVector();
+	    else if (bond3 == VZero)
+	      bond3 = atom->GetVector() - nbr->GetVector();
+	    else if (bond4 == VZero)
+	      bond4 = atom->GetVector() - nbr->GetVector();
+	  }
       
-    //
-    //  a   --->   a---*
-    //
-    if (atom->GetValence() == 0) {
-      newbond = atom->GetVector() + VX * length;
-      // Check that the vector is still finite before returning
-      if (!isfinite(newbond.x()) || !isfinite(newbond.y()))
-        newbond.Set(0.0, 0.0, 0.0);
-      return newbond;
-    }
+	  newbond = bond2;
+	  newbond = newbond.normalize();
+	  newbond *= length;
+	  newbond += atom->GetVector();
+	  return newbond;
+	}
 
-    // hyb * = 1                                                                //
-    // ^^^^^^^^^                                                                //
-    //                                                                          //
-    //   (a-1)--a   --->   (a-1)--a--*        angle(a-1, a, *) = 180            //
-    //                                                                          //
-    // hyb * = 2                                                                //
-    // ^^^^^^^^^                                                                //
-    // make sure we place the new atom trans to a-2 (if there is an a-2 atom)   //
-    //                                                                          //
-    //   (a-2)             (a-2)                                                //
-    //     \                 \                                                  //
-    //    (a-1)==a   --->   (a-1)==a          angle(a-1, a, *) = 120            //
-    //                              \                                           //
-    //                               *                                          //
-    // hyb * = 3                                                                //
-    // ^^^^^^^^^                                                                //
-    // make sure we place the new atom trans to a-2 (if there is an a-2 atom)   //
-    //                                                                          //
-    //   (a-2)             (a-2)                                                //
-    //     \                 \                                                  //
-    //    (a-1)--a   --->   (a-1)--a          angle(a-1, a, *) = 109            //
-    //                              \                                           //
-    //                               *                                          //
-    if (atom->GetValence() == 1) {
-      OBAtom *nbr = atom->BeginNbrAtom(i);
-      if (!nbr)
-        return VZero;
-      bond1 = atom->GetVector() - nbr->GetVector(); // bond (a-1)--a
+	if (atom->GetHyb() == 4) {
+	  FOR_NBORS_OF_ATOM (nbr, atom) {
+	    if (bond1 == VZero)
+	      bond1 = atom->GetVector() - nbr->GetVector();
+	    else if (bond2 == VZero)
+	      bond2 = atom->GetVector() - nbr->GetVector();
+	    else if (bond3 == VZero) 
+	      bond3 = atom->GetVector() - nbr->GetVector();
+	    else if (bond4 == VZero)
+	      bond4 = atom->GetVector() - nbr->GetVector();
+	  }
+	  
+	  bond1 = bond1.normalize();
+	  bond2 = bond2.normalize();
+	  bond3 = bond3.normalize();
+	  bond4 = bond4.normalize();
 
-      for (OBAtom *nbr2 = nbr->BeginNbrAtom(i); nbr2; nbr2 = nbr->NextNbrAtom(i))
-        if (nbr2 != atom)
-          bond2 = nbr->GetVector() - nbr2->GetVector(); // bond (a-2)--(a-1)
+          v1 = cross(bond1, bond3);
+	  v1 = v1.normalize();
 
-      int hyb = atom->GetHyb();
-      if (hyb == 1)
-        newbond = bond1;
-      else if (hyb == 2 || hyb == 3) {
-        matrix3x3 m;
-        m.RotAboutAxisByAngle(VZ, 60.0);
-        newbond = m*bond1;
+	  newbond = -v1 + tan(DEG_TO_RAD*30.0) * bond3;
+	  newbond = newbond.normalize();
+	  newbond *= length;
+	  newbond += atom->GetVector();
+	  return newbond;
+
+	}
+
       }
-      newbond.normalize();
-      newbond *= length;
-      newbond += atom->GetVector();
-      return newbond;
-    } // GetValence() == 1
+
+      if (atom->GetValence() == 5) {
+	if (atom->GetHyb() == 5) {
+	  FOR_NBORS_OF_ATOM (nbr, atom) {
+	    if (bond1 == VZero)
+	      bond1 = atom->GetVector() - nbr->GetVector();
+	    else if (bond2 == VZero)
+	      bond2 = atom->GetVector() - nbr->GetVector();
+	    else if (bond3 == VZero)
+	      bond3 = atom->GetVector() - nbr->GetVector();
+	    else if (bond4 == VZero)
+	      bond4 = atom->GetVector() - nbr->GetVector();
+	    else if (bond5 == VZero)
+	      bond5 = atom->GetVector() - nbr->GetVector();
+	  }
+      
+	  newbond = bond3;
+	  newbond = newbond.normalize();
+	  newbond *= length;
+	  newbond += atom->GetVector();
+	  return newbond;
+	}
+      }
+    } else {
+      ////////////
+      //   2D   //
+      ////////////
+      OBBondIterator i;
+      
+      //
+      //  a   --->   a---*
+      //
+      if (atom->GetValence() == 0) {
+	newbond = atom->GetVector() + VX * length;
+	// Check that the vector is still finite before returning
+	if (!isfinite(newbond.x()) || !isfinite(newbond.y()))
+	  newbond.Set(0.0, 0.0, 0.0);
+	return newbond;
+      }
+
+      // hyb * = 1                                                                //
+      // ^^^^^^^^^                                                                //
+      //                                                                          //
+      //   (a-1)--a   --->   (a-1)--a--*        angle(a-1, a, *) = 180            //
+      //                                                                          //
+      // hyb * = 2                                                                //
+      // ^^^^^^^^^                                                                //
+      // make sure we place the new atom trans to a-2 (if there is an a-2 atom)   //
+      //                                                                          //
+      //   (a-2)             (a-2)                                                //
+      //     \                 \                                                  //
+      //    (a-1)==a   --->   (a-1)==a          angle(a-1, a, *) = 120            //
+      //                              \                                           //
+      //                               *                                          //
+      // hyb * = 3                                                                //
+      // ^^^^^^^^^                                                                //
+      // make sure we place the new atom trans to a-2 (if there is an a-2 atom)   //
+      //                                                                          //
+      //   (a-2)             (a-2)                                                //
+      //     \                 \                                                  //
+      //    (a-1)--a   --->   (a-1)--a          angle(a-1, a, *) = 109            //
+      //                              \                                           //
+      //                               *                                          //
+      if (atom->GetValence() == 1) {
+	OBAtom *nbr = atom->BeginNbrAtom(i);
+	if (!nbr)
+	  return VZero;
+	bond1 = atom->GetVector() - nbr->GetVector(); // bond (a-1)--a
+
+	for (OBAtom *nbr2 = nbr->BeginNbrAtom(i); nbr2; nbr2 = nbr->NextNbrAtom(i))
+	  if (nbr2 != atom)
+	    bond2 = nbr->GetVector() - nbr2->GetVector(); // bond (a-2)--(a-1)
+
+	int hyb = atom->GetHyb();
+	if (hyb == 1)
+	  newbond = bond1;
+	else if (hyb == 2 || hyb == 3 || hyb == 0) {
+	  matrix3x3 m;
+	  m.RotAboutAxisByAngle(VZ, 60.0);
+	  newbond = m*bond1;
+	}
+	newbond.normalize();
+	newbond *= length;
+	newbond += atom->GetVector();
+	return newbond;
+      } // GetValence() == 1
   
       //                          //
       //    \         \           //
       //     X  --->   X--*       //
       //    /         /           //
       //                          //
-    if (atom->GetValence() == 2) {
-      for (OBAtom *nbr = atom->BeginNbrAtom(i); nbr; nbr = atom->NextNbrAtom(i)) {
-        if (bond1 == VZero)
-          bond1 = atom->GetVector() - nbr->GetVector();
-        else
-          bond2 = atom->GetVector() - nbr->GetVector();
+      if (atom->GetValence() == 2) {
+	for (OBAtom *nbr = atom->BeginNbrAtom(i); nbr; nbr = atom->NextNbrAtom(i)) {
+	  if (bond1 == VZero)
+	    bond1 = atom->GetVector() - nbr->GetVector();
+	  else
+	    bond2 = atom->GetVector() - nbr->GetVector();
+	}
+	bond1.normalize();
+	bond2.normalize();
+	newbond = bond1 + bond2;
+	newbond.normalize();
+	newbond *= length;
+	newbond += atom->GetVector();
+	return newbond;
       }
-      bond1.normalize();
-      bond2.normalize();
-      newbond = bond1 + bond2;
-      newbond.normalize();
-      newbond *= length;
-      newbond += atom->GetVector();
-      return newbond;
-    }
 
-    //                          //
-    //    \          \          //
-    //   --X  --->  --X--*      //
-    //    /          /          //
-    //                          //
-    if (atom->GetValence() == 3) {
-      OBStereoFacade stereoFacade((OBMol*)atom->GetParent());
-      if (stereoFacade.HasTetrahedralStereo(atom->GetId())) {
-        OBBond *hash = 0;
-        OBBond *wedge = 0;
-        vector<OBBond*> plane;
-        for (OBAtom *nbr = atom->BeginNbrAtom(i); nbr; nbr = atom->NextNbrAtom(i)) {
-          OBBond *bond = atom->GetBond(nbr);
-
-          if (bond->IsWedge()) {
-            if (atom == bond->GetBeginAtom())
-              wedge = bond;
-            else
-              hash = bond;
-          } else 
-            if (bond->IsHash()) {
-              if (atom == bond->GetBeginAtom())
-                hash = bond;
-              else
-                wedge = bond;
-            } else
-              plane.push_back(bond);
-        }
-
-        if (wedge && !plane.empty()) {
-          bond2 = atom->GetVector() - wedge->GetNbrAtom(atom)->GetVector();
-          bond3 = atom->GetVector() - plane[0]->GetNbrAtom(atom)->GetVector();
-        } else if (hash && !plane.empty()) {
-          bond2 = atom->GetVector() - hash->GetNbrAtom(atom)->GetVector();
-          bond3 = atom->GetVector() - plane[0]->GetNbrAtom(atom)->GetVector();
-        } else if (plane.size() >= 2) {
-          bond2 = atom->GetVector() - plane[0]->GetNbrAtom(atom)->GetVector();
-          bond3 = atom->GetVector() - plane[1]->GetNbrAtom(atom)->GetVector();
-        } else if (hash && wedge) {
-          bond2 = atom->GetVector() - wedge->GetNbrAtom(atom)->GetVector();
-          bond3 = atom->GetVector() - hash->GetNbrAtom(atom)->GetVector();
-        }
-      } else {
-        for (OBAtom *nbr = atom->BeginNbrAtom(i); nbr; nbr = atom->NextNbrAtom(i)) {
-          if (bond1 == VZero)
-            bond1 = atom->GetVector() - nbr->GetVector();
-          else if (bond2 == VZero)
-            bond2 = atom->GetVector() - nbr->GetVector();
-          else
-            bond3 = atom->GetVector() - nbr->GetVector();
-        }
+      //                          //
+      //    \          \          //
+      //   --X  --->  --X--*      //
+      //    /          /          //
+      //                          //
+      if (atom->GetValence() == 3) {
+	OBStereoFacade stereoFacade((OBMol*)atom->GetParent());
+	if (stereoFacade.HasTetrahedralStereo(atom->GetId())) {
+	  OBBond *hash = 0;
+	  OBBond *wedge = 0;
+	  vector<OBBond*> plane;
+	  for (OBAtom *nbr = atom->BeginNbrAtom(i); nbr; nbr = atom->NextNbrAtom(i)) {
+	    OBBond *bond = atom->GetBond(nbr);
+	    
+	    if (bond->IsWedge()) {
+	      if (atom == bond->GetBeginAtom())
+		wedge = bond;
+	      else
+		hash = bond;
+	    } else 
+	      if (bond->IsHash()) {
+		if (atom == bond->GetBeginAtom())
+		  hash = bond;
+		else
+		  wedge = bond;
+	      } else
+		plane.push_back(bond);
+	  }
+	  
+	  if (wedge && !plane.empty()) {
+	    bond2 = atom->GetVector() - wedge->GetNbrAtom(atom)->GetVector();
+	    bond3 = atom->GetVector() - plane[0]->GetNbrAtom(atom)->GetVector();
+	  } else if (hash && !plane.empty()) {
+	    bond2 = atom->GetVector() - hash->GetNbrAtom(atom)->GetVector();
+	    bond3 = atom->GetVector() - plane[0]->GetNbrAtom(atom)->GetVector();
+	  } else if (plane.size() >= 2) {
+	    bond2 = atom->GetVector() - plane[0]->GetNbrAtom(atom)->GetVector();
+	    bond3 = atom->GetVector() - plane[1]->GetNbrAtom(atom)->GetVector();
+	  } else if (hash && wedge) {
+	    bond2 = atom->GetVector() - wedge->GetNbrAtom(atom)->GetVector();
+	    bond3 = atom->GetVector() - hash->GetNbrAtom(atom)->GetVector();
+	  }
+	} else {
+	  for (OBAtom *nbr = atom->BeginNbrAtom(i); nbr; nbr = atom->NextNbrAtom(i)) {
+	    if (bond1 == VZero)
+	      bond1 = atom->GetVector() - nbr->GetVector();
+	    else if (bond2 == VZero)
+	      bond2 = atom->GetVector() - nbr->GetVector();
+	    else
+	      bond3 = atom->GetVector() - nbr->GetVector();
+	  }
+	}
+	
+	bond2.normalize();
+	bond3.normalize();
+	newbond = -(bond2 + bond3);
+	newbond.normalize();
+	newbond *= length;
+	newbond += atom->GetVector();
+	return newbond;
       }
+      
+    }
 
-      bond2.normalize();
-      bond3.normalize();
-      newbond = -(bond2 + bond3);
-      newbond.normalize();
-      newbond *= length;
-      newbond += atom->GetVector();
-      return newbond;
-    }
-  
+  return VZero; //previously undefined
   }
 
-  return VZero; //previously undefined
-}
   
   // The OBMol mol contains both the molecule to which we want to connect the 
   // fragment and the fragment itself. The fragment containing b will be 
@@ -722,7 +879,6 @@
 //     }
   }
 
-
   // First we find the most complex fragments in our molecule. Once we have a match,
   // vfrag is set for all the atoms in the fragment. A second match (smaller, more 
   // simple part of the 1st match) is ignored.
@@ -823,7 +979,7 @@
                 // set coordinates for atoms
                 OBAtom *atom = workMol.GetAtom(*k);
                 atom->SetVector(i->second[counter]);
-              }
+             }
             }
 
             // add the bonds for the fragment
@@ -892,7 +1048,7 @@
       
       vdone.SetBitOn(a->GetIdx());
       
-      // place the atom the atom 
+      // place the atom
       OBAtom *atom = workMol.GetAtom(a->GetIdx());
       atom->SetVector(molvec);
 
Index: data/atomtyp.txt
===================================================================
--- data/atomtyp.txt	(revision 3640)
+++ data/atomtyp.txt	(working copy)
@@ -1,7 +1,8 @@
 ##############################################################################
 #                                                                            #
-#                   Open Babel file: atomtyp.txt                             # #                                                                            #
+#                   Open Babel file: atomtyp.txt                             #
 #                                                                            #
+#                                                                            #
 #  Copyright (c) 1998-2001 by OpenEye Scientific Software, Inc.              #
 #  Some portions Copyright (c) 2001-2008 Geoffrey R. Hutchison               #
 #  Part of the Open Babel package, under the GNU General Public License (GPL)#
@@ -20,7 +21,9 @@
 #                                                                            #
 ##############################################################################
 
-INTHYB  [D4]                      3       #any 4 valent atom
+INTHYB  [D4]                      3       #any 4-valent atom
+INTHYB  [D5]                      4       #any 5-valent atom
+INTHYB  [D6]                      5       #any 6-valent atom
 INTHYB  [C]                       3       #sp3 carbon
 INTHYB  [c,$(C=*)]                2       #sp2 carbon
 INTHYB  [$([#6]([#8D1])[#8D1])]   2       #sp2 carbon
@@ -38,8 +41,10 @@
 
 INTHYB  [P]                       3       #sp3 phosphorus
 INTHYB  [#15;$([PD1]=*)]          2       #sp2 phosphorus
+INTHYB  [PD5]			  4	  #sp3d phosphorus, as in PF5
 INTHYB  [S]                       3       #sp3 sulfur
 INTHYB  [#16;s,$([SD1]=*)]        2       #sp2 sulfur
+INTHYB  [SD6]			  5	  #sp3d2 sulfur, as in SF6
 INTHYB  [B]                       2       #sp2 boron
 INTHYB  [BD4]                     3       #sp3 boron
 
@@ -220,6 +225,10 @@
 
 ######################## Add Extra Definitions Here ##########################
 
+#INTHYB  [U]                      3
+#INTHYB  [W]                      3
+INTHYB  [Mo]			  5 # for development
+INTHYB  [Cr]			  4 # for development
 
 ############################# End Extra Definitions ##########################
 
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
OpenBabel-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to