1010import subprocess
1111import time
1212import pandas as pd
13- #from chimera import runCommand as rc
13+ #from chimera import runCommand as rc
1414
15+ # The above line can be uncommented when running sturated_mutagenesis() on UCSF Chimera
1516
1617def saturated_mutagenesis (model_no ,chain_name ,start_residue ,stop_residue ,input_path ,file_name ,output_path ):
1718
19+ """
20+ Perform saturated Mutagenesis (SM) of a given length of peptide submitted in .pdb format and return all mutants each in different files
21+
22+ Args:
23+ model_no (str) : The model number of the peptide of interest in the .pdb file
24+
25+ chain_no (str) : Name of the Chain where SM is to be performed. Ex : 'A' , 'B' or ' '
26+
27+ start_residue (int) : Residue number on the given chain and model where SM needs to be performed (started)
28+
29+ stop_residue (int) : Residue number on the given chain where the SM needs to be stopped.
30+
31+ input_path (str) : Path to the directory .pdb containing the peptide that needs to undergo SM
32+
33+ file_name (str) : Name of the .pdb file submitted
34+
35+ output_path (str) : Name of the output directory where the new models are saved.
36+
37+ Returns :
38+ This script is to be run in UCSF Chimera and all models/mutants are returned in .pdb format in the output_directory
39+
40+
41+ Raises :
42+ UCSF Chimera only works with Python 2.x
43+
44+ Notes :
45+ Visit Github.com/Anantha-Rao12/Peptides-against-Malaria for more info
46+
47+ """
48+
1849 aa_data = 'ala arg asn asp cys glu gln gly his ile leu lys met phe pro ser thr trp tyr val' .split ()
1950
2051 for residue_no in range (start_residue ,stop_residue + 1 ):
@@ -28,7 +59,26 @@ def saturated_mutagenesis(model_no,chain_name,start_residue,stop_residue,input_p
2859
2960
3061
31- def AnalyseComplex (foldx_path , file_full_path , output_full_path ):
62+ def AnalyseComplex (foldx_path , file_full_path ):
63+
64+ """
65+ Use the subprocess module to execute the --analyseComplexChains=A,B command of FoldX and obtain the Interaction Energy between two chains in a .pdb file
66+
67+ Args:
68+ foldx_path (str) : local full/relative path of the FOLDX executable
69+
70+ file_path (str) : local full path to the .pdb file that is to be analysed
71+
72+
73+ Returns :
74+ Prints the time taken to analyse, process and write the output a single .pdb file
75+ Output is the stdout from the terminal
76+
77+ Notes :
78+ More information can be found here : foldxsuite.crg.eu/command/AnalyseComplex
79+
80+
81+ """
3282
3383 data = []
3484 start = time .time ()
@@ -43,10 +93,10 @@ def AnalyseComplex(foldx_path, file_full_path, output_full_path):
4393
4494def make_df_combine (files_path1 ,files_path2 ,output_path ,csv_file_name ):
4595
46- ''' This function visits files_path1 and files_path2 to collect all foldx Summary.fxout files that was created by AnalyseComplex command.
96+ """ Visit files_in path1 and files_in path2 to collect all foldx Summary.fxout files that was created by AnalyseComplex command.
4797 With os.listdir each file name is stored in lists called 'foldx_summary_files' via list comprehension. We then open each .fxout Summary file with
4898 a context manager and store the last line of the file which has the required interaction data (tab separated). A list of lists is thus created
49- and finally grafted into a dataframe with Pandas that is written as a .csv file to the given 'output_path' with 'csv_file_name'. '''
99+ and finally grafted into a dataframe with Pandas that is written as a .csv file to the given 'output_path' with 'csv_file_name'."""
50100
51101 listoflists = []
52102 paths = [files_path1 ,files_path2 ]
@@ -55,8 +105,8 @@ def make_df_combine(files_path1,files_path2,output_path,csv_file_name):
55105 for file in os .listdir (foldx_summary_files ):
56106 with open (os .path .join (path ,file ),'r' ) as rf :
57107 lines = rf .read ().splitlines ()
58- data = lines [- 1 ].split ('\t ' )
59- header = lines [- 2 ].split ('\t ' )
108+ data = lines [- 1 ].split ('\t ' ) #Obtain the last line in the Summary.fxout file
109+ header = lines [- 2 ].split ('\t ' ) #Obtain the 2nd last line as header in the Summary.fxout file
60110 listoflists .append (data )
61111 df = pd .DataFrame (listoflists ,columns = header )
62112 os .chdir (output_path )
0 commit comments