Skip to content

Commit

Permalink
For #155; also replace exclude batch with POINTLESS; efficiently comp…
Browse files Browse the repository at this point in the history
…ress batches for command interface using https://docs.python.org/2.6/library/itertools.html#examples
  • Loading branch information
graeme-winter committed Jul 7, 2017
1 parent 43f6b08 commit 2827897
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Experts/ResolutionExperts.py
Expand Up @@ -21,7 +21,6 @@
import time

from xia2.Wrappers.CCP4.Pointless import Pointless
from xia2.Wrappers.CCP4.Rebatch import Rebatch
from xia2.Handlers.Streams import Debug

# global parameters
Expand Down Expand Up @@ -588,14 +587,11 @@ def remove_blank(hklin, hklout):
Debug.write('%d blank vs. %d good: ignore' % (len(blanks), len(goods)))
return hklin

rb = Rebatch()
rb.set_hklin(hklin)
rb.set_hklout(hklout)

for b in blanks:
rb.exclude_batch(b)

rb.exclude_batches()
pl = Pointless()
pl.set_hklin(hklin)
pl.set_hklout(hklout)
pl.exclude_batch(blanks)
pl.exclude_batches()

return hklout

Expand Down
26 changes: 26 additions & 0 deletions Wrappers/CCP4/Pointless.py
Expand Up @@ -297,6 +297,32 @@ def limit_batches(self, first, last):
self.close_wait()
return

def compact_batches(self, batches):
'''Pack down batches to lists of continuous batches.'''
from operator import itemgetter
from itertools import groupby
return [map(itemgetter(1), g) for k, g in groupby(enumerate(batches),
lambda (i,x):i-x)]

def exclude_batches(self, batches):
'''Replacement for rebatch, removing batches.'''

self.check_hklin()
self.check_hklout()

self.add_command_line('-c')

self.start()

for b in compact_batches(batches):
if len(b) == 1:
self.input('exclude batch %d' % b[0])
else:
self.input('exclude batch %d to %d' % (b[0], b[-1]))

self.close_wait()
return

def xds_to_mtz(self):
'''Use pointless to convert XDS file to MTZ.'''

Expand Down

0 comments on commit 2827897

Please sign in to comment.