chanage log

This commit is contained in:
2024-01-12 11:19:30 +08:00
parent 3a9a03e6c7
commit 4f3daa855b

View File

@@ -64,9 +64,23 @@ class LoopModelBuilder:
log_file = self.output_dir / "loop_modeling.log" log_file = self.output_dir / "loop_modeling.log"
if log_file.exists(): if log_file.exists():
log_file.unlink() log_file.unlink()
logging.basicConfig(level=logging.INFO, filename=log_file, filemode='a',
format='%(asctime)s - %(levelname)s - %(message)s') # 创建 logger 实例
self.logger = logging.getLogger('LoopModelBuilder') self.logger = logging.getLogger('LoopModelBuilder')
self.logger.setLevel(logging.INFO)
# 创建 file handler
file_handler = logging.FileHandler(log_file, mode='a')
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
# 创建 console handler
console_handler = logging.StreamHandler()
console_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
# 将 handlers 添加到 logger
self.logger.addHandler(file_handler)
self.logger.addHandler(console_handler)
def initialize_pymol(self): def initialize_pymol(self):
self.pymol_instance = pymol.cmd self.pymol_instance = pymol.cmd
@@ -75,6 +89,7 @@ class LoopModelBuilder:
def split_chains(self) -> dict: def split_chains(self) -> dict:
split_dict = {} split_dict = {}
for chain_id in self.analyzer_instance.chain_id_list: for chain_id in self.analyzer_instance.chain_id_list:
self.logger.info(f"Chain {chain_id} info: \n{self.analyzer_instance.extract_sequences(chain_id)}")
chain_file = self.output_dir.joinpath(f"{self.analyzer_instance.pid}_{chain_id}.pdb") chain_file = self.output_dir.joinpath(f"{self.analyzer_instance.pid}_{chain_id}.pdb")
self.analyzer_instance.split_chain(chain_id).to_pdb(chain_file.as_posix()) self.analyzer_instance.split_chain(chain_id).to_pdb(chain_file.as_posix())
split_dict[chain_id] = chain_file.read_text() split_dict[chain_id] = chain_file.read_text()