old_contents: import os
  import json
  import tempfile
  from indra.java_vm import autoclass, JavaException
  import indra.databases.pmc_client as pmc_client
  from processor import ReachProcessor
  
  
  def process_pmc(pmc_id):
      xml_str = pmc_client.get_xml(pmc_id)
      with tempfile.NamedTemporaryFile() as fh:
          fh.write(xml_str)
          fh.flush()
          rp = process_nxml(fh.name)
      return rp
          
  
  def process_nxml(file_name, use_tempdir=False):
      base = os.path.basename(file_name)
      file_id = os.path.splitext(base)[0]
      if use_tempdir:
          tmp_dir = tempfile.mkdtemp()
      else:
          tmp_dir = '.'
      try:
          paper_reader = autoclass('edu.arizona.sista.reach.ReadPaper')
          paper_reader.main([file_name, tmp_dir])
      except JavaException:
          print 'Could not process file %s.' % file_name
          return None
      
      json_file_name = os.path.join(tmp_dir, file_id + '.uaz.events.json')
      return process_json_file(json_file_name)
  
  def process_json_file(file_name):
      try:
          with open(file_name, 'rt') as fh:
              json_str = fh.read()
              return process_json_str(json_str)
      except IOError:
          print 'Could not read file %s.' % file_name
  
  
  def process_json_str(json_str):
      json_dict = json.loads(json_str)
      rp = ReachProcessor(json_dict)
      rp.get_phosphorylation()
      rp.get_complexes()
      return rp
  
  if __name__ == '__main__':
      rp = process_json_file('PMC0000001.uaz.events.json')
  
new_contents: import os
  import json
  import tempfile
  from indra.java_vm import autoclass, JavaException
  import indra.databases.pmc_client as pmc_client
  from processor import ReachProcessor
  
  
  def process_pmc(pmc_id):
      xml_str = pmc_client.get_xml(pmc_id)
      with tempfile.NamedTemporaryFile() as fh:
          fh.write(xml_str)
          fh.flush()
          rp = process_nxml(fh.name)
      return rp
  
  def process_text(txt, use_tempdir=False):
      nxml_txt = '<article><body><sec><p>%s</p></sec></body></article>' % txt
      tmp_file = tempfile.NamedTemporaryFile()
      tmp_file.file.write(nxml_txt)
      tmp_file.file.flush()
      return process_nxml(tmp_file.name)
  
  def process_nxml(file_name, use_tempdir=False):
      base = os.path.basename(file_name)
      file_id = os.path.splitext(base)[0]
      if use_tempdir:
          tmp_dir = tempfile.mkdtemp()
      else:
          tmp_dir = '.'
      try:
          paper_reader = autoclass('edu.arizona.sista.reach.ReadPaper')
          paper_reader.main([file_name, tmp_dir])
      except JavaException:
          print 'Could not process file %s.' % file_name
          return None
      
      json_file_name = os.path.join(tmp_dir, file_id + '.uaz.events.json')
      return process_json_file(json_file_name)
  
  def process_json_file(file_name):
      try:
          with open(file_name, 'rt') as fh:
              json_str = fh.read()
              return process_json_str(json_str)
      except IOError:
          print 'Could not read file %s.' % file_name
  
  
  def process_json_str(json_str):
      json_dict = json.loads(json_str)
      rp = ReachProcessor(json_dict)
      rp.get_phosphorylation()
      rp.get_complexes()
      return rp
  
  if __name__ == '__main__':
      rp = process_json_file('PMC0000001.uaz.events.json')
  
subject: Add process_text function to reach_api to allow reading pieces of text through the nxml reader