Example #1
0
def read_table(file_name):
    atomic_number = None
    number_of_electrons = None
    x = flex.double()
    y = flex.double()
    sigmas = flex.double()
    lf = line_feeder(open(file_name))
    while 1:
        line = next(lf)
        if (lf.eof): break
        if (line.startswith("   FORM: ATOMIC NUMBER=")):
            atomic_number = float(line.split("=")[1])
            assert int(atomic_number) == atomic_number
        elif (line.startswith("   FORM: # ELECTRONS=")):
            number_of_electrons = float(line.split("=")[1])
            assert int(number_of_electrons) == number_of_electrons
        elif (line.startswith("        X (1/A)")):
            assert atomic_number == number_of_electrons
            while 1:
                line = next(lf)
                assert not lf.eof
                if (line == " *** END OF DATA ***"):
                    lf.eof = True
                    break
                vals_str = line.split()
                for val_str in vals_str:
                    assert len(val_str) == 13
                x.append(float(vals_str[0]))
                y.append(float(vals_str[1]))
                assert vals_str[1][-4] == "E"
                sigmas.append(float("0.00000005" + vals_str[1][-4:]))
    return table(int(atomic_number), x, y * atomic_number, sigmas)
Example #2
0
def read_table(file_name):
    atomic_number = None
    number_of_electrons = None
    x = flex.double()
    y = flex.double()
    sigmas = flex.double()
    lf = line_feeder(open(file_name))
    while 1:
        line = lf.next()
        if lf.eof:
            break
        if line.startswith("   FORM: ATOMIC NUMBER="):
            atomic_number = float(line.split("=")[1])
            assert int(atomic_number) == atomic_number
        elif line.startswith("   FORM: # ELECTRONS="):
            number_of_electrons = float(line.split("=")[1])
            assert int(number_of_electrons) == number_of_electrons
        elif line.startswith("        X (1/A)"):
            assert atomic_number == number_of_electrons
            while 1:
                line = lf.next()
                assert not lf.eof
                if line == " *** END OF DATA ***":
                    lf.eof = True
                    break
                vals_str = line.split()
                for val_str in vals_str:
                    assert len(val_str) == 13
                x.append(float(vals_str[0]))
                y.append(float(vals_str[1]))
                assert vals_str[1][-4] == "E"
                sigmas.append(float("0.00000005" + vals_str[1][-4:]))
    return table(int(atomic_number), x, y * atomic_number, sigmas)
def read_table6111(file_name):
    tab = table6111(file_name)
    lf = line_feeder(open(file_name))
    while 1:
        line = next(lf)
        if (lf.eof): break
        if (line.startswith("Element")):
            elements = line.split()[1:]
            line = next(lf)
            assert line.lstrip().startswith("Z"), line
            atomic_numbers = [int(z) for z in line.split()[1:]]
            assert len(atomic_numbers) == len(elements), line
            line = next(lf)
            assert line.startswith("Method"), line
            methods = line.split()[1:]
            assert len(methods) == len(elements), line
            line = next(lf)
            assert line.find("sin") > 0, line
            stols = flex.double()
            value_rows = []
            sigma_rows = []
            while 1:
                line = next(lf)
                assert not lf.eof
                if (len(line.strip()) == 0): continue
                raw_value_row = line.rstrip().split("\t")
                assert len(raw_value_row) == len(elements) + 1, line
                stols.append(float(raw_value_row[0]))
                assert stols[-1] == international_tables_stols[stols.size() -
                                                               1], line
                value_row = flex.double()
                sigma_row = flex.double()
                for value in raw_value_row[1:]:
                    if (len(value.strip()) == 0):
                        value_row.append(-1)
                        sigma_row.append(-1)
                    else:
                        try:
                            value_row.append(float(value))
                        except ValueError as e:
                            raise ValueError(line)
                        assert value.count(".") == 1
                        sigma = ""
                        for c in value.strip():
                            if (c == "."):
                                sigma += "."
                            else:
                                assert c in "0123456789"
                                sigma += "0"
                        sigma += "5"
                        sigma_row.append(float(sigma))
                value_rows.append(value_row)
                sigma_rows.append(sigma_row)
                if (stols.size() == 62):
                    assert stols[-1] == 6, line
                    break
            tab.enter_block(elements, atomic_numbers, methods, value_rows,
                            sigma_rows)
    return tab
def read_table6111(file_name):
  tab = table6111(file_name)
  lf = line_feeder(open(file_name))
  while 1:
    line = lf.next()
    if (lf.eof): break
    if (line.startswith("Element")):
      elements = line.split()[1:]
      line = lf.next()
      assert line.lstrip().startswith("Z"), line
      atomic_numbers = [int(z) for z in line.split()[1:]]
      assert len(atomic_numbers) == len(elements), line
      line = lf.next()
      assert line.startswith("Method"), line
      methods = line.split()[1:]
      assert len(methods) == len(elements), line
      line = lf.next()
      assert line.find("sin") > 0, line
      stols = flex.double()
      value_rows = []
      sigma_rows = []
      while 1:
        line = lf.next()
        assert not lf.eof
        if (len(line.strip()) == 0): continue
        raw_value_row = line.rstrip().split("\t")
        assert len(raw_value_row) == len(elements) + 1, line
        stols.append(float(raw_value_row[0]))
        assert stols[-1] == international_tables_stols[stols.size()-1], line
        value_row = flex.double()
        sigma_row = flex.double()
        for value in raw_value_row[1:]:
          if (len(value.strip()) == 0):
            value_row.append(-1)
            sigma_row.append(-1)
          else:
            try: value_row.append(float(value))
            except ValueError, e: raise ValueError(line)
            assert value.count(".") == 1
            sigma = ""
            for c in value.strip():
              if (c == "."):
                sigma += "."
              else:
                assert c in "0123456789"
                sigma += "0"
            sigma += "5"
            sigma_row.append(float(sigma))
        value_rows.append(value_row)
        sigma_rows.append(sigma_row)
        if (stols.size() == 62):
          assert stols[-1] == 6, line
          break
      tab.enter_block(elements,atomic_numbers,methods,value_rows,sigma_rows)
  return tab
Example #5
0
def run():
    assert len(sys.argv) == 2
    f = open(sys.argv[1], "r")
    lf = line_feeder(f)
    lookup_dict = {}
    while 1:
        entry = dtrek_symmetry_entry(lf)
        if (entry.symbol is None):
            break
        cctbx_lookup_symbol = str(entry.space_group_info).replace(" ", "")
        if (cctbx_lookup_symbol != entry.symbol):
            lookup_dict[entry.symbol] = cctbx_lookup_symbol
    pprint.pprint(lookup_dict)
def run():
  assert len(sys.argv) == 2
  f = open(sys.argv[1], "r")
  lf = line_feeder(f)
  lookup_dict = {}
  while 1:
    entry = dtrek_symmetry_entry(lf)
    if (entry.symbol is None):
      break
    cctbx_lookup_symbol = str(entry.space_group_info).replace(" ", "")
    if (cctbx_lookup_symbol != entry.symbol):
      lookup_dict[entry.symbol] = cctbx_lookup_symbol
  pprint.pprint(lookup_dict)