Skip to content

Commit

Permalink
xia2.ispyb_xml: include pipeline name in processingPrograms field
Browse files Browse the repository at this point in the history
  • Loading branch information
rjgildea committed Jun 13, 2018
1 parent d144fd0 commit 2ce6410
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 7 additions & 2 deletions Interfaces/ISPyB/ISPyBXmlHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import time

from xia2.Handlers.Files import FileHandler
from xia2.Handlers.Phil import PhilIndex

def sanitize(path):
'''Replace double path separators with single ones.'''
Expand Down Expand Up @@ -110,7 +111,10 @@ def write_scaling_statistics(self, fout, scaling_stats_type, stats_dict):

fout.write('</AutoProcScalingStatistics>\n')

def write_xml(self, file, command_line=''):
def write_xml(self, file, command_line='', working_phil=None):
if working_phil is not None:
PhilIndex.merge_phil(working_phil)
params = PhilIndex.get_python_object()

fout = open(file, 'w')

Expand Down Expand Up @@ -234,10 +238,11 @@ def write_xml(self, file, command_line=''):
from xia2.Handlers.CommandLine import CommandLine
command_line = CommandLine.get_command_line()

pipeline = params.xia2.settings.pipeline
fout.write('<AutoProcProgramContainer><AutoProcProgram>')
fout.write('<processingCommandLine>%s</processingCommandLine>' \
% sanitize(command_line))
fout.write('<processingPrograms>xia2</processingPrograms>')
fout.write('<processingPrograms>xia2 %s</processingPrograms>' % pipeline)
fout.write('</AutoProcProgram>')

from xia2.Handlers.Environment import Environment
Expand Down
12 changes: 8 additions & 4 deletions command_line/ispyb_xml.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
from __future__ import absolute_import, division, print_function

import os
import libtbx.load_env
import iotbx.phil
from xia2.Interfaces.ISPyB.ISPyBXmlHandler import ISPyBXmlHandler
from xia2.Schema.XProject import XProject

def ispyb_xml(xml_out):
from xia2.Interfaces.ISPyB.ISPyBXmlHandler import ISPyBXmlHandler
import os
assert os.path.exists('xia2.json')
assert os.path.exists('xia2.txt')
assert os.path.exists('xia2-working.phil')
command_line = ''
for record in open('xia2.txt'):
if record.startswith('Command line:'):
command_line = record.replace('Command line:', '').strip()
from xia2.Schema.XProject import XProject
with open('xia2-working.phil', 'rb') as f:
working_phil = iotbx.phil.parse(f.read())
xinfo = XProject.from_json(filename='xia2.json')
crystals = xinfo.get_crystals()
assert len(crystals) == 1
crystal = next(crystals.itervalues())
ISPyBXmlHandler.add_xcrystal(crystal)
ISPyBXmlHandler.write_xml(xml_out, command_line)
ISPyBXmlHandler.write_xml(xml_out, command_line, working_phil=working_phil)

if __name__ == '__main__':
import sys
Expand Down

0 comments on commit 2ce6410

Please sign in to comment.