Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Use reassembly.sh and medaka.sh Scripts

These two scripts help you process and assemble long-read sequencing data using NanoFilt, Flye, and Medaka.


What You Need First

  1. A folder with your raw .fastq.gz file — one file per sample.

    • Example: /Users/you/sequencing_data/SampleA/SampleA.fastq.gz
  2. The required tools:

Using Conda Environments

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.

Step 0: Set Up Conda (If Not Already Installed)

If you don't have conda installed, install Miniconda from:
https://docs.conda.io/en/latest/miniconda.html


Environment Setup (One-Time Only)

Open a terminal and run the following once to create the environments:

For reassembly.sh:

conda create -n contig_assembly python=3.9
conda activate contig_assembly
conda install -c bioconda nanofilt flye minimap2 samtools seqkit nanoplot

For medaka.sh:

conda create -n medaka_env python=3.9
conda activate medaka_env
conda install -c bioconda medaka

Activating the Right Environment Before Running Scripts

Each time you open a new terminal or before running a script:

To run reassembly.sh, activate:

conda activate contig_assembly
./reassembly.sh /full/path/to/sample_directory

To run medaka.sh, activate:

conda activate medaka_env
./medaka.sh /full/path/to/sample_directory

You must activate the correct environment before running each script so that all required tools are available.


Tip

You can verify the active conda environment with:

conda info --envs

The currently active one will have an asterisk * next to it.



Step-by-Step Instructions

Step 1: Make Scripts Executable

chmod +x reassembly.sh
chmod +x medaka.sh

Step 2: Run the Reassembly Script

This script:

  • Filters reads
  • Runs Flye for assembly
  • Aligns reads with minimap2
  • Generates read depth & QC metrics

Basic Command:

./reassembly.sh /full/path/to/sample_directory

With 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)

What You’ll Get

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

Step 3: Run the Medaka Polishing Script

After the Flye assembly is complete, run Medaka to polish the consensus.

./medaka.sh /full/path/to/sample_directory

Medaka will:

  • Use the Flye assembly and filtered reads
  • Output polished results to Flye_assembly/Medaka_Consensus_Assembly/

Tips

  • 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

Need Help?

To see usage instructions in the terminal, just run:

./reassembly.sh
./medaka.sh

Saving Script Output to a Log File

To 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>&1 ensures that standard error (stderr) is also redirected to the same file.

Example:

bash assembly.sh > assembly.log 2>&1

This 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.


Watching the Log File in Real Time

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.log

You can stop watching the log at any time by pressing Ctrl + C.


Opening Log Files in the Terminal

Once a run is complete, and you want to open a log filr, use the less command:

less output.log

Updating Your Local Repository with git pull

If changes have been made to the GitHub repository by someone else, you need to update your local copy to implement those changes with:

git pull

This 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.

About

A repositiory that contains the tools necessary to utilize Flye to assemble long-read sequencing reads from oxford-nanopore platforms. Medaka is utilized to polish the assembly as a follow-up step.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages