def start(self): self.log.info("Writing DataSet: %s" % self.output) dataset = DataSet(self.output, mode="w", name="VectorApp-%s" % self.method) for i, (data, file) in enumerate(self.yield_transform(with_filenames=True)): dataset[i] = data dataset.set_trajfn(i, file) dataset.close()
def _yield_input(self, with_filenames=False): if self.source == "vector": for data in self.vectorapp.yield_transform(with_filenames): yield data else: dataset = DataSet(self.input) for key in dataset.keys(): if with_filenames: yield dataset[key], dataset.get_trajfn(key) else: yield dataset[key] self.input_provenance = dataset.provenance dataset.close()
def start(self): if not os.path.exists(self.input): self.error('No such file or directory: %s' % self.input) if not tables.is_pytables_file(self.input): self.error('Unrecognized format') try: ds = DataSet(self.input, 'r') self.print_dataset(ds) ds.close() except UnrecognizedFormatError: handle = tables.open_file(self.input) self.print_model(handle) handle.close()
def _yield_input(self, with_filenames=False): if self.source == 'tICA': for data in self.ticaapp.yield_transform(with_filenames): yield data elif self.source == 'vector': for data in self.vector.yield_transform(with_filenames): yield data elif self.source == 'precomputed': dataset = DataSet(self.input) for key in dataset.keys(): if with_filenames: yield dataset[key], dataset.get_trajfn(key) else: yield dataset[key] self.input_provenance = dataset.provenance dataset.close() else: raise RuntimeError(self.source)
def start(self): self.fit() if self.mode == 'fit': self.log.info('Saving fit KCenters model to `%s`' % self.output) with tables.open_file(self.output, 'w') as f: self.kcenters.to_pytables(f.root) elif self.mode in ['fit_predict', 'predict']: self.log.info('Writing DataSet: %s' % self.output) dataset = DataSet(self.output, mode='w', name='KCenters') if self.source == 'precomputed': dataset.provenance = self.input_provenance for i, (data, fn) in enumerate(self.yield_transform(with_filenames=True)): dataset[i] = data dataset.set_trajfn(i, fn) dataset.close() else: raise RuntimeError(self.mode)
def start(self): self.fit() if self.mode == "fit": self.log.info("Saving fit tICA model to `%s`" % self.output) with tables.open_file(self.output, "w") as f: self.tica.to_pytables(f.root) return if self.mode in ["fit_transform", "transform"]: self.log.info("Writing DataSet: %s" % self.output) dataset = DataSet(self.output, mode="w", name="TICAApp") if self.source == "precomputed": dataset.provenance = self.input_provenance for i, (data, fn) in enumerate(self.yield_transform(with_filenames=True)): dataset[i] = data dataset.set_trajfn(i, fn) dataset.close() else: raise RuntimeError()