Commit 43fde672 authored by Nicolas  MAILLET's avatar Nicolas MAILLET

Add TP8 q1

parent 2acca8f9
# Import regex
import re
def read_file(file_in):
""" Read the file and return its content (array of tuples) """
content = []
# Open the file
with open(file_in) as file:
# The header of the current sequence
header = False
# For each line
for line in file:
# If the header is False, this is a new sequence
if not header:
# Backup the header
header = line.strip()
# Header is not False, we are in a sequence
else:
# Create a tuple (not modifiable) with the header and the sequence
tmp = (header, line.strip())
# Add it to the returned list
content.append(tmp)
# Put header to False
header = False
# Return the content of the file
return content
def main():
""" The main of TP8 that launch regex """
# The file to process
file_in = "sequences.fasta"
# Get its content
content = read_file(file_in)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment