<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 What do the data look like?
Jupyter IPython notebooks, such as this one, allow you to run both Python code and, using 'magics' also shell commands. In this tutorial we'll use both, since we will be interfacing with a variety of software, as well as processing data.
First, let's look around in the directory using standard Linux commands. We can execute a shell command by preceding it with an exclamation mark.
Step1:  We see that there are five files four of these are mutants, and and one reference original sample.
We will take a look inside one of the files and look at the distribution of read statistics.
The reads are in text files, which have been compressed using gzip, a common practice for storing raw data. You can look inside by decompressing a file, piping the output to a program called head, which will stop after a few lines. You don't want to print the contents of the entire file to screen, since it will likely crash IPython.
Step2:  Each read in the fastq file format has four lines, one is a unique read name, one containing the sequence of bases, one +, and one containing quality scores. The quality scores correspond to the sequencer's confidence in making the base call.
It is good practice to examine the quality of your data before you proceed with the analysis. We'll use a popular tools called FastQC to do some exploratory analysis.
Step3:  Key statistics
Basic Statistics. Reports number of sequences, and basic details
Per base sequence quality. The distribution of sequence quality scored over the length of the read.
The quality scale is logarithmic. Notice that the quality degrades rapidly over the length of the read. This is a key characteristic of Illumina data, and product of their sequencing chemistry, which limits the upper read length to about 300 bp.
We can explore the contents of read files programmatically using a library within Python called Biopython. This allows to automate many tedious tasks.
Step4:  You can see the methods associated with each object, suce as rec usig the dir command.
Step5:  For example, we can reverse complement the sequence
<ASSISTANT_TASK:>
Python Code:
!ls -lh ../data/reads
Explanation: What do the data look like?
Jupyter IPython notebooks, such as this one, allow you to run both Python code and, using 'magics' also shell commands. In this tutorial we'll use both, since we will be interfacing with a variety of software, as well as processing data.
First, let's look around in the directory using standard Linux commands. We can execute a shell command by preceding it with an exclamation mark.
End of explanation
!gunzip -c ../data/reads/mutant1_OIST-2015-03-28.fq.gz | head -8
Explanation: We see that there are five files four of these are mutants, and and one reference original sample.
We will take a look inside one of the files and look at the distribution of read statistics.
The reads are in text files, which have been compressed using gzip, a common practice for storing raw data. You can look inside by decompressing a file, piping the output to a program called head, which will stop after a few lines. You don't want to print the contents of the entire file to screen, since it will likely crash IPython.
End of explanation
!fastqc ../data/reads/mutant1_OIST-2015-03-28.fq.gz
from IPython.display import IFrame
IFrame('../data/reads/mutant1_OIST-2015-03-28_fastqc.html', width=1000, height=1000)
Explanation: Each read in the fastq file format has four lines, one is a unique read name, one containing the sequence of bases, one +, and one containing quality scores. The quality scores correspond to the sequencer's confidence in making the base call.
It is good practice to examine the quality of your data before you proceed with the analysis. We'll use a popular tools called FastQC to do some exploratory analysis.
End of explanation
import gzip
from Bio import SeqIO
with gzip.open("../data/reads/mutant1_OIST-2015-03-28.fq.gz", 'rt') as infile: # open and decompress input file
    for rec in SeqIO.parse(infile, "fastq"):  # start looping over all records
        print(rec)  #print record contents
        break # stop looping, we only want to see one record
Explanation: Key statistics
Basic Statistics. Reports number of sequences, and basic details
Per base sequence quality. The distribution of sequence quality scored over the length of the read.
The quality scale is logarithmic. Notice that the quality degrades rapidly over the length of the read. This is a key characteristic of Illumina data, and product of their sequencing chemistry, which limits the upper read length to about 300 bp.
We can explore the contents of read files programmatically using a library within Python called Biopython. This allows to automate many tedious tasks.
End of explanation
print(dir(rec)) # print methods associaat
Explanation: You can see the methods associated with each object, suce as rec usig the dir command.
End of explanation
rec.reverse_complement()
Explanation: For example, we can reverse complement the sequence:
End of explanation
<END_TASK>