Jun-12-2023, 02:19 AM
I am new to Python and need help to make a script for the task. I am running a modified Autodock program and need to compile the results.
I have a folder that contain hundreds of *.pdbqt files named "compound_1.pdbqt", "compound_2.pdbqt", .etc.
Each file have a structure like this:
Thank you very much.
I have a folder that contain hundreds of *.pdbqt files named "compound_1.pdbqt", "compound_2.pdbqt", .etc.
Each file have a structure like this:
Output:MODEL 1
REMARK minimizedAffinity -7.11687565
REMARK CNNscore 0.573647082
REMARK CNNaffinity 5.82644749
REMARK 11 active torsions:
#Lots of text here
MODEL 2
REMARK minimizedAffinity -6.61898327
REMARK CNNscore 0.55260396
REMARK CNNaffinity 5.86855984
REMARK 11 active torsions:
#Lots of text here
#Repeat with 10 to 20 model
I want to use a python (using Python 3) script to exact the "MODEL", "minimizedAffinity", "CNNscore", and "CNNaffinity" of each and every compound in the folder into a delimited text file that look like this:Output:Compound Model minimizedAffinity CNNscore CNNaffinity
1 1 -7.11687565 0.573647082 5.82644749
1 2 -6.61898327 0.55260396 5.86855984
Currently I am stuck at this script#! /usr/bin/env python import sys import glob files = glob.glob('**/*.pdbqt', recursive = True) for file in files: word1 = 'MODEL' word2 = 'minimizedAffinity' word3 = 'CNNscore' word4 = 'CNNaffinity' print(file) with open(file) as fp: # read all lines in a list lines = fp.readlines() for line in lines: # check if string present on a current line if line.find(word1) != -1: print('Line:', line) if line.find(word2) != -1: print('Line:', line) if line.find(word3) != -1: print('Line:', line) if line.find(word4) != -1: print('Line:', line)Really appreciate any help.
Thank you very much.