封装函数

  • import parmed as pmd  def amber_to_gmx(prmtop_file, inpcrd_file, top_file, gro_file):     """     Convert AMBER parameter and coordinate files to GROMACS format.      Parameters:     prmtop_file (str): Path to the AMBER prmtop file.     inpcrd_file (str): Path to the AMBER inpcrd file.     top_file (str): Output path for the GROMACS .top file.     gro_file (str): Output path for the GROMACS .gro file.     """     try:         # Load the AMBER files         amber = pmd.load_file(prmtop_file, inpcrd_file)                  # Save the files in GROMACS format         amber.save(top_file)         amber.save(gro_file)                  print(f"Files have been successfully converted to GROMACS format: {top_file}, {gro_file}")          except Exception as e:         print(f"Error during conversion: {e}")  # Example usage: amber_to_gmx('complex.prmtop', 'complex.inpcrd', 'gmx.top', 'gmx.gro')