def copy_cifs(self, target_folder):
        """Copy cif files from their existing location to the specified
        target_folder.

        :param target_folder: Path of folder to copy collection CIF files to.
        """
        if target_folder is None:
            return
        tf_abspath = os.path.abspath(target_folder)
        Helper.make_folder(tf_abspath)
        print(self.separator)
        print('The cif files for this collection will be copied to'
              ' the specified folder:\n\"{}\"'.format(tf_abspath))
        print('The cif paths will be updated.')

        for i, mi in enumerate(list(self.mof_coll)):
            destination_path = "{}/{}.cif".format(tf_abspath, mi['mof_name'])
            self.mof_coll[i] = {
                "mof_name": mi['mof_name'],
                "mof_file": destination_path,
                "checksum": mi['checksum']
            }
            if not os.path.isfile(destination_path):
                shutil.copyfile(mi['mof_file'], destination_path)
        print(self.separator)
    def summarize_tfactors(self):
        """Summarize the t-factor information and make histograms for all the
        MOFs in the collection.
        """
        tfac_analysis_folder = self.summary_folder + '/tfac_analysis'
        Helper.make_folder(self.summary_folder)
        Helper.make_folder(tfac_analysis_folder)

        df = self.metal_site_df.copy()
        sites_u = df[df['unique']]

        for n in range(4, 7):
            self._write_t_factors(sites_u, n, tfac_analysis_folder)
 def _load_mofs(self):
     """Add MOfs to collection, use CIF file checksum as an identifier."""
     print('Loading CIF files...')
     li = max(int(len(self.path_list) / 1000), 1)
     lm = len(self.path_list) / 100.0
     for i, mof_file in enumerate(self.path_list):
         if i % li == 0:
             print("{:4.1f} %".format((i + 1) / lm), end="\r", flush=True)
         checksum = Helper.get_checksum(mof_file)
         mof_name = os.path.splitext(os.path.basename(mof_file))[0]
         mof_info = {
             "mof_name": mof_name,
             "mof_file": mof_file,
             "checksum": checksum
         }
         self.mof_coll.append(mof_info)
         if checksum not in self.properties:
             self.properties[checksum] = {"mof_name": mof_name}
         else:
             if self.properties[checksum]["mof_name"] != mof_name:
                 exit("MOF name and CIF checksum mismatch for {}.cif "
                      "{}.cif. Either the CIF files has already been "
                      "processed with a different name, or the CIF file "
                      "has changed since it was processed."
                      "".format(mof_name,
                                self.properties[checksum]['mof_name']))
         if self._check_if_results_exist(mof_name):
             self._compare_checksums(mof_file, mof_name, checksum)
     print("\nAll Done.")
     self._store_properties()
    def copy_results(self, target_folder):
        """Copy OMS result files from their existing location to the specified
        target_folder.

        :param target_folder: Path of folder to copy collection OMS result
        files to.
        """
        if target_folder is None:
            return

        print(self.separator)
        tf_abspath = os.path.abspath(target_folder)
        destination_path = tf_abspath + '/oms_results'

        print('The result files for this collection will be copied to the '
              'specified folder:\n{}\nThe analysis folder will be updated.'
              ''.format(tf_abspath))

        Helper.make_folder(tf_abspath)
        Helper.make_folder(destination_path)

        for i, mi in enumerate(self.mof_coll):
            mof_name = mi['mof_name']
            if self._check_if_results_exist(mof_name):
                source_path = "{}/{}".format(self.oms_results_folder, mof_name)
                Helper.copy_folder(destination_path, source_path)
        self.analysis_folder = tf_abspath
        self._validate_properties(['has_oms'])
        print(self.separator)
 def summary_folder(self):
     """Get value of the summary folder."""
     sf = self.analysis_folder + '/summary'
     Helper.make_folder(sf)
     return sf
 def oms_results_folder(self):
     """Get value of the OMS results folder."""
     orf = self.analysis_folder + '/oms_results'
     Helper.make_folder(orf)
     return orf
 def analysis_folder(self):
     """Get value of the analysis folder."""
     Helper.make_folder(self._analysis_folder)
     return self._analysis_folder