All-in-one solution for discovering novel DNA barcode
Download the package, unzip, and run.
Open terminal, run
# Install, using pip (recommended) pip install BarcodeFinder --user # Initiliaze with Internet # Windows python -m BarcodeFinder init # Linux and MacOS python3 -m BarcodeFinder init # Run # Windows python -m BarcodeFinder # Linux and MacOS python3 -m BarcodeFinder
Table of Contents
- Quick start
:heavy_check_mark: Automatically collect, organize and clean sequence data from NCBI GenBank or local: collect data with abundant options; extract CDS, intergenic spacer, or any other annotations from original sequencep; remove redundant sequences according to species information; remove invalid or abnormal sequences/fragments; generate clean dataset with uniform sequence id.
:heavy_check_mark: Evaluate variance of sequences by calculating nucleotide diversity, observed resolution, Shannon index, tree resolution, phylogenetic diversity (original and edited version), gap ratio, and others. Support sliding-window scanning.
:heavy_check_mark: Design universal primer for the alignment. Support ambiguous bases in primers.
BarcodeFinder requires very few computational resources. A normal PC/laptop is enough. For downloading large amount of data, make sure the Internet connection is stable and fast enough.
For the portable version, nothing need to be installed manually.
For installing from pip, Python is required. Notice that the python version should be higher than 3.6.
:white_check_mark: All third-party dependencies will be automatically
installed with Internet, including
primer3-py, (python packages), and
We assume that users have already installed Python3 (3.7 or above).
Download from the link, unpack and run with Internet for the first time.
Install with pip
Install Python. 3.7 or newer is required.
Open command line, run
pip install BarcodeFinder --user
During the first running,
barcodefinder will check and initialize the
running environment. Missing dependencies will be automatically installed.
This step requires Internet connection.
# Windows python -m BarcodeFinder init # Linux and MacOS python3 -m BarcodeFinder init
If BarcodeFinder FAILED to install third-party software, please follow these steps:
For Linux users with root privileges, just use the package manager:
# Ubuntu and Debian sudo apt install mafft ncbi-blast+ iqtree # Fedora (1) sudo dnf install mafft ncbi-blast+ iqtree # Fedora (2) sudo yum install mafft ncbi-blast+ iqtree # ArchLinux sudo pacman -S mafft ncbi-blast+ iqtree # FreeBSD sudo pkg install mafft ncbi-blast+ iqtree
For MacOS users with root privileges, install
brew if it has not been
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If any errors occur, install Xcode from the App Store and retry.
brew install blast mafft brewsci/science/iqtree
If using Windows or lacking root privileges, users should follow these instructions:
Choose "All-in-one version", download and unzip. Then follow the steps in the BLAST+ installation manual to set the
Choose "Portable package", download and unzip. Then follow the instructions of BLAST+ to set the
Choose "All-in-one version", download and unzip. Then follow the steps in the BLAST+ installation manual to set the
Download the installer according to OS. Unzip and add the path of subfolder
BarcodeFinder is a command-line program. Once a user opens the command line (Windows) or terminal (Linux and MacOS), just type the command:
# Windows python -m BarcodeFinder [input] -[options] -out [out_folder] # Linux and MacOS python3 -m BarcodeFinder [input] -[options] -out [out_folder]
- Download all
rbcLsequences of species in Poaceae family and do pre-process.
# Windows python -m BarcodeFinder.gb2fasta -gene rbcL -taxon Poaceae -out rbcL_Poaceae # Linux and macOS python3 -m BarcodeFinder.gb2fasta -gene rbcL -taxon Poaceae -out rbcL_Poaceae
- Download all ITS sequences of Rosa genus. Do pre-process and keep redundant sequences:
# Windows python -m BarcodeFinder.gb2fasta -query internal transcribed spacer -taxon Rosa -out Rosa_its -uniq no # Linux and macOS python3 -m BarcodeFinder.gb2fasta -query internal transcribed spacer -taxon Rosa -out Rosa_its -uniq no
- Download all Lamiaceae chloroplast genome sequences in the RefSeq database. Then do pre-process and evaluation of variance (skip primer designing):
# Windows python -m BarcodeFinder -og cp -refseq -taxon Lamiaceae -out Lamiaceae_cp -skip_primer # Linux and macOS python3 -m BarcodeFinder -og cp -refseq -taxon Lamiaceae -out Lamiaceae_cp -skip_primer
- Download sequences of Zea mays, set length between 100 bp and 3000 bp, and then perform evaluation and primer designing. Note that the space in the species name is replaced with underscore "_".
# Windows python -m BarcodeFinder -taxon Zea_mays -min_len 100 -max_len 3000 -out Zea_mays # Linux and macOS python3 -m BarcodeFinder -taxon Zea_mays -min_len 100 -max_len 3000 -out Zea_mays
- Download all Oryza mitochondria genomes in RefSeq database, keep the longest sequence for each species and run a full analysis:
# Windows python -m BarcodeFinder -taxon Oryza -og mt -min_len 50000 -max_len 200000 -uniq longest -out Oryza_cp -refseq yes # Linux and macOS python3 -m BarcodeFinder -taxon Oryza -og mt -min_len 50000 -max_len 200000 -uniq longest -out Oryza_cp -refseq yes
BarcodeFinder uses a uniform sequence id format for input fasta files and all output sequences.
Locus|Kingdom|Phylum|Class|Order|Family|Genus|Species|Accession|SpecimenID|Isolate # example rbcL|Viridiplantae|Streptophyta|Magnoliopsida|Poales|Poaceae|Oryza|longistaminata|MF998442|TAN:GB60B-2014|
The order of the fields is fixed. The fields are separated by vertical bars ("|"). The space character (" ") was disallowed and was replaced by an underscore ("_"). Due to missing data, some fields may be empty.
Locus: SeqName refers to the name of a sequence. Usually it is the gene
name. For intergenic spacer, an underscore ("_") is used to connect two
gene's names, e.g., "geneA_geneB".
If a valid sequence name cannot be found in the annotations of the GenBank file, BarcodeFinder will use "Unknown" instead.
For chloroplast genes, if "-rename" option is set, the program will try to use regular expressions to fix potential errors in gene names.
Kingdom: The kingdom (Fungi, Viridiplantae, Metazoa) of a species. For
convenience, a superkingdom (Bacteria, Archaea, Eukaryota, Viruses, Viroids)
may be used if the kingdom information for a sequence is missing.
Phylum: The phylum of the species.
Class: The class of the species.
Because some species' classes are empty (for instance, basal angiosperm), BarcodeFinder will guess the class of the species.
Given the taxonomy information in GenBank file:
Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta; Spermatophyta; Magnoliophyta; basal Magnoliophyta; Amborellales; Amborellaceae; Amborella.
BarcodeFinder will use "basal Magnoliophyta" as the class because this expression locates before the order name ("Amborellales").
Order: The order name of the species.
Family: The family name of the species.
Genus: The genus name of the species, i.e., the first part of the scientific
Species: The specific epithet of the species, i.e., the second part of the
scientific name of the species. It may contain the subspecies' name.
Accession: The GenBank Accession number for the sequence. It does not
contain the record's version.
SpecimenID: Specimen ID of the sequence. May be empty.
Isolate: Isolate ID of the sequence. May be empty.
:exclamation: In Linux and MacOS, Python2 is
python2 and Python3 is
python3. However, in Windows, Python3 is called
python, too. Please
notice the difference.
- Show help information of each module
# Windows python -m BarcodeFinder -h python -m BarcodeFinder.gb2fasta -h python -m BarcodeFinder.evaluate -h python -m BarcodeFinder.primer -h # Linux and MacOS python3 -m BarcodeFinder.gb2fasta -h python3 -m BarcodeFinder.evaluate -h python3 -m BarcodeFinder.primer -h
- Full process
# Windows python -m BarcodeFinder -gene [gene name] -taxon [taxon name] -og [organelle type] -out [output name] # Linux and MacOS python3 -m BarcodeFinder -gene [gene name] -taxon [taxon name] -og [organelle type] -out [output name]
- Collect, convert, and clean GenBank data with gb2fasta module
# Windows python -m BarcodeFinder.gb2fasta -gene [gene name] -taxon [taxon name] -og [organelle type] -out [output name] # Linux and MacOS python3 -m BarcodeFinder.gb2fasta -gene [gene name] -taxon [taxon name] -og [organelle type] -out [output name]
- Evaluate variance of given fasta files
# Windows python -m BarcodeFinder.evaluate -fasta [fasta files] # Linux and MacOS python3 -m BarcodeFinder.evaluate -fasta [input file]
- Design universal primers of given alignments.
# Windows python -m BarcodeFinder.primer -aln [alignment files] # Linux and MacOS python3 -m BarcodeFinder.primer -aln [alignment files]
- GenBank queries. Users can use "-query" or combine with any other filters;
- GenBank-format files.
- Unaligned fasta files. Each file is considered as one locus when evaluating the variance;
- Alignments (fasta format).
All results will be put in the output folder. If the user does not set the output path via "-out", BarcodeFinder will create a folder labelled "Result".
In the output folder, several subfolders will be created.
Raw GenBank files.
Fasta files converted from the GenBank file. Each file represents a fragment of the original sequence according to the annotation.
For instance, a record in a "rbcL.gb" file may also contain atpB gene's sequences. The "rbcL.fasta" file does not contain any upstream/downstream sequences and "atpB_rbcL.fasta" does not have even one base of the atpB or rbcL gene, just the spacer (assuming the annotation is precise).
User can skip this dividing step with the option "-no_divide".
Raw fasta files users provided.
Fasta files after removing redundant sequences.
To design primers, BarcodeFinder extend a sequence to its upstream/downstream. Only used in the primer module.
Aligned fasta files.
.aln: The aligned fasta files.
.-consensus.fastq: The fastq format of the consensus sequence of the alignment. Note that it contains alignment gap ("-"). It is NOT RECOMMENDED to be used directly because the consensus-generating algorithm is optimised for primer design.
Including output files from the evaluation module.
.csv: The CSV format file of the sliding-window scan result.
"Index"means the location of the base in the alignment.
Including output files from the primer module.
.primer.fastq: The fastq format file of a primer's sequence. It contains two sequences, and the direction is 5' to 3'. The first is the forward primer, and the second is the reverse primer. The quality of each base is equal to its proportion of the column in the alignment. Note that the sequence may contains ambiguous bases if it was not disabled.
.primers.csv: The list of primer pairs in CSV (comma-separated values text) format.
.candidate.fasta: The candidate primers. This file may contains thousands of records. Do not recommend paying attention to it.
.candidate.fastq: Again, the candidate primers. This time, each file has the quality information that equals to the proportion of the bases in the column of the alignment.
Including temporary files. Could be safely deleted .
In the output folder, there are some other important output files:
The list of primer pairs in CSV (comma-separated values text) format.
Locus: The name of the locus/fragment.
Samples: The number of sequences used to find this pair of primers.
Score: The score of this pair of primers. Usually the higher, the better.
AvgProductLength: The average length of the DNA fragment amplified by this pair of primers.
StdEV: The standard deviation of the AvgProductLength. A higher number means the primer may amplify different lengths of DNA fragments.
MinProductLength: The minimum length of an amplified fragment.
MaxProductLength: The maximum length of an amplified fragment. Note that all of these fields are calculated using given sequences.
Coverage: The coverage of this pair of primers over the sequences it used. Calculated with the BLAST result. High coverage means that the pair is much more "universal".
observed resolutionof the sub-alignment sliced by the primer pair, which is equal to the number of unique sequences divided by the number of total sequences. The value is between 0 and 1.
tree resolutionof the sub-alignment, which is equal to the number of internal nodes on a phylogenetic tree (constructed from the alignment) divided by number of terminal nodes. The value is between 0 and 1.
PD_terminal: The average of the terminal branch's length. It's an edited version of the
Phylogenetic Diversityfor DNA barcoding evaluation.
Shannon equitabilityindex of the sub-alignment. The value is between 0 and 1.
LeftSeq: Sequence of the forward primer. The direction is 5' to 3'.
LeftTm: The melting temperature of the forward primer. The unit is degree Celsius (掳C).
LeftAvgBitscore: The average raw bitscore of the forward primer, which is calculated by BLAST.
LeftAvgMismatch: The average number of mismatched bases of the forward primer, as counted by BLAST.
RightSeq: Sequence of reverse primer. The direction is 5' to 3'.
RightTm: The melting temperature of the reverse primer. The unit is degrees Celsius (掳C).
RightAvgBitscore: The average raw bitscore of the reverse primer, which is calculated by BLAST.
RightAvgMismatch: The average number of mismatched bases of the reverse primer, as counted by BLAST.
DeltaTm: The difference in the melting temperatures of the forward and reverse primers. A pair of primers with a high DeltaTm may result in failure during the PCR experiment.
AlnStart: The location of the beginning of the forward primer (5', leftmost of primer pairs) in the entire alignment.
AlnEnd: The location of the end of the reverse primer (5', rightmost of primer pairs) in the entire alignment.
AvgSeqStart: The average beginning of the forward primer in the original sequences. ONLY USED FOR DEBUG.
AvgSeqEnd: The average end of the forward primer in the original sequences. ONLY USED FOR DEBUG.
The primer pairs are sorted by
Score. Since the score may not fully satisfy the user's specific considerations, it is suggested that primer pairs be chosen manually if the first primer pair fails during the PCR experiment.
The log file. Contains all the information printed on the screen.
The summary of all loci/fragments, which only contains the variance information for each fragment. One of the new field,
GapRatio, means the ratio of the gap ("-") in the alignment.
PDmeans the original version of the phylogenetic diversity and
PD_stemmeans an alternative version of it which only calculate the length of the stem branch in the phylogenetic tree.
Here are some general options for the program and submodule:
-h: Prints help messages of the program or one of the module.
-gb [filename]: User-provided GenBank file or files. Could be one or more
files that separated by space.
# one file -gb sequence.gb # multiple files -gb matK.gb rbcL.gb Oryza.gb Homo_sapiens.gb
-fasta [filename]: User-provided unaligned fasta files. Could be one or
-aln [filename]: Alignment files that the user provides. Could be one ore
It only supports the fasta format. Ambiguous bases and gaps ("-") are supported.
-out [folder name]: The output folder's name. All results will be put into
the output folder. If the user does not set an output path via "-out",
BarcodeFinder will create a folder named "Result".
BarcodeFinder does not overwrite the existing folder with the same name.
It is HIGHLY RECOMMENDED to use only letters, numbers and underscores ("_") in the folder name to avoid mysterious errors caused by other Unicode characters.
Options below are for specific modules.
Options used for querying NCBI GenBank.
-taxon [taxonomy name]: The taxonomy name. It could be any taxonomic rank
from kingdom (same as "-group") to species, as long as the user inputs correct
name (the scientific name of species or taxonomic group in latin, NOT
ENGLISH). It will restrict the query to the targeted taxonomy unit. Make sure
to use quotation marks if
taxonomy has more than one word or use underscore
to replace space, for instance
"Zea mays" or
-gene [gene name]: The gene's name which the user wants to query in GenBank.
If the user wants to use logical expressions like "OR", "AND", "NOT", s/he
should use "-query" instead. If there is space in the gene's name, make sure
to use quotation marks.
Note that "ITS" is not a gene name--it is "internal transcribed spacer".
Sometimes "-gene" options may bring in unwanted sequences. For example, if a user queries "rbcL[gene]" in GenBank, spacer sequences may contain rbcL or rbcL's upstream/downstream gene, such as "atpB_rbcL spacer" or atpB.
-og [ignore|both|no|mt|mitochondrion|cp|chloroplast|pl|plastid]: Query
organelle sequences or not. The default value is
- `ignore`: do not consider organelle type, same as GenBank website's default setting. - `both`: only query organelle sequences, including both plastid and mitochondrion. - `no`: exclude organelle sequences from the query. - `cp` or `chloroplast` or `pl` or `plastid`: only query plastid sequences - `mt` or `mitochondrion`: only query mitochondrion sequences.
-refseq [both|yes|no]: query in RefSeq database or not. The default value is
- `both`: query all sequences in or not in RefSeq database, same as NCBI website's default setting. - `yes`: only query sequences in RefSeq database. - `no`: exclude sequences in RefSeq database.
RefSeq is considered to have
higher sequence and annotation quality than GenBank. This option could be used
for getting nuclear/organelle genomes from NCBI. In this situation (
-refseq yes), the length limit will be removed automatically.
-seq_n [number]: Restrict numbers of sequences to be downloaded. The default
0 means no restriction.
-min_len [length]: The minimum length of the records downloaded from
GenBank. The default value is
100 (bp). The number must be an integer.
-max_len [length]: The maximum length of the records downloaded from
GenBank. The default value is
10000 (bp). The number must be an integer.
-date_start [yyyy/mm/dd]: The beginning of the release data range of the
sequences, the format is yyyy/mm/dd.
-date_end [yyyy/mm/dd]: The end of the release data range of the sequences,
the format is yyyy/mm/dd.
-molecular [all|DNA|RNA]: The molecular type,
which could be DNA or RNA. The
-email [email address]: NCBI GenBank database requires users to provide
an email address in case of abnormal situations that NCBI need to contact
the user. For convenience, BarcodeFinder will use
"email@example.com" if the user does not provide an email address. However,
it is better to provide a real email address for potential contact.
-query [expression]: The query string provided by the user. It behaves in
the same manner as the query the user typed into the Search Box in NCBI
Make sure to follow NCBI's grammar for queries. It can contain several words.
Remember to add quotation marks if an item contains more than one words, for
"Homo sapiens"[organism], or use underscore to replace space,
-exclude [expression]: Use this option to use negative option. For instance,
"-exclude Zea [organism]" (do not include quotation marks) will add " NOT
(Zea[organism])" to the query.
This option can be useful for excluding a specific taxon.
-taxon Zea -exclude "Zea mays"[organism]
This will query all records in genus Zea while records of Zea mays will be excluded.
For much more complex exclude options, please consider to use "Advance search" in GenBank website.
-group [all|animals|plants|fungi|protists|bacteria|archaea|viruses]: To
restrict the query in given group. The default value is
It is reported that the "group" filter may return abnormal records, for instance, return plants' records when the group is "animal" and the "organelle" is "chloroplast". Furthermore, it may match a great number of records in GenBank. Hence, we strongly recommend using "-taxon" instead.
Options used for converting GenBank files to fasta files.
-no_divide: If set, it will analyse the whole sequence instead of the
divided fragments. By default, BarcodeFinder divides one GenBank record into
several fragments according to its annotation.
-rename: If set, the program will try to rename genes. For instance, "rbcl"
will be renamed to "rbcL", and "tRNA UAC" will be renamed to "trnVuac", which
consists of "trn", the amino acid's letter and transcribed codon. This may be
helpful if the annotation has nonstandard uppercase/lowercase or naming format
that it can merge the same sequences to one file for the same locus having
If using Windows operating system, consider using this option to avoid contradictory filenames.
-unique [longest|first|no]: The method used to remove redundant sequences.
BarcodeFinder will remove redundant sequences to ensure only one sequence per
species by default. A user can change its behaviour by setting different
- `first`: According to the records' order in the original GenBank file, only the first sequence of the same species' same locus will be kept. Others will be ignored directly. This is the default option due to performance considerations. - `longest`: Keep the longest sequence for one species. The program will compare the sequence's length from the same species' same locus. - `no`: Skip this step. All sequences will be kept.
-allow_mosaic_spacer: If one gene nested with another gene, normally they
do not have spacers. The default value is
However, some users want the fragments between two gene's beginnings and ends. This option is for this specific purpose (e.g., matK-trnK_UUU). For normal usage, do not recommend.
-expand [number]: The expansion length in upstream/downstream. If set,
BarcodeFinder will expand the sequence to its upstream/downstream after the
dividing step to find primer candidates. The default value is
Note that this option is different with "-max_len". This option limits the length of one annotation's sequence. The "-max_len" limits the whole sequence's length of one GenBank record.
-allow_repeat: If genes repeated in downstream, this option will allow the
repeat region to be extracted, otherwise any repeated region will be omitted.
The default value is
-allow_invert_repeat: If two genes invert-repeated in downstream, this
option will allow the spacer of them to be extracted, otherwise the spacer
will be omitted. The default value is
For instance, geneA-geneB located in one invert-repeat region (IR) of chloroplast genome. In another IR region, there are geneB-geneA. This option will extract sequences of two different direction as two unique spacers.
-max_name_len [number]: The maximum length of a feature name. Some
annotation's feature name in GenBank file is too long, and usually, they are
not the target sequence the user wants. By setting this option, BarcodeFinder
will truncate the annotation's feature name if it is too long. By default, the
-max_seq_len [value]: The maximum length of a sequence for one annotation.
Some annotations' sequences are too long (for instance, one gene has two
exons, and its intron is longer than 10 Kb). This option will skip those long
sequences. By default, the value is
-ignore_gap: ignore gaps in the alignment.
-ignore_ambigous: ignore ambiguous bases in the alignment.
-quick: skip sliding-window scan.
-size [number]: the window size of the sliding window scan. The default
-step [number]: the step size of the sliding window scan. The default value
-skip_primer: skip primer designing. The default value is
-coverage [value]: The minimum coverage of the base and primer. The default
0.5 (50%). It is used to remove primer candidates if its coverage
among all sequences is smaller than the threshold. The coverage of primers is
calculated by BLAST.
-res [value]: The minimum observed resolution of the fragments or primer
pairs. The default value is 0.3 (30%). The value should be in 0.0 to 1.0.
BarcodeFinder uses the observed resolution instead of others because of the speed. Also, it is considered to be the lower bound of the real resolution that a fragment with a low observed resolution may not have a satisfactory tree resolution/phylogenetic diversity, either.
-pmin [length]: The minimal length of the primer. The default value is 20.
-pmax [length]: The maximal length of the primer. The default value is 25.
-topn [number]: How many pairs of primers is kept for each input alignment.
The default value is
1, i.e., only keep the best primer pair according to
score. To keep more pairs, set "-t" to more than 1.
-tmin [length]: The minimum product length (include primer). The default
300 (bp). Note this limits the PCR product's length instead of the
-tmax [length]: The maximum product length (include primer).
The "-tmin" and "-tmax" are used to screen primer candidates. It uses BLAST results to set the location of primers on each template sequence and calculates the average lengths of the products. Because of the variance of species, the same locus may have different lengths in different species, plus with the stretching of the alignment that gaps were added during the aligning, please consider adding some margins for these two options.
For instance, if a user wants the amplified length to be smaller than 800 and greater than 500, s/he could consider setting "-tmin" to 550 and "-tmax" to 750.
-ambiguous [number]: The maximum number of ambiguous bases allowed in one
primer. The default value is
-mismatch [number]: The maximum number of mismatched bases in a primer. This
options is used to remove primer candidates if the BLAST results show that
there is too much mismatch. The default value is
For a taxon that is not very large and includes few fragments, BarcodeFinder can finish the task in minutes. For a large taxon (such as the Asteraceae family or the whole class of the Poales) containing multiple fragments (such as the chloroplast genomes), the time to complete may be one hour or more on a PC or laptop.
BarcodeFinder requires few memories (usually less than 0.5 GB, although, for a large taxon BLAST may require more) and few CPUs (one core is enough). It can run very well on a normal PC. Multiple CPU cores may be helpful for the alignment and tree construction steps.
As yet unpublished.
The software itself is licensed under AGPL-3.0 (not include third-party software).
Please submit your questions in the Issue page :smiley:
Q: I got error message that the program failed to install MAFFT/BLAST/IQTREE.
A: Uncommonly, users in specific area have connection issue for those websites. Users have to manually download packages and install (see Software for the download links).
For Windows users, please download and unpack files into
For Linux and MacOS users, please download and unpack files into
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size BarcodeFinder-0.9.49-py3-none-any.whl (71.2 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
Hashes for BarcodeFinder-0.9.49-py3-none-any.whl