alidenewade commited on
Commit
c7ddfd7
·
verified ·
1 Parent(s): c3673c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -68,18 +68,26 @@ sns.set_theme(style='whitegrid')
68
 
69
  # --- FINGERPRINT CONFIGURATION ---
70
  # Create a dummy PubChem.xml if no XML files are found, to ensure fp_config is populated
71
- if not glob.glob('*.xml'):
 
 
 
 
 
 
 
 
72
  try:
73
- with open('PubChem.xml', 'w') as f:
74
  f.write('')
 
75
  except IOError:
76
- warnings.warn("Could not create a dummy 'PubChem.xml' file. Fingerprint calculation might fail if no .xml files are present.")
77
 
78
- xml_files = sorted(glob.glob('*.xml'))
79
  if not xml_files:
80
  warnings.warn(
81
- "No descriptor .xml files found. Fingerprint calculation will not be possible. "
82
- "Please place descriptor XML files in the same directory as the script."
83
  )
84
  fp_config = {os.path.splitext(os.path.basename(file))[0]: file for file in xml_files}
85
  FP_list = sorted(list(fp_config.keys()))
 
68
 
69
  # --- FINGERPRINT CONFIGURATION ---
70
  # Create a dummy PubChem.xml if no XML files are found, to ensure fp_config is populated
71
+ # Check if the 'padel_descriptors' directory exists, create it if not
72
+ if not os.path.exists('padel_descriptors'):
73
+ os.makedirs('padel_descriptors')
74
+
75
+ # Check for XML files within the 'padel_descriptors' folder
76
+ xml_files = sorted(glob.glob('padel_descriptors/*.xml'))
77
+
78
+ if not xml_files:
79
+ # If no XML files found in the directory, try to create a dummy one.
80
  try:
81
+ with open('padel_descriptors/PubChem.xml', 'w') as f:
82
  f.write('')
83
+ xml_files = sorted(glob.glob('padel_descriptors/*.xml')) # Re-check after creating
84
  except IOError:
85
+ warnings.warn("Could not create a dummy 'PubChem.xml' file in 'padel_descriptors' folder. Fingerprint calculation might fail if no .xml files are present.")
86
 
 
87
  if not xml_files:
88
  warnings.warn(
89
+ "No descriptor .xml files found in the 'padel_descriptors' folder. Fingerprint calculation will not be possible. "
90
+ "Please place descriptor XML files in the 'padel_descriptors' folder."
91
  )
92
  fp_config = {os.path.splitext(os.path.basename(file))[0]: file for file in xml_files}
93
  FP_list = sorted(list(fp_config.keys()))