- 1 Read the file
- 2 Clean and validate
- 3 Filter by length
- 4 Trim adapters
- 5 Quality check a FASTQ file
Trim adapters
THE BRIEF
During sequencing, short synthetic adapter sequences are attached to the DNA fragments. If a read is shorter than the fragment the machine runs through into the adapter, so the read ends with adapter sequence that is not part of the organism's DNA. Left in, it can mislead alignment and assembly.
Your task. The first line is the adapter sequence. Every following line is one read. For each read, find the first occurrence of the adapter and remove it together with everything after it, keeping only what came before. If the adapter does not occur, the read is unchanged. If nothing is left after trimming, print EMPTY.
Input. An adapter line, then one read per line.
Output. One line per read: the trimmed read, or EMPTY.
GIVEN INPUT
Your code reads this from standard input (input() or sys.stdin), both here and when it is graded.
AGATCGGAAG ACGTACGTAGATCGGAAGTTTT GGGGCCCC AGATCGGAAGACGT TTAGATCGGAAGAGATCGGAAG
EXPECTED OUTPUT FOR THIS INPUT
ACGTACGT GGGGCCCC EMPTY TT
SKILLS YOU'LL USE
Stuck? These bank problems practise the same techniques.
Write your code
Check your understanding
A quick self-check, marked right here in your browser. It is not graded or saved.
What is an adapter sequence?
Adapters let fragments bind to the sequencing machine, but they are not part of the sample's genome.
Why must adapters be removed before aligning reads to a genome?
Leftover adapter sequence is a classic source of artefacts.
Explain and submit
Explain how your code finds the adapter in a read and why it removes everything after the first match as well as the adapter itself.
Your submissions (0)
You can look ahead; come back to finish this stage.