In case anybody is willing I have attached a patch.  This introduces a
new option 'r' which, when set, switches off residue number appending
unless 'l' is also set and residue name is simply '<1>'.  The defaults
are as they used to be.

On Mon, 14 Jul 2014 12:03:45 +0100
Hannes Loeffler <hannes.loeff...@stfc.ac.uk> wrote:

> Hi,
> 
> here is something that has bugged me for some time now and is quite an
> annoying misfeature of MOL2Format::WriteMolecule().  In line 591 of
> src/formats/mol2format.cpp (checked out just a minute ago) the residue
> name is appended with its number (res->GetNum()).
> 
> The practical problem is that whenever I change the residue name to a
> desired string in my Python script I get a modified residue on
> output.  This is obviously exacerbated by multiple read/writes.
> 
> If this is really a vital option to some I think it should be possible
> to switch this off with a write option.
> 
> Cheers,
> Hannes.


-- 
Scanned by iCritical.
--- mol2format.cpp.orig	2014-07-23 13:37:43.000000000 +0100
+++ mol2format.cpp	2014-07-23 13:44:59.000000000 +0100
@@ -34,6 +34,7 @@
       OBConversion::RegisterFormat("ml2",this);
       OBConversion::RegisterFormat("sy2",this);
       OBConversion::RegisterOptionParam("l", NULL, 0, OBConversion::OUTOPTIONS);
+      OBConversion::RegisterOptionParam("r", NULL, 0, OBConversion::OUTOPTIONS);
     }
 
     virtual const char* Description() //required
@@ -42,6 +43,7 @@
         "Sybyl Mol2 format\n"
         "Write Options e.g. -xl\n"
         "  l               Output ignores residue information (only ligands)\n\n";
+        "  r               Output does not append residue number to residue name\n\n";
     };
 
     virtual const char* SpecificationURL()
@@ -503,6 +505,7 @@
     ostream &ofs = *pConv->GetOutStream();
     OBMol &mol = *pmol;
     bool ligandsOnly = pConv->IsOption("l", OBConversion::OUTOPTIONS)!=NULL;
+    bool resNum = pConv->IsOption("r", OBConversion::OUTOPTIONS)!=NULL;
 
     //The old code follows....
     string str,str1;
@@ -588,7 +591,11 @@
             // use original atom names defined by residue
             snprintf(label,BUFF_SIZE,"%s",(char*)res->GetAtomID(atom).c_str());
             // make sure that residue name includes its number
-            snprintf(rlabel,BUFF_SIZE,"%s%d",res->GetName().c_str(), res->GetNum());
+            if (resNum) {
+              snprintf(rlabel,BUFF_SIZE,"%s",res->GetName().c_str());
+            } else {
+              snprintf(rlabel,BUFF_SIZE,"%s%d",res->GetName().c_str(), res->GetNum());
+            }
             snprintf(rnum,BUFF_SIZE,"%d",res->GetNum());
           }
 
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to