libokj commited on
Commit
3641f11
·
1 Parent(s): 29b90e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -316,11 +316,11 @@ def heavy_atom(mol):
316
 
317
 
318
  def rotatable_bond(mol):
319
- return CalcNumRotatableBonds((mol))
320
 
321
 
322
  def tpsa(mol):
323
- return CalcTPSA((mol))
324
 
325
 
326
  def lipinski(mol):
@@ -579,7 +579,7 @@ def ts_to_str(ts, timezone_str):
579
  dt = datetime.fromtimestamp(ts)
580
  dt = dt.replace(tzinfo=pytz.utc) # Set the datetime object to UTC
581
  localized_dt = dt.astimezone(local_tz) # Convert the datetime object to the desired timezone
582
- return localized_dt.strftime('%Y-%m-%d %H:%M:%S (%Z%z)')
583
 
584
 
585
  def lookup_job(job_id):
@@ -1263,7 +1263,7 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
1263
  target_gene = gr.Textbox(
1264
  show_label=False, visible=False,
1265
  interactive=True, scale=4,
1266
- info='Enter a gene symbol and query. The first record is used by default.')
1267
  target_organism = gr.Textbox(
1268
  info='Organism scientific name (default: Homo sapiens).',
1269
  placeholder='Homo sapiens', show_label=False,
@@ -1715,13 +1715,23 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
1715
  aligner = PairwiseAligner(scoring='blastp', mode='local')
1716
  alignment_df = pd.read_csv('data/target_libraries/ChEMBL33_all_spe_single_prot_info.csv')
1717
 
 
 
 
 
 
 
 
 
 
 
1718
  def align_score(query):
1719
- return aligner.align(process_target_fasta(fasta), query).score
1720
 
1721
  alignment_df['score'] = alignment_df['X2'].swifter.progress_bar(
1722
  desc="Detecting protein family of the target...").apply(align_score)
1723
  row = alignment_df.loc[alignment_df['score'].idxmax()]
1724
- return gr.Dropdown(value=row['protein_family'].capitalize(),
1725
  info=f"Reason: Best BLASTP score ({row['score']}) "
1726
  f"with {row['ID2']} from family {row['protein_family']}")
1727
  except Exception as e:
 
316
 
317
 
318
  def rotatable_bond(mol):
319
+ return CalcNumRotatableBonds(mol)
320
 
321
 
322
  def tpsa(mol):
323
+ return CalcTPSA(mol)
324
 
325
 
326
  def lipinski(mol):
 
579
  dt = datetime.fromtimestamp(ts)
580
  dt = dt.replace(tzinfo=pytz.utc) # Set the datetime object to UTC
581
  localized_dt = dt.astimezone(local_tz) # Convert the datetime object to the desired timezone
582
+ return localized_dt.strftime('%Y-%m-%d %H:%M:%S (%Z)')
583
 
584
 
585
  def lookup_job(job_id):
 
1263
  target_gene = gr.Textbox(
1264
  show_label=False, visible=False,
1265
  interactive=True, scale=4,
1266
+ info='Enter a gene symbol and query. The first record will be used.')
1267
  target_organism = gr.Textbox(
1268
  info='Organism scientific name (default: Homo sapiens).',
1269
  placeholder='Homo sapiens', show_label=False,
 
1715
  aligner = PairwiseAligner(scoring='blastp', mode='local')
1716
  alignment_df = pd.read_csv('data/target_libraries/ChEMBL33_all_spe_single_prot_info.csv')
1717
 
1718
+ processed_fasta = process_target_fasta(fasta)
1719
+
1720
+ # Check for an exact match first
1721
+ exact_match = alignment_df[alignment_df['X2'] == processed_fasta]
1722
+ if not exact_match.empty:
1723
+ row = exact_match.iloc[0]
1724
+ return gr.Dropdown(value=row['protein_family'],
1725
+ info=f"Reason: Exact match found with {row['ID2']} from family {row['protein_family']}")
1726
+
1727
+ # If no exact match, then calculate alignment score
1728
  def align_score(query):
1729
+ return aligner.align(processed_fasta, query).score
1730
 
1731
  alignment_df['score'] = alignment_df['X2'].swifter.progress_bar(
1732
  desc="Detecting protein family of the target...").apply(align_score)
1733
  row = alignment_df.loc[alignment_df['score'].idxmax()]
1734
+ return gr.Dropdown(value=row['protein_family'],
1735
  info=f"Reason: Best BLASTP score ({row['score']}) "
1736
  f"with {row['ID2']} from family {row['protein_family']}")
1737
  except Exception as e: