fatmacankara commited on
Commit
0d8e357
·
1 Parent(s): 13cf7a1

Update code/alphafold_featureVector.py

Browse files
Files changed (1) hide show
  1. code/alphafold_featureVector.py +54 -3
code/alphafold_featureVector.py CHANGED
@@ -44,6 +44,53 @@ import requests
44
  from Bio.PDB import PDBParser, PPBuilder
45
  from io import StringIO
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  def convert_non_standard_amino_acids(sequence):
49
  """
@@ -629,7 +676,6 @@ def alphafold(input_set, mode, impute):
629
  atomSequence = convert_non_standard_amino_acids(atomSequence)
630
  alignments = aligner.align(pdbSequence, atomSequence)
631
  alignments = (list(alignments))
632
-
633
  #if get_alignments_3D(uniprotID, mod, pdb_path, pdbSequence, 'nan', 'nan', 'nan', mode, Path(path_to_output_files / '3D_alignment'),
634
  # 'gzip') != None:
635
 
@@ -640,8 +686,13 @@ def alphafold(input_set, mode, impute):
640
 
641
 
642
  alignments = alignments[0]
643
-
644
- calculate_freesasa(uniprotID, mod, existing_free_sasa, alphafold_path, path_to_output_files)
 
 
 
 
 
645
  if (mutationPositionOnPDB != 'nan'):
646
  if (int(mutationPositionOnPDB) <= 1400):
647
  try:
 
44
  from Bio.PDB import PDBParser, PPBuilder
45
  from io import StringIO
46
 
47
+ import glob
48
+ import ssbio.utils
49
+ import subprocess
50
+ import ssbio
51
+ import os.path as op
52
+ from add_3Dalignment import *
53
+ import os
54
+ from pathlib import Path
55
+ import gzip
56
+ import shutil
57
+ import streamlit as st
58
+
59
+
60
+ def run_freesasa(infile, outfile, include_hetatms=True, outdir=None, force_rerun=False, file_type = 'gzip'):
61
+ if not outdir:
62
+ outdir = ''
63
+ outfile = op.join(outdir, outfile)
64
+ if file_type == 'pdb':
65
+ if ssbio.utils.force_rerun(flag=force_rerun, outfile=outfile):
66
+ if include_hetatms:
67
+ shell_command = 'freesasa --format=rsa --hetatm {} -o {}'.format(infile, outfile)
68
+ else:
69
+ shell_command = 'freesasa --format=rsa {} -o {}'.format(infile, outfile)
70
+ command = subprocess.Popen(shell_command,
71
+ stdout=subprocess.PIPE,
72
+ stderr=subprocess.PIPE,
73
+ shell=True)
74
+ out, err = command.communicate()
75
+ elif file_type == 'gzip':
76
+ with gzip.open(infile, 'rb') as f_in:
77
+ with open('file_temp.pdb', 'wb') as f_out:
78
+ shutil.copyfileobj(f_in, f_out)
79
+
80
+ infile = 'file_temp.pdb'
81
+
82
+ if ssbio.utils.force_rerun(flag=force_rerun, outfile=outfile):
83
+ if include_hetatms:
84
+ shell_command = 'freesasa --format=rsa --hetatm {} -o {}'.format(infile, outfile)
85
+ else:
86
+ shell_command = 'freesasa --format=rsa {} -o {}'.format(infile, outfile)
87
+ command = subprocess.Popen(shell_command,
88
+ stdout=subprocess.PIPE,
89
+ stderr=subprocess.PIPE,
90
+ shell=True)
91
+ out, err = command.communicate()
92
+ return outfile
93
+
94
 
95
  def convert_non_standard_amino_acids(sequence):
96
  """
 
676
  atomSequence = convert_non_standard_amino_acids(atomSequence)
677
  alignments = aligner.align(pdbSequence, atomSequence)
678
  alignments = (list(alignments))
 
679
  #if get_alignments_3D(uniprotID, mod, pdb_path, pdbSequence, 'nan', 'nan', 'nan', mode, Path(path_to_output_files / '3D_alignment'),
680
  # 'gzip') != None:
681
 
 
686
 
687
 
688
  alignments = alignments[0]
689
+ if ID not in existing_free_sasa:
690
+ fullID = f'AF-{ID}-F{model_num}-{file_str }.pdb.gz'
691
+ run_freesasa(Path(alphafold_path / fullID),
692
+ Path(path_to_output_files / f'freesasa_files/{fullID}.txt'), include_hetatms=True,
693
+ outdir=None, force_rerun=False)
694
+ st.write('Calulated')
695
+ #calculate_freesasa(uniprotID, mod, existing_free_sasa, alphafold_path, path_to_output_files)
696
  if (mutationPositionOnPDB != 'nan'):
697
  if (int(mutationPositionOnPDB) <= 1400):
698
  try: