| 
3
 | 
     1 [](http://dx.doi.org/10.5281/zenodo.215824)
 | 
| 
 | 
     2 
 | 
| 
 | 
     3 bac-genomics-scripts
 | 
| 
 | 
     4 ====================
 | 
| 
 | 
     5 
 | 
| 
 | 
     6 A collection of scripts intended for **bacterial genomics** (some might also be useful for eukaryotes) from **high-throughput sequencing** (aka next-generation sequencing).
 | 
| 
 | 
     7 
 | 
| 
 | 
     8 * [Summary](#summary)
 | 
| 
 | 
     9 * [Introduction](#introduction)
 | 
| 
 | 
    10 * [Installation recommendations](#installation-recommendations)
 | 
| 
 | 
    11 * [Dependencies](#dependencies)
 | 
| 
 | 
    12 * [UNIX loops](#unix-loops)
 | 
| 
 | 
    13 * [Windows - UNIX linebreak problems](#windows---unix-linebreak-problems)
 | 
| 
 | 
    14 * [Citation](#citation)
 | 
| 
 | 
    15 * [License](#license)
 | 
| 
 | 
    16 * [Author - contact](#author---contact)
 | 
| 
 | 
    17 
 | 
| 
 | 
    18 ## Summary
 | 
| 
 | 
    19 
 | 
| 
 | 
    20 * Basic stats for bases and reads in FASTQ files: [`calc_fastq-stats`](/calc_fastq-stats)
 | 
| 
 | 
    21 * Concatenate multi-sequence files (RichSeq EMBL or GENBANK format, or FASTA format) to a single artificial file: [`cat_seq`](/cat_seq)
 | 
| 
 | 
    22 * COG ([cluster of orthologous groups](http://www.ncbi.nlm.nih.gov/COG/)) classification of proteins: [`cdd2cog`](/cdd2cog)
 | 
| 
 | 
    23 * Extraction of protein/nucleotide sequences from CDSs: [`cds_extractor`](/cds_extractor)
 | 
| 
 | 
    24 * MLST (multilocus sequence typing) assignment and allele extraction for *Escherichia coli* ([Achtman scheme](http://mlst.warwick.ac.uk/mlst/)): [`ecoli_mlst`](/ecoli_mlst)
 | 
| 
 | 
    25 * Create a feature table for all annotated primary features in RichSeq (EMBL or GENBANK format) files: [`genomes_feature_table`](/genomes_feature_table)
 | 
| 
 | 
    26 * **Deprecated!** Batch downloading of sequences from NCBI's FTP server: [`ncbi_ftp_download`](/ncbi_ftp_download)
 | 
| 
 | 
    27 * Order sequence entries in FASTA/FASTQ files according to an ID list: [`order_fastx`](/order_fastx)
 | 
| 
 | 
    28 * Create an ortholog/paralog annotation comparison matrix from [*Proteinortho5*](http://www.bioinf.uni-leipzig.de/Software/proteinortho/) output: [`po2anno`](/po2anno)
 | 
| 
 | 
    29 * Calculate stats and plot venn diagrams for genome groups according to orthologs/paralogs from [*Proteinortho5*](http://www.bioinf.uni-leipzig.de/Software/proteinortho/) output, i.e. overall presence/absence statistics for groups of genomes and not simply single genomes: [`po2group_stats`](/po2group_stats)
 | 
| 
 | 
    30 * Strain panel query protein search with **BLASTP** plus concise hit summary, optional alignment, and presence/absence matrix. Also included, scripts to transpose the matrix and calculate overall presence/absence statistics for groups of columns in the matrix: [`prot_finder`](/prot_finder)
 | 
| 
 | 
    31 * Rename FASTA ID lines and optionally numerate them: [`rename_fasta_id`](/rename_fasta_id)
 | 
| 
 | 
    32 * Reverse complement (multi-)sequence files (RichSeq EMBL or GENBANK format, or FASTA format): [`revcom_seq`](/revcom_seq)
 | 
| 
 | 
    33 * Regions of difference (ROD) detection in genomes with **BLASTN**: [`rod_finder`](/rod_finder)
 | 
| 
 | 
    34 * NGS paired-end library insert size estimation from BAM/SAM: [`sam_insert-size`](/sam_insert-size)
 | 
| 
 | 
    35 * Randomly subsample FASTA, FASTQ, or TEXT files with [*reservoir sampling*](https://en.wikipedia.org/wiki/Reservoir_sampling): [`sample_fastx-txt`](/sample_fastx-txt)
 | 
| 
 | 
    36 * Convert a sequence file to another format with [BioPerl](http://www.bioperl.org): [`seq_format-converter`](/seq_format-converter)
 | 
| 
 | 
    37 * Manual curation of annotation in NCBI's TBL format (e.g. from [Prokka](http://www.vicbioinformatics.com/software.prokka.shtml) automatic annotation) in a spreadsheet software: [`tbl2tab`](/tbl2tab)
 | 
| 
 | 
    38 * Truncate sequence files (RichSeq EMBL or GENBANK format, or FASTA format) according to given coordinates: [`trunc_seq`](/trunc_seq)
 | 
| 
 | 
    39 * And an assortment of smaller scripts for tasks like (not yet uploaded to GitHub): alignment format converters, dnadiff, GC% calculation etc.
 | 
| 
 | 
    40 
 | 
| 
 | 
    41 ## Introduction
 | 
| 
 | 
    42 
 | 
| 
 | 
    43 All the scripts here are written in [**Perl**](https://www.perl.org/) (some include bash shell wrappers).
 | 
| 
 | 
    44 
 | 
| 
 | 
    45 Each script is hosted in its own folder, so that a separate *README.md* can be included for more information. However, all of the Perl scripts include additionally a usage/help text or a comprehensive [POD](http://perldoc.perl.org/perlpod.html) (Plain Old Documentation) by calling the script either without arguments/options or option **-h|-help**.
 | 
| 
 | 
    46 
 | 
| 
 | 
    47 The scripts are only tested under UNIX, some won't run in a Windows environment (because of included UNIX commands). If you are on Windows an alternative might be [Cygwin](http://cygwin.com/).
 | 
| 
 | 
    48 
 | 
| 
 | 
    49 ## Installation recommendations
 | 
| 
 | 
    50 
 | 
| 
 | 
    51 To download the repository, use either the '[Download ZIP](https://github.com/aleimba/bac-genomics-scripts/archive/master.zip)' link after clicking the green 'Clone or download' button at the top or clone the repository with `git`:
 | 
| 
 | 
    52 
 | 
| 
 | 
    53     git clone https://github.com/aleimba/bac-genomics-scripts.git
 | 
| 
 | 
    54 
 | 
| 
 | 
    55 If there is an update to this GitHub repository (see above [commits](https://github.com/aleimba/bac-genomics-scripts/commits/master) and [releases](https://github.com/aleimba/bac-genomics-scripts/releases)), you can refresh your **local** repository by using the following command **inside** the local folder:
 | 
| 
 | 
    56 
 | 
| 
 | 
    57     git pull
 | 
| 
 | 
    58 
 | 
| 
 | 
    59 To install the scripts, copy them e.g. to a home */bin* folder in your *PATH* and make them executable
 | 
| 
 | 
    60 
 | 
| 
 | 
    61     $ find . \( -name '*.pl' -o -name '*.sh' -o -name '*.fas' -o -name '*.txt' \) -exec cp {} ~/bin \;
 | 
| 
 | 
    62     $ chmod u+x ~/bin/*.pl
 | 
| 
 | 
    63 
 | 
| 
 | 
    64 the scripts can then be run everywhere on your system. Of course you can just call them directly by prefexing `perl` to the command or a './' for bash wrappers:
 | 
| 
 | 
    65 
 | 
| 
 | 
    66     $ perl /path/to/script/script.pl <options>
 | 
| 
 | 
    67 
 | 
| 
 | 
    68 or
 | 
| 
 | 
    69 
 | 
| 
 | 
    70     $ ./script.sh <arguments>
 | 
| 
 | 
    71 
 | 
| 
 | 
    72 **Single** scripts can be downloaded as well. For this purpose click on the folder you're interested in and then on the link of the script. There click on the **Raw** button and save this page to a file (without **Raw** you'll get an unusable html file). This is also true for other files (e.g. PDFs etc.).
 | 
| 
 | 
    73 
 | 
| 
 | 
    74 ## Dependencies
 | 
| 
 | 
    75 
 | 
| 
 | 
    76 All scripts are tested with Perl v5.22.1.
 | 
| 
 | 
    77 
 | 
| 
 | 
    78 Most of the Perl scripts include modules from [BioPerl](http://www.bioperl.org) as stated in their respective *README.md* or POD, which as a consequence has to be installed on your system. For BioPerl installation instructions see the website ([**Installation**](http://bioperl.org/INSTALL.html)).
 | 
| 
 | 
    79 
 | 
| 
 | 
    80 Some scripts need additional Perl modules, which will be stated in the associated *README.md* or POD. If they're not installed yet on your system get them from [CPAN](http://www.cpan.org/) (installation instructions can be found on the website, see e.g. [**Getting Started...Installing Perl Modules**](http://www.cpan.org/modules/INSTALL.html) or [**FAQ**](http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_modules)).
 | 
| 
 | 
    81 
 | 
| 
 | 
    82 Furthermore, some scripts call upon statistical computing language [**R**](http://www.r-project.org/) and dependent packages for plotting purposes (again see the respective *README.md* or POD).
 | 
| 
 | 
    83 
 | 
| 
 | 
    84 ## UNIX loops
 | 
| 
 | 
    85 
 | 
| 
 | 
    86 A very handy tip, if you want to run a script on all files in the current working directory you can use a **loop** in UNIX, e.g.:
 | 
| 
 | 
    87 
 | 
| 
 | 
    88     $ for file in *.fasta; do perl script.pl "$file"; done
 | 
| 
 | 
    89 
 | 
| 
 | 
    90 ## Windows - UNIX linebreak problems
 | 
| 
 | 
    91 
 | 
| 
 | 
    92 At last, some of the scripts don't like Windows formatted line breaks, you might consider running these input files through a nifty UNIX utility called [dos2unix](http://dos2unix.sourceforge.net/):
 | 
| 
 | 
    93 
 | 
| 
 | 
    94     $ dos2unix input
 | 
| 
 | 
    95 
 | 
| 
 | 
    96 ## Citation
 | 
| 
 | 
    97 For now cite the latest major release (tag: [***bovine_ecoli_mastitis***](https://github.com/aleimba/bac-genomics-scripts/releases)) hosted on [Zenodo](https://zenodo.org/):
 | 
| 
 | 
    98 
 | 
| 
 | 
    99 **Leimbach A**. 2016. bac-genomics-scripts: Bovine *E. coli* mastitis comparative genomics edition. Zenodo. <http://dx.doi.org/10.5281/zenodo.215824>.
 | 
| 
 | 
   100 
 | 
| 
 | 
   101 Also, all scripts have a version number (see option **-v**), which might be included in a materials and methods section.
 | 
| 
 | 
   102 
 | 
| 
 | 
   103 ## License
 | 
| 
 | 
   104 
 | 
| 
 | 
   105 All scripts are licensed under GPLv3 which is contained in the file [*LICENSE*](./LICENSE).
 | 
| 
 | 
   106 
 | 
| 
 | 
   107 ## Author - contact
 | 
| 
 | 
   108 For help, suggestions, bugs etc. use the GitHub issues or write an email to aleimba [at] gmx [dot] de.
 | 
| 
 | 
   109 
 | 
| 
 | 
   110 Andreas Leimbach (Microbial Genome Plasticity, Institute of Hygiene, University of Muenster)
 |