Answers.Body: <p>It sounds like you are saying your file is already sorted? Is this correct?</p>
  <p>RDKit Mae supplier is an iterator as is the gzip reader, so does not load all in memory, so that is the best option given that loading all 1e6 into memory crashes your system. What is the fraction of unreadable compounds in RDKit? And does it matter? These are likely failing sanitisation —the <code>sanitize=False</code> flag. If for some reason none can be ignored, circumventing this is hard. The <code>removeHs=True</code> flag is rarely/never the cause even though the description of several aromatics require protons, e.g. an indole ring is <code>c1ccc2c(c1)cc[nH]2</code>, the proton removal happens after loading. If you have an identifier and a list of SMILES you can correct dodgy bond orders etc. But making an unsanitisable molecule sanitary is tricky and rarely worth it as the output molecule is likely rubbish anyway.
  Plus loading in RDKit will allow you do some additional calculations, such as ligand efficiency (best for sorting anyway), partition coefficient etc etc. As opposed to simply slicing your sorted file.</p>
  <p>Alternatively, I believe Open Babel does not load all into memory and has a <code>splitinto</code> argument to make the file smaller and can convert gzipped Mae file to SDF.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-09T08:48:41.250Z
Answers.LastActivityDate: 2021-06-09T08:48:41.250Z
Answers.UserDisplayName: Matteo Ferla
Body: <p>My VLS run completed yielding millions of ligands and I would like to extract top-scored 20000 ligands in a separate file. Incorporating the .maegz output in Maestro is not an option as it fills up all the memory and keeps crashing. Are there any command-line options for this task?</p>
  <p>PS: I tried using rdkit in python to parse the output file after converting it to .sdf, however, rdkit skipped some ligands that it could not read.</p>
  
Tags: <format-conversion><docking>
Title: How to extract docked ligands from .maegz docking results file sorted by glide gscores in Schrodinger Maestro?
ThreadText: # How to extract docked ligands from .maegz docking results file sorted by glide gscores in Schrodinger Maestro?
  
  (Asked by: username_0 on 2021-06-07)
  
  My VLS run completed yielding millions of ligands and I would like to extract top-scored 20000 ligands in a separate file. Incorporating the .maegz output in Maestro is not an option as it fills up all the memory and keeps crashing. Are there any command-line options for this task?
  
  PS: I tried using rdkit in python to parse the output file after converting it to .sdf, however, rdkit skipped some ligands that it could not read.
  
  **Tags:** format-conversion, docking
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-09. Score: 1
  
  It sounds like you are saying your file is already sorted? Is this correct?
  
  RDKit Mae supplier is an iterator as is the gzip reader, so does not load all in memory, so that is the best option given that loading all 1e6 into memory crashes your system. What is the fraction of unreadable compounds in RDKit? And does it matter? These are likely failing sanitisation —the `sanitize=False` flag. If for some reason none can be ignored, circumventing this is hard. The `removeHs=True` flag is rarely/never the cause even though the description of several aromatics require protons, e.g. an indole ring is `c1ccc2c(c1)cc[nH]2`, the proton removal happens after loading. If you have an identifier and a list of SMILES you can correct dodgy bond orders etc. But making an unsanitisable molecule sanitary is tricky and rarely worth it as the output molecule is likely rubbish anyway.
  Plus loading in RDKit will allow you do some additional calculations, such as ligand efficiency (best for sorting anyway), partition coefficient etc etc. As opposed to simply slicing your sorted file.
  
  Alternatively, I believe Open Babel does not load all into memory and has a `splitinto` argument to make the file smaller and can convert gzipped Mae file to SDF.
  
  
  ---
  
  