These two scripts help you process and assemble long-read sequencing data using NanoFilt, Flye, and Medaka.
-
A folder with your raw
.fastq.gzfile — one file per sample.- Example:
/Users/you/sequencing_data/SampleA/SampleA.fastq.gz
- Example:
-
The required tools:
These scripts require different tools that are best managed using separate conda environments. Conda helps manage software dependencies in isolated environments to avoid version conflicts.
If you don't have conda installed, install Miniconda from:
https://docs.conda.io/en/latest/miniconda.html
Open a terminal and run the following once to create the environments:
conda create -n contig_assembly python=3.9
conda activate contig_assembly
conda install -c bioconda nanofilt flye minimap2 samtools seqkit nanoplotconda create -n medaka_env python=3.9
conda activate medaka_env
conda install -c bioconda medakaEach time you open a new terminal or before running a script:
conda activate contig_assembly
./reassembly.sh /full/path/to/sample_directoryconda activate medaka_env
./medaka.sh /full/path/to/sample_directoryYou must activate the correct environment before running each script so that all required tools are available.
You can verify the active conda environment with:
conda info --envsThe currently active one will have an asterisk * next to it.
chmod +x reassembly.sh
chmod +x medaka.shThis script:
- Filters reads
- Runs Flye for assembly
- Aligns reads with minimap2
- Generates read depth & QC metrics
Basic Command:
./reassembly.sh /full/path/to/sample_directoryWith Optional Settings:
./reassembly.sh /full/path/to/sample_directory \
-l 12000 \ # minimum read length (default: 10000)
-q 25 \ # minimum read quality (default: 20)
-i 4 \ # Flye polishing iterations (default: 5)
-t 8 \ # number of threads (default: 1)
-g 12k \ # genome size (default: 10k)
-m 3000 # minimum overlap (default: 5000)Inside your sample folder:
*_filtered_reads.fastq- A
Flye_assembly/folder with assembly results - A
Flye_assembly/minimap2_alignment/folder with alignment files and metrics
After the Flye assembly is complete, run Medaka to polish the consensus.
./medaka.sh /full/path/to/sample_directoryMedaka will:
- Use the Flye assembly and filtered reads
- Output polished results to
Flye_assembly/Medaka_Consensus_Assembly/
- Always use the full path to your sample folder.
- Each sample folder must contain:
your_sample.fastq.gz- (after running
reassembly.sh)your_sample_filtered_reads.fastq Flye_assembly/assembly.fasta
To see usage instructions in the terminal, just run:
./reassembly.sh
./medaka.shTo record all output (both standard output and error messages) from a script into a single .log file, you can use the following syntax:
bash script_name.sh > output.log 2>&1>redirects standard output (stdout) to the file.2>&1ensures that standard error (stderr) is also redirected to the same file.
bash assembly.sh > assembly.log 2>&1This command will run assembly.sh and save everything it prints—including errors—to assembly.log.
** IMPORTANT WARNING ** Using the above commands will instantly and permanently delete any previous log files with the same pathname. If you want to run the script again, but want to preserve the results and .log file from a previous run, you should copy the starting files into a new directory.
Most of the time, if you need to re-run the scripts, it is because the assembly didn't work the first time. In which case, re-running it with different parameters in the same directory and overwriting the previous files is desired anyway.
If you want to watch the log file as it's being written to (for example, to monitor progress or catch errors as they occur), use the tail command with the -f (follow) flag:
tail -f output.logYou can stop watching the log at any time by pressing Ctrl + C.
Once a run is complete, and you want to open a log filr, use the less command:
less output.logIf changes have been made to the GitHub repository by someone else, you need to update your local copy to implement those changes with:
git pullThis command fetches the latest changes from GitHub and merges them into your local project.
Use git pull anytime you want to make sure your local files are up to date with the latest version on GitHub.