Jayesh13 commited on
Commit
96d0940
·
verified ·
1 Parent(s): d5ba624

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -18
app.py CHANGED
@@ -16,12 +16,7 @@ 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("NCBI Genome Sequence Extractor")
@@ -33,24 +28,22 @@ def main():
33
  # Read and split accession numbers from the uploaded file
34
  accession_numbers = uploaded_file.read().decode("utf-8").splitlines()
35
 
36
- # Prepare lists to store sequences
37
- starting_sequences = []
38
- ending_sequences = []
39
 
40
  for accession_number in accession_numbers:
41
  genome_data = get_genome_from_ncbi(accession_number)
42
  if genome_data:
43
- start_sequence, end_sequence = extract_sequences(genome_data)
44
- starting_sequences.append(f"{accession_number}: {start_sequence}")
45
- ending_sequences.append(f"{accession_number}: {end_sequence}")
 
 
46
 
47
- # Write starting sequences to a file for download
48
- start_sequences_text = "\n".join(starting_sequences)
49
- st.download_button("Download Starting Sequences", start_sequences_text, file_name="starting_sequences.txt", mime="text/plain")
50
 
51
- # Write ending sequences to a file for download
52
- end_sequences_text = "\n".join(ending_sequences)
53
- st.download_button("Download Ending Sequences", end_sequences_text, file_name="ending_sequences.txt", mime="text/plain")
54
 
55
  if __name__ == "__main__":
56
  main()
 
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
+ return sequence # Return the full sequence
 
 
 
 
 
20
 
21
  def main():
22
  st.title("NCBI Genome Sequence Extractor")
 
28
  # Read and split accession numbers from the uploaded file
29
  accession_numbers = uploaded_file.read().decode("utf-8").splitlines()
30
 
31
+ output_sequences = []
 
 
32
 
33
  for accession_number in accession_numbers:
34
  genome_data = get_genome_from_ncbi(accession_number)
35
  if genome_data:
36
+ # Extract the sequence
37
+ sequence = extract_sequences(genome_data)
38
+ # Format the output as per the requirement
39
+ output_sequence = f">{accession_number}\n{sequence}"
40
+ output_sequences.append(output_sequence)
41
 
42
+ # Create output text with the specified format
43
+ output_text = "\n".join(output_sequences)
 
44
 
45
+ # Provide a download button for the formatted output
46
+ st.download_button("Download Sequences", output_text, file_name="formatted_sequences.txt", mime="text/plain")
 
47
 
48
  if __name__ == "__main__":
49
  main()