# PyScript — Simple Bioinformatics Example

PyScript — Simple Bioinformatics Example v.1

Demonstrates the simple use of `PyScript` in Bioinformatics/Computational Biology fields!

🧬 DNA Sequence Tool

Input DNA Sequence
Pick the operation to be applied

Output for the `given operation`
# Define HTML elements and inputs dna_alphabet = "ATGC" output = Element("output") dna_seq_element = Element("dna_seq") operation_element = Element("operation") operation_name_output_element = Element("operation_name_output") # DNA Sequene Operations def return_reverse(dna_seq): return dna_seq[::-1] def return_complement(dna_seq): return dna_seq.translate(str.maketrans("ATCG", "TAGC")) def return_reverse_complement(dna_seq): return dna_seq.translate(str.maketrans("ATCG", "TAGC"))[::-1] # Check DNA seq is valid def check_dna_seq(dna_seq): return all(letter in dna_alphabet for letter in dna_seq.upper()) # Clear the form and output def clear(*args, **kwargs): dna_seq_element.clear() output.clear() # Run def run(*args, **kwargs): dna_seq = dna_seq_element.value is_dna_seq_valid = check_dna_seq(dna_seq) if is_dna_seq_valid: operation_name = operation_element.value operation_name_output_element.write(operation_name) # Compute the desired outputs if operation_name == "Reverse": output_dna_seq = return_reverse(dna_seq) elif operation_name == "Complement": output_dna_seq = return_complement(dna_seq) elif operation_name == "ReverseComplement": output_dna_seq = return_reverse_complement(dna_seq) # Output the result output.write(output_dna_seq) elif (dna_seq.strip() == "") or (dna_seq is None): output.write("No DNA sequence provided") else: output.write("Invalid DNA sequence entered")