Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 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 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
|
| 49 |
-
st.download_button("Download Starting Sequences", start_sequences_text, file_name="starting_sequences.txt", mime="text/plain")
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 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()
|