Beispiel #1
0
def get_year_temperature(filename):
    with gzip.open(filename, "r") as fh:
        cif = iotbx.cif.reader(file_object=fh)
    model = cif.model()
    assert len(model) == 1, list(model)
    entry = model[list(model)[0]]

    year = entry.get("_pdbx_database_status.recvd_initial_deposition_date")
    if year and "-" in year:
        year = int(year.split("-")[0])
    else:
        year = False
    if entry.get("_exptl.method") != "X-RAY DIFFRACTION":
        return year, False
    temp = entry.get("_diffrn.ambient_temp")
    if not temp:
        return year, None

    if isinstance(temp, basestring):
        return year, parse_temperature(temp)

    # scitbx array
    templist = filter(None, map(parse_temperature, temp))
    if not templist:
        return year, None
    return year, templist[0]
    def __init__(self, file_name):
        DetectorImageBase.__init__(self, file_name)
        raw = open(file_name, "rb").read()
        self.binary_sections = get_binary_sections(raw)
        self.header_sections = get_header_sections(raw, self.binary_sections)

        assert len(self.binary_sections) == 1

        cif = iotbx.cif.fast_reader(input_string=self.header_sections)
        self.cif_model = cif.model()
        im1 = self.cif_model["image_1"]

        self.vendortype = "CBF"
        self.readHeader()
Beispiel #3
0
  def __init__(self, file_name):
    DetectorImageBase.__init__(self, file_name)
    raw = open(file_name, "rb").read()
    self.binary_sections = get_binary_sections(raw)
    self.header_sections = get_header_sections(raw, self.binary_sections)

    assert len(self.binary_sections)==1

    cif = iotbx.cif.fast_reader(input_string=self.header_sections)
    self.cif_model = cif.model()
    im1 = self.cif_model["image_1"]

    self.vendortype = "CBF"
    self.readHeader()
Beispiel #4
0
def run(args):
  dic_path = libtbx.env.find_in_repositories(
    relative_path="cbflib/doc/cif_img_1.5.4_28Jul07.dic",
    test=op.isfile)
  if (dic_path is not None):
    cif_dic = iotbx.cif.validation.smart_load_dictionary(file_path=dic_path)
  else:
    cif_dic = None
  for file_name in args:
    raw = open(file_name, "rb").read()
    pattern = "--CIF-BINARY-FORMAT-SECTION--"
    i = raw.find(pattern)
    if (i >= 0):
      j = raw.rfind(pattern+"--")
    sliced = raw[:i] + "\n" + raw[j:]
    cif = iotbx.cif.fast_reader(input_string=sliced)
    model = cif.model()
    for k, v in model.iteritems():
      print v["_array_data.data"]
    if (cif_dic is not None):
      model.validate(cif_dic)
Beispiel #5
0
def run(args):
  dic_path = libtbx.env.find_in_repositories(
    relative_path="cbflib/doc/cif_img_1.5.4_28Jul07.dic",
    test=op.isfile)
  if (dic_path is not None):
    cif_dic = iotbx.cif.validation.smart_load_dictionary(file_path=dic_path)
  else:
    cif_dic = None
  for file_name in args:
    raw = open(file_name, "rb").read()
    pattern = "--CIF-BINARY-FORMAT-SECTION--"
    i = raw.find(pattern)
    if (i >= 0):
      j = raw.rfind(pattern+"--")
    sliced = raw[:i] + "\n" + raw[j:]
    cif = iotbx.cif.fast_reader(input_string=sliced)
    model = cif.model()
    im1 = model["image_1"]
    print im1["_array_data.data"]
    if (cif_dic is not None):
      model.validate(cif_dic)