TITLE: Steps to Create FASTQ of  CCS Overlapping Genomic SSR  - CCS ROI 
AUTHORS: Gregory Harhay

[DESCRIPTION]
<div class = "text-blocks"><div class = "text-block"><span>The virulence and pathogenicity of bacterial pathogens are related to their adaptability to changing environments.  One process enabling adaptation is based on minor changes in genome sequence, as small as a few base pairs, within segments of genome called simple sequence repeats (SSRs) that consist of multiple copies of a short sequence (from one to several nucleotides), repeated in series.  SSRs are found in eukaryotes as well as prokaryotes, and variation in them occurs at frequencies up to a million-fold higher than the average bacterial mutation rate through a process of slipped stranded mispairing (SSM) by DNA polymerase during replication. The characterization of SSR length by standard sequencing methods is complicated by the appearance of length variation introduced during the sequencing process that does not accurately quantify lower-abundance repeat number variants in a population.  Here we report a computational approach to correct for process-induced artifacts, validated for tetranucleotide repeats by use of synthetic constructs of fixed, known length. We apply this method to a laboratory culture of</span><span style = "font-style:italic;">Histophilus somni</span><span>, prepared from a single colony, and demonstrate that the culture consists of populations of distinct sequence phase and read length variants at individual tetranucleotide SSR loci.</span></div><div class = "text-block">Input requirements: Closed Genome -   It is recommended that only organisms with closed genomes be the subject of the analyses described here. Mapping repetitive reads to to contigs of non-closed genomes may map to multiple locations, complicating tha analysis. Mapping CCS (circular consensus sequence) wiith repetitve sequence to closed genomes are guaranted  to map to a single locus if sufficent unique flanking sequence is used to confim the unique mapping.  Consequently, long CCS with high base quality are the most desirable input into this workflow.</div><div style = "text-align :; float : ;"><img style = "" src = "https://s3.amazonaws.com/pr-journal/ba5fa.png" /></div></div>

[STEPS]
?. [Software Requirements]
For those without Matlab licences, Matlab code can be run in CodeOcean at this  Matlab  Compute CapsuleGeneious was used to as wrapper to for running sequence mappers, phobos, and sequence
?. [Download Genome and  BAM Alignment of nine CCS libraries to CP018802 (H somni)  from NCBI]
Genome available at at Genbank CP018802.1BAM file available at  https://trace.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?run=SRR8080935 , the download BAM file is named SRR8080935_CP018802.bam
?. [Identify SSR in Genome]
Run Phobos  to identify simple sequence repeats:  search for repeats 2-mers to 10-mers in CP018802.1 genome.This Geneious plugin does not provide access to all potentail running modes and defaults to providing repeat unit naming using "normalised alphabetical mode,"  where the repeat unit reported is independent of strand and phase enabling  Phobos to chose the the repeat pattern that comes first in the alphabet.Save repeats to CP018802.1 genome annotation
?. [Select SSRs For Further Analysis]
These tetranucleotide repeats were selected for further analysis.   ABCDEF1Repeat UnitNameMinimumMaximumLengthPercentage Perfection2AACCTetranucleotide Repeat17922171792466250100.00%3AATCTetranucleotide Repeat14525621452715154100.00%4ACTGTetranucleotide Repeat15013211501467147100.00%5ACTGTetranucleotide Repeat14560131456119107100.00%6AAGCTetranucleotide Repeat1834016183409479100.00%
ABCDEF1Repeat UnitNameMinimumMaximumLengthPercentage Perfection2AACCTetranucleotide Repeat17922171792466250100.00%3AATCTetranucleotide Repeat14525621452715154100.00%4ACTGTetranucleotide Repeat15013211501467147100.00%5ACTGTetranucleotide Repeat14560131456119107100.00%6AAGCTetranucleotide Repeat1834016183409479100.00%
?. [For each SSR, extract CCS mapping SSR Regions of Interest (ROI)]
Create BAM file of CCS overlapping SSR ROI using coordinates identified in step 4 and  transfered to their respective BED file to be used in combination with with the BAM file of all reads mapping to the genome. When specifiying position of SSR, allow for 5 bp on each flank. Please keep in mind the BED file convention, the left coodrinate is 0-based while the right coordinate is 1-based.  For selecting CCS mapping to SSR,  use BED to define coordinates
?. [Analyze CCS mapping to ROI on reference]
Use Geneious to view CCS mapping to referenceInspect alignment  of CCS  mapping to duplex.  Note that gap regions between end of SSR region and first adjacent base of both flanking regions defined region of interest (ROI). Some mappers such as BowTie2 tend to place "extra" repeat units in the gap region between the SSR and the first adjacent base to the left of the SSR, while Genious mapper tends to place "extra" repeat units to the right of the SSR, in the gap between the SSR and the first adjacent baseFor each read the Geneious "Extract" function was used to select bases within the ROI to create a new FASTQ file of CCS with bases spanning the ROI.Portion of CCS spanning the region of interest
?. [Extract region of interest from each read into FASTQ file.]
Create the following FASTQ reads for downstream analysis in MATLAB (link to CodeOcean capsule)
?. [Computed processes in Matlab for pruning reads to reveal reads representing extant molecules   ]
Matlab scripts for processing ROI CCS (above step)  are available for download and processing at Matlab  Compute Capsule