Jayesh13 commited on
Commit
0cfb879
·
verified ·
1 Parent(s): f659c90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -12,6 +12,17 @@ def get_genome_from_ncbi(accession_number):
12
  st.error("Failed to retrieve genome. Please check the accession number.")
13
  return None
14
 
 
 
 
 
 
 
 
 
 
 
 
15
  def main():
16
  st.title("Download Genome from NCBI")
17
  st.write("Enter the accession number to download the corresponding genome.")
@@ -22,8 +33,15 @@ def main():
22
  if accession_number:
23
  genome_data = get_genome_from_ncbi(accession_number)
24
  if genome_data:
25
- st.text_area("Genome Data", genome_data, height=300)
26
- st.download_button("Download Genome", genome_data, file_name=f"{accession_number}.fasta", mime="text/plain")
 
 
 
 
 
 
 
27
  else:
28
  st.warning("Please enter an accession number.")
29
 
 
12
  st.error("Failed to retrieve genome. Please check the accession number.")
13
  return None
14
 
15
+ def extract_sequences(genome_data):
16
+ # Extract the sequence part from the FASTA format
17
+ lines = genome_data.splitlines()
18
+ sequence = ''.join(lines[1:]) # Join all lines except the first (which is the header)
19
+
20
+ # Get the first 55 and last 114 base pairs
21
+ start_sequence = sequence[:55] # First 55 base pairs
22
+ end_sequence = sequence[-114:] # Last 114 base pairs
23
+
24
+ return start_sequence, end_sequence
25
+
26
  def main():
27
  st.title("Download Genome from NCBI")
28
  st.write("Enter the accession number to download the corresponding genome.")
 
33
  if accession_number:
34
  genome_data = get_genome_from_ncbi(accession_number)
35
  if genome_data:
36
+ start_sequence, end_sequence = extract_sequences(genome_data)
37
+
38
+ # Display the sequences
39
+ st.text_area("Starting 55 Base Pairs", start_sequence, height=50)
40
+ st.text_area("Ending 114 Base Pairs", end_sequence, height=100)
41
+
42
+ # Prepare content for download
43
+ download_content = f"Starting 55 Base Pairs:\n{start_sequence}\n\nEnding 114 Base Pairs:\n{end_sequence}\n"
44
+ st.download_button("Download Sequences", download_content, file_name=f"{accession_number}_sequences.txt", mime="text/plain")
45
  else:
46
  st.warning("Please enter an accession number.")
47