Silencing all Modeller output
Hi,
I wonder if there is a way to silence all output when running automodel. I have set modeller.log.none() at the beginning of the script, but I still get a bunch of output:
0 atoms in HETATM/BLK residues constrained to protein atoms within 2.30 angstroms and protein CA atoms within 10.00 angstroms 0 atoms in residues without defined topology constrained to be rigid bodies >> Model assessment by DOPE potential DOPE score : -13973.771484 >> Model assessment by DOPE-HR potential DOPE-HR score : -7906.894043 >> Model assessment by DOPE potential DOPE score : -13973.771484 >> Normalized DOPE z score: -0.645 [...] >> Summary of successfully produced models: Filename molpdf DOPE score DOPE-HR score GA341 score Normalized DOPE score ----------------------------------------------------------------------------------------------------------- MODEL.B999910001.pdb 12623.23730 -13973.77148 -7906.89404 1.00000 -0.64460 MODEL.B999910002.pdb 12689.78906 -13755.89648 -7777.28760 1.00000 -0.54034 [...]
I have also tried to redirect stdout to /dev/null from Python while Modeller runs, without effect, so I guess this must be coming from a compiled printf. Is there any other way I am overlooking? In my case I have several processes running in parallel, and all my output is cluttered by this.
Thank you,
David.
On 3/25/15 8:14 AM, David Menéndez Hurtado wrote: > I wonder if there is a way to silence all output when running > automodel. I have set modeller.log.none() at the beginning of the > script, but I still get a bunch of output:
Sure. log.none() silences the logging from the Modeller internals, but there's still a handful of places in automodel where plain old Python "print" is used, and that isn't affected.
> I have also tried to redirect stdout to /dev/null from Python while > Modeller runs, without effect, so I guess this must be coming from a > compiled printf.
I have no idea what a "compiled printf" is, but all Modeller output is routed to Python's sys.stdout, so you can definitely redirect that in Python (or even do something fancy, like reassign it to some other filelike object, like a StringIO) or from the command line (e.g. with the > operator). So I'm not sure what you're doing here.
Ben Webb, Modeller Caretaker
On Wed, Mar 25, 2015 at 5:20 PM, Modeller Caretaker modeller-care@salilab.org wrote: > On 3/25/15 8:14 AM, David Menéndez Hurtado wrote: >> I have also tried to redirect stdout to /dev/null from Python while >> Modeller runs, without effect, so I guess this must be coming from a >> compiled printf. > > > I have no idea what a "compiled printf" is, but all Modeller output is > routed to Python's sys.stdout, so you can definitely redirect that in Python > (or even do something fancy, like reassign it to some other filelike object, > like a StringIO) or from the command line (e.g. with the > operator). So I'm > not sure what you're doing here.
Indeed, you are right. I was redirecting the output using:
_stdout = sys.stdout sys.stdout = open(os.devnull, 'w') [run modeller] sys.stdout.close() sys.stdout = _stdout
But somewhere along the road I made a mistake, and it was still showing up; so I assumed the output came from a compiled extension, that cannot be redirected. Sorry about that.
In case this is helpful for anyone else, here is my final solution. ContactModel inherits from and replaces automodel because I am adding some restraints. Now make() is completely silent.
class ShutUp(object): def __enter__(self): self._stdout = sys.stdout sys.stdout = open(os.devnull, 'w')
def __exit__(self, *args): sys.stdout.close() sys.stdout = self._stdout
class ContactModel(modeller.automodel.automodel): [...] def make(self): with ShutUp(): super(ContactModel, self).make()
/David.
participants (2)
-
David Menéndez Hurtado
-
Modeller Caretaker