pax_global_header 0000666 0000000 0000000 00000000064 14265374640 0014525 g ustar 00root root 0000000 0000000 52 comment=61efcb35a667863c4a7ff73e7aec431e4abeb993
DWGSIM-dwgsim.0.1.14/ 0000775 0000000 0000000 00000000000 14265374640 0014073 5 ustar 00root root 0000000 0000000 DWGSIM-dwgsim.0.1.14/.github/ 0000775 0000000 0000000 00000000000 14265374640 0015433 5 ustar 00root root 0000000 0000000 DWGSIM-dwgsim.0.1.14/.github/workflows/ 0000775 0000000 0000000 00000000000 14265374640 0017470 5 ustar 00root root 0000000 0000000 DWGSIM-dwgsim.0.1.14/.github/workflows/testing.yml 0000664 0000000 0000000 00000000540 14265374640 0021667 0 ustar 00root root 0000000 0000000 name: Checks
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Checks
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Build
run: make
- name: Test
run: make test
DWGSIM-dwgsim.0.1.14/.gitignore 0000664 0000000 0000000 00000000020 14265374640 0016053 0 ustar 00root root 0000000 0000000 src/*.o
dwgsim*
DWGSIM-dwgsim.0.1.14/.gitmodules 0000664 0000000 0000000 00000000127 14265374640 0016250 0 ustar 00root root 0000000 0000000 [submodule "samtools"]
path = samtools
url = http://github.com/samtools/samtools.git
DWGSIM-dwgsim.0.1.14/INSTALL 0000664 0000000 0000000 00000001603 14265374640 0015124 0 ustar 00root root 0000000 0000000 Welcome to DWGSIM
=== Prerequisites ===
If you have just cloned this repository using GIT, you must
initialize the SAMtools sub-module:
git submodule init
git submodule update
You should now have the SAMtools-compatible version checked
out in the samtools sub-directory.
=== Building DWGSIM ===
To build DWGSIM, execute the following commands:
make
To install DWGSIM, after building, copy the following binaries
to their appropriate installation directories:
dwgsim
dwgsim_eval
dwgims_pileup_eval.pl
=== DWGSIM with Galaxy ===
DWGSIM can be incorporated into galaxy.
NB: this is out-of-date.
1. Copy over the wrapper scripts:
cp scripts/galaxy/dwgsim_wrapper.* galaxy-dist/tools/sr_mapping
2. Add to the list of available tools.
2a. Open galaxy-dist/tool_conf.xml
2b. At the end of the NGS: mapping section, add the following:
DWGSIM-dwgsim.0.1.14/LICENSE 0000664 0000000 0000000 00000043103 14265374640 0015101 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
DWGSIM-dwgsim.0.1.14/Makefile 0000664 0000000 0000000 00000005146 14265374640 0015541 0 ustar 00root root 0000000 0000000 PACKAGE_VERSION="0.1.14"
CC= gcc
CFLAGS= -g -Wall -O3 #-m64 #-arch ppc
DFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -DPACKAGE_VERSION=\\\"${PACKAGE_VERSION}\\\"
DWGSIM_AOBJS = src/dwgsim_opt.o src/mut.o src/contigs.o src/regions_bed.o \
src/mut_txt.o src/mut_bed.o src/mut_vcf.o src/mut_input.o src/dwgsim.o
DWGSIM_EVAL_AOBJS = src/dwgsim_eval.o \
samtools/knetfile.o \
samtools/bgzf.o samtools/kstring.o samtools/bam_aux.o samtools/bam.o samtools/bam_import.o samtools/sam.o samtools/bam_index.o \
samtools/bam_pileup.o samtools/bam_lpileup.o samtools/bam_md.o samtools/razf.o samtools/faidx.o samtools/bedidx.o \
samtools/bam_sort.o samtools/sam_header.o samtools/bam_reheader.o samtools/kprobaln.o samtools/bam_cat.o
PROG= dwgsim dwgsim_eval
INCLUDES= -I.
SUBDIRS= samtools .
CLEAN_SUBDIRS= samtools src
LIBPATH=
.SUFFIXES:.c .o
.c.o:
$(CC) -c $(CFLAGS) $(DFLAGS) $(INCLUDES) $< -o $@
all-recur lib-recur clean-recur cleanlocal-recur install-recur:
@target=`echo $@ | sed s/-recur//`; \
wdir=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
cd $$subdir; \
$(MAKE) CC="$(CC)" DFLAGS="$(DFLAGS)" CFLAGS="$(CFLAGS)" \
INCLUDES="$(INCLUDES)" LIBPATH="$(LIBPATH)" $$target || exit 1; \
cd $$wdir; \
done;
all:$(PROG)
.PHONY:all lib clean cleanlocal
.PHONY:all-recur lib-recur clean-recur cleanlocal-recur install-recur
dwgsim:lib-recur $(DWGSIM_AOBJS)
$(CC) $(CFLAGS) -o $@ $(DWGSIM_AOBJS) -lm -lz -lpthread
dwgsim_eval:lib-recur $(DWGSIM_EVAL_AOBJS)
$(CC) $(CFLAGS) -o $@ $(DWGSIM_EVAL_AOBJS) -Lsamtools -lm -lz -lpthread
cleanlocal:
rm -vfr gmon.out *.o a.out *.exe *.dSYM razip bgzip $(PROG) *~ *.a *.so.* *.so *.dylib; \
wdir=`pwd`; \
list='$(CLEAN_SUBDIRS)'; for subdir in $$list; do \
if [ -d $$subdir ]; then \
cd $$subdir; \
pwd; \
rm -vfr gmon.out *.o a.out *.exe *.dSYM razip bgzip $(PROG) *~ *.a *.so.* *.so *.dylib; \
cd $$wdir; \
fi; \
done;
clean:cleanlocal-recur
dist:clean
if [ -f dwgsim-${PACKAGE_VERSION}.tar.gz ]; then \
rm -rv dwgsim-${PACKAGE_VERSION}.tar.gz; \
fi; \
if [ -f dwgsim-${PACKAGE_VERSION}.tar ]; then \
rm -rv dwgsim-${PACKAGE_VERSION}.tar; \
fi; \
if [ -d dwgsim-${PACKAGE_VERSION} ]; then \
rm -rv dwgsim-${PACKAGE_VERSION}; \
fi; \
mkdir dwgsim-${PACKAGE_VERSION}; \
cp -r INSTALL LICENSE Makefile README scripts src dwgsim-${PACKAGE_VERSION}/.; \
tar -vcf dwgsim-${PACKAGE_VERSION}.tar dwgsim-${PACKAGE_VERSION}; \
gzip -9 dwgsim-${PACKAGE_VERSION}.tar; \
rm -rv dwgsim-${PACKAGE_VERSION};
test:
if [ -d tmp ]; then rm -r tmp; fi
/bin/bash testdata/test.sh
DWGSIM-dwgsim.0.1.14/README.md 0000664 0000000 0000000 00000001217 14265374640 0015353 0 ustar 00root root 0000000 0000000 [](https://github.com/nh13/DWGSIM/actions/workflows/testing.yml)
[](http://bioconda.github.io/recipes/dwgsim/README.html)
[](https://github.com/nh13/dwgsim/blob/main/LICENSE)
[](https://en.wikipedia.org/wiki/C_(programming_language))
Welcome to DWGSIM.
----
Documentation can be found in the [docs folder](docs/01_Introduction.md)
DWGSIM-dwgsim.0.1.14/docs/ 0000775 0000000 0000000 00000000000 14265374640 0015023 5 ustar 00root root 0000000 0000000 DWGSIM-dwgsim.0.1.14/docs/01_Introduction.md 0000664 0000000 0000000 00000000226 14265374640 0020326 0 ustar 00root root 0000000 0000000 # Introduction
* [Installation](02_Installation.md)
* [Simulating Reads](03_Simulating_Reads.md)
* [Evaluating Mappings](04_Evaluating_Mappings.md)
DWGSIM-dwgsim.0.1.14/docs/02_Installation.md 0000664 0000000 0000000 00000000447 14265374640 0020314 0 ustar 00root root 0000000 0000000 # Installation
Please use the following command when cloning this repository:
```console
git clone --recursive git@github.com:nh13/DWGSIM.git
```
Next, build the `dwgsim` and `dwgsim_eval` binaries:
```console
make
```
You can run a simple integration test with:
```console
make test
```
DWGSIM-dwgsim.0.1.14/docs/03_Simulating_Reads.md 0000664 0000000 0000000 00000013252 14265374640 0021104 0 ustar 00root root 0000000 0000000 # Simulating Reads
* [Overview](#overview)
* [Error rates explained](#error-rates-explained)
* [Read names explained](#read-names-explained)
* [Mate pair or paired end modes](#mate-pair-or-paired-end-modes)
* [Output mutations file](#output-mutations-file)
* [Output FASTQ files](#output-fastq-files)
## Overview
The `dwgsim` tool simulates reads from a reference genome FASTA.
It can be used to evaluate both mapping and variant calling.
See the `dwgsim_eval` tool for [Evaluating Mappings](04_Evaluating_Mappings.md).
Use `dwgsim -h` to see the full set of command line options (usage).
An example command is as follows:
```console
dwgsim -N 10000 -1 100 -2 100 -y 0 phix.fasta output
```
This will simulate 10,000 reads (`-N 10000`), which are paired end 2x100bp (`-1 100` for R1 and `-2 100` for R2), with no random reads (`-y 0`),
from the given genome FASTA (`phix.fasta`), producing output with prefix `output`.
The following output will be created:
| Name | Description |
| --- | --- |
| output.bfast.fastq.gz | Interleaved FASTQ containing both read one and read two |
| output.bwa.read1.fastq.gz | FASTQ containing only read one |
| output.bwa.read2.fastq.gz | FASTQ containing only read two |
| output.mutations.vcf | VCF containing simulated mutations |
| output.mutations.txt | TXT in a custom format containing simulated mutations (see [below](#output-mutations-file)) |
Notes:
- the longest supported insertion is 255bp
- The `-H` mode will simulate a haploid genome, whereas the default is to simulate a diploid genome.
## Error rates explained
The `-e` and `-E` options accept a uniform error rate (i.e. `-e 0.01` for 1%), or a uniformly increasing/decreasing error rate (i.e. `-e 0.01-0.1` for an error rate of 1% at the start of the read increasing to 10% at the end of the read).
## Read names explained
Read names are of the form:
```
@<#1>_<#2>_<#3>_<#4>_<#5>_<#6>_<#7>_<#8>:<#9>:<#10>_<#11>:<#12>:<#13>_<#14>
```
| Field | Description |
| --- | --- |
| 1 | contig name (chromsome name) |
| 2 | start read 1 (one-based) |
| 3 | start read 2 (one-based) |
| 4 | strand read 1 (0 - forward, 1 - reverse) |
| 5 | strand read 2 (0 - forward, 1 - reverse) |
| 6 | random read 1 (0 - from the mutated reference, 1 - random) |
| 7 | random read 2 (0 - from the mutated reference, 1 - random) |
| 8 | number of sequencing errors read 1 (color errors for colorspace) |
| 9 | number of SNPs read 1 |
| 10 | number of indels read 1 |
| 11 | number of sequencing errors read 2 (color errors for colorspace) |
| 12 | number of SNPs read 2 |
| 13 | number of indels read 2 |
| 14 | read number (unique within a given contig/chromsome) |
Read 1 and read 2 correspond to the first and second reads from a paired-end/mate-pair read respectively.
## Mate pair or paired end modes
This utility can generate mate pair or paired end reads using the `-S` option.
By default, Illumina (nucleotide) data are paired end, and SOLiD (color space) data are mate pair.
For clarity, lets call the first end sequence E1 and the second end E2.
Paired end reads have the following orientation:
```
5' E1 -----> .... 3'
3' .... <------- E2 5'
```
Above, the start co-ordinate of E1 is less than E2, with E1 and E2 reported on opposite strands.
Mate pair reads have following orientation
```
5' E2 -----> .... E1 -------> 3'
3' .... 5'
```
Above, the start co-ordinate of E1 is greater than E2, with E1 and E2 reported on the same strand.
So for SOLiD mate pair reads, the R3 tag (E2) is listed before the F3 tag (E1).
For SOLiD paired end reads, the F3 tag (E1) is listed before the F5 tag (E2).
## Output mutations file
The locations of introduced mutations are given in a `.mutations.txt` text file.
There are file columns:
1. the chromosome/contig name
2. the one-based position
3. the original reference base
4. the new reference base(s)
5. the variant strand(s)
SNPs are represented on one line, and in the case of heterozygous mutations, the new reference base is an [IUPAC](http://www.bioinformatics.org/sms/iupac.html) code.
```
contig4 4 T K 1
```
The above shows a heterozygous mutation at position 4 of contig4 on the first strand, mutating the T base to a heterozygous K (G or T) SNP.
Insertions are represented on one line, where the reference base is missing (indicated by a '-' in the third column).
```
contig5 13 - TAC 3
```
The above shows a homozygous insertion of TAC prior to position 13.
Each base of a deletion is represented on one line, where the new reference base is missing and represented by a '-'.
```
contig6 22 A - 2
```
The above shows a heterozygous deletion of T at position 22 on the second strand.
Multi-base deletions are show on consecutive lines.
```
contig6 22 A - 2
contig6 23 C - 2
```
The above shows a two base homozygous deletion of positions 22 and 23 on the second strand.
## Output FASTQ files
Three FASTQ files are produced, for use with BFAST (interleaved FASTQ) and BWA (one FASTQ per read end).
The FASTQ for BFAST is formatted so that the multi-end reads (paired end or mate pair) occur consecutively in the FASTQ (interleaved), with the read that is 5' of the other listed first.
For paired end reads, this means that E1 is always listed before E2.
For mate pair reads, this means that E2 is always listed before E1.
The FASTQs for BWA are split into two files, the first file for one end, the second file for the other, with the read that is 5' of the other in the first file.
For paired end reads, this means that E1 is in the first file and E2 is in the second file.
For mate pair reads, this means that E2 is in the first file and E1 is in the second file.
DWGSIM-dwgsim.0.1.14/docs/04_Evaluating_Mappings.md 0000664 0000000 0000000 00000006651 14265374640 0021615 0 ustar 00root root 0000000 0000000 # Evaluating Mappings
* [Overview](#overview)
* [Key Options](#key-options)
* [Output](#output)
## Overview
The `dwgsim_eval` tool evaluates the mappings from reads produced by `dwgsim`.
See the `dwgsim` tool for [Simulating Reads](03_Simulating_Reads.md).
Use `dwgsim_eval -h` to see the full set of command line options (usage).
An example command is as follows:
```console
dwgsim_eval mapped.bam
```
A read is correctly mapped if the mapped start position is within `INT` bases (`-g`) of the simulated read's start position.
Otherwise, it is counted as incorrectly mapped.
Furthermore, random reads created by `dwgsim` are expected to be unmapped (counted as false mappings otherwise).
## Key Options
- Use the `-c` option if the reads are from SOLID
- Use the `-b` option if the alignments are from BWA when mapping SOLiD reads
- Use the `-z` option if the input reads are expected to be single end (not paired end)
- Use the `-s` option if the input is a SAM file (default: BAM)
- Use the `-n` option to specify the number of reads if only a subset of the input reads were used (affects the denominator)
## Output
The `dwgsim_eval` tool outputs a table with the following columns:
| Column | Description |
| --- | --- |
| `thr` | The alignment threshold (see `-a`) |
| `mc` | The number of reads mapped correctly that should be mapped at the threshold |
| `mi` | The number of reads mapped incorrectly that should be mapped be mapped at the threshold |
| `mu` | The number of reads unmapped that should be mapped be mapped at the threshold |
| `um` | The number of reads mapped that should be unmapped be mapped at the threshold |
| `uu` | The number of reads unmapped that should be unmapped be mapped at the threshold |
| `mc + mi + mu + um + uu` | The total number of reads that should be unmapped be mapped at the threshold |
| `mc'` | The number of reads mapped correctly that should be mapped at or greater than the threshold |
| `mi'` | The number of reads mapped incorrectly that should be mapped be mapped at or greater than the threshold |
| `mu'` | The number of reads unmapped that should be mapped be mapped at or greater than the threshold |
| `um'` | The number of reads mapped that should be unmapped be mapped at or greater than the threshold |
| `uu'` | The number of reads unmapped that should be unmapped be mapped at or greater than the threshold |
| `mc' + mi' + mu' + um' + uu'` | The total number of reads that should be unmapped be mapped at or greater than the threshold |
| `mc / (mc + mi + mu)` | Sensitivity at the threshold. I.e. the fraction of reads that should be mapped that are mapped correctly. |
| `mc / (mc + mi)` | Positive predictive value at the threshold. I.e. The fraction of mapped reads that are mapped correctly. |
| `um / (um + uu)` | False discovery rate at the threshold. I.e. The fraction of random reads that are mapped. |
| `mc' / (mc' + mi' + mu')` | Sensitivity at or greater than the threshold. I.e. the fraction of reads that should be mapped that are mapped correctly. |
| `mc' / (mc' + mi')` | Positive predictive value at or greater than the threshold. I.e. The fraction of mapped reads that are mapped correctly. |
| `um' / (um' + uu')` | False discovery rate at or greater than the threshold. I.e. The fraction of random reads that are mapped. |
"At or greater than the threshold" tells us what our sensitivity, PPV, and FDR would be if we filtered based on that threshold.
DWGSIM-dwgsim.0.1.14/samtools/ 0000775 0000000 0000000 00000000000 14265374640 0015734 5 ustar 00root root 0000000 0000000 DWGSIM-dwgsim.0.1.14/scripts/ 0000775 0000000 0000000 00000000000 14265374640 0015562 5 ustar 00root root 0000000 0000000 DWGSIM-dwgsim.0.1.14/scripts/dwgsim_eval_plot.py 0000664 0000000 0000000 00000010504 14265374640 0021473 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
import os
import sys
from optparse import OptionParser
import re
import string
import pylab
class Table:
def __init__(self, fn, min_mapq):
ncol = -1
# read in the data
data = list()
fh = open(fn, 'r')
for line in fh:
line = line.rstrip("\r\n")
if '#' == line[0]:
continue
else:
table = self.__parse(line)
if table[0] < min_mapq:
continue
data.append(table)
if -1 == ncol:
ncol = len(table)
elif ncol != len(table):
sys.stderr.write("Error: table was misformatted\n")
sys.exit(1)
fh.close()
# re-arrange the data
self.matrix = [[data[i][j] for j in xrange(ncol)] for i in xrange(len(data))]
# NB: assumes sorted descending
def __parse(self, line):
tokens = re.findall(r'[\w+-.]+', line)
for i in range(0, 13):
tokens[i] = int(tokens[i])
for i in range(13, len(tokens)):
tokens[i] = float(tokens[i])
return tokens
def main(options):
fmts = ['-', '--', '-.', ':', '.']
if None == options.fns or 0 == len(options.fns):
return
# read in through the files
fmts_i = 0
for fn in options.fns:
table = Table(fn, options.min_mapq)
# extract sensitivity
x = [table.matrix[i][17] for i in range(len(table.matrix))]
# extract specificity
y = [table.matrix[i][16] for i in range(len(table.matrix))]
pylab.plot(x, y, fmts[fmts_i])
fmts_i = fmts_i + 1
if len(fmts) <= fmts_i:
fmts_i = 0
# plot values
pylab.title('DWGSIM ROC')
pylab.xlabel('specificity')
pylab.ylabel('sensitivity')
# xlim
if None != options.xlim:
nums = re.findall(r'\d+\.?\d*', options.xlim)
if 2 == len(nums):
pylab.xlim(xmin=float(nums[0]), xmax=float(nums[1]))
# ylim
if None != options.ylim:
nums = re.findall(r'\d+\.?\d*', options.ylim)
if 2 == len(nums):
pylab.ylim(ymin=float(nums[0]), ymax=float(nums[1]))
# legend
if not options.no_legend:
if None != options.ids and len(options.fns) == len(options.ids):
pylab.legend(options.ids, title='IDs', loc='lower left')
elif options.infer_ids:
ids = list()
for fn in options.fns:
i = re.sub(r'^.*\/', '', fn)
i = re.sub(r'\.sam\.txt$', '', i)
i = re.sub(r'^out', '', i)
i = re.sub(r'^dwgsim_eval', '', i)
i = re.sub(r'^\.', '', i)
ids.append(i)
pylab.legend(ids, title='IDs', loc='lower left')
# show the plot
if None == options.out:
pylab.show()
else:
# check if the file extension is present, if not, add it
if len(options.out) <= len(options.outtype) or options.outtype != options.out[len(options.out)-len(options.outtype):]:
pylab.savefig("%s.%s" % (options.out, options.outtype), format=options.outtype)
else:
pylab.savefig(options.out, format=options.outtype)
pylab.close()
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('--fn', help="an output file from dwgsim_eval", action="append", dest="fns")
parser.add_option('--id', help="the corresponding ID to add to the plot legened", action="append", dest="ids")
parser.add_option('--infer-ids', help="infer the ids from the file names", action="store_true", default=True, dest="infer_ids")
parser.add_option('--xlim', help="the x-axis range", dest="xlim")
parser.add_option('--ylim', help="the y-axis range", dest="ylim")
parser.add_option('--out', help="the output file", dest="out")
parser.add_option('--outtype', help="the output file type (ex. pdf, png)", dest="outtype", default="pdf")
parser.add_option('--min-mapq', help="minimum mapping quality (inclusive)", dest="min_mapq", type=int, default=0)
parser.add_option('--no-legend', help="do not add a legend to the plot", dest="no_legend", action="store_true", default=False)
if len(sys.argv[1:]) < 1:
parser.print_help()
else:
options, args = parser.parse_args()
main(options)
DWGSIM-dwgsim.0.1.14/scripts/dwgsim_mut_to_vcf.pl 0000664 0000000 0000000 00000004640 14265374640 0021642 0 ustar 00root root 0000000 0000000 #!/usr/bin/env perl
use strict;
use warnings;
# TODO:
# getopt
# better messaging
# usage
# pod...
my $fn = shift || die "No input file";
my %to_alt = (
"AR" => "G", "GR" => "A",
"CY" => "T", "TY" => "C",
"CS" => "G", "GS" => "C",
"AW" => "T", "TW" => "A",
"GK" => "T", "TK" => "G",
"AM" => "C", "CM" => "A"
);
open(FH, "$fn") || die "Could not open '$fn' for reading.\n";
print STDOUT "##fileformat=VCFv4.1\n";
print STDOUT "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tSample\n";
my $type = -1; # 1 - SUB, 2 - INS, 3 - DEL
my $prev_name = -1;
my $prev_pos = -1;
my $del_n = 0;
my $del_name = "";
my $del_pos = -1;
my $del_ref = "";
my $del_s = -1;
my $line_n = 0;
while(defined(my $line = )) {
if($line =~ m/^(.+)\t(\d+)\t(.+)\t(.+)\t(\d+)$/) {
$line_n++;
my $name = $1;
my $pos = $2;
my $ref = $3;
my $alt = $4;
my $s = $5;
if($prev_name ne $name) {
if(0 < $del_n) {
printf(STDOUT "%s\t%d\t.\t%s\t.\t100\tPASS\tpl=%d\n",
$del_name, $del_pos, $del_ref, $del_s);
}
# reset
$prev_pos = -1; $del_n = 0; $del_s = -1;
$del_name = ""; $del_pos = -1; $del_ref = "";
}
if("-" eq $alt) { # DEL
if(0 < $del_n && $del_pos + $del_n == $pos && $s == $del_s) {
$del_n++;
$del_ref .= $ref;
}
else {
if(0 < $del_n) {
printf(STDOUT "%s\t%d\t.\t%s\t.\t100\tPASS\tpl=%d\n",
$del_name, $del_pos, $del_ref, $del_s);
}
$del_n = 1;
$del_name = $name;
$del_pos = $pos;
$del_ref = $ref;
$del_s = $s;
}
}
else {
# print deletion, if it exists
if(0 < $del_n) {
printf(STDOUT "%s\t%d\t.\t%s\t.\t100\tPASS\tpl=%d\n",
$del_name, $del_pos, $del_ref, $s);
# reset
$prev_pos = -1; $del_n = 0; $del_s = -1;
$del_name = ""; $del_pos = -1; $del_ref = "";
}
if("-" eq $ref) { # INS
printf(STDOUT "%s\t%d\t.\t.\t%s\t100\tPASS\tpl=%d\n",
$name, $pos, $alt, $s);
}
else { # SUB
if(3 != $s) {
if(!defined($to_alt{"$ref"."$alt"})) {
die "Could not convert $ref$alt"." on $line_n.\n";
}
$alt = $to_alt{"$ref"."$alt"};
}
printf(STDOUT "%s\t%d\t.\t%s\t%s\t100\tPASS\tpl=%d\n",
$name, $pos, $ref, $alt, $s);
}
}
$prev_name = $name;
$prev_pos = $pos;
}
else {
die "Input file is not in the proper format.\n";
}
}
# print deletion, if it exists
if(0 < $del_n) {
printf(STDOUT "%s\t%d\t.\t%s\t.\t100\tPASS\tpl=%d\n",
$del_name, $del_pos, $del_ref, $del_s);
}
close(FH);
DWGSIM-dwgsim.0.1.14/scripts/dwgsim_pileup_eval.pl 0000664 0000000 0000000 00000012571 14265374640 0022004 0 ustar 00root root 0000000 0000000 #!/usr/bin/env perl -w
# Copied from SAMtools (http://samtools.sourceforge.net)
# This perl code is very cryptic. Evaluates the fraction
# of reads correctly aligned at various mapping quality
# thresholds.
use strict;
use warnings;
use Getopt::Std;
select STDERR; $| = 1; # make STDERR unbuffered
&dwgsim_eval;
exit;
sub dwgsim_eval {
my %opts = (g=>5, n=>0);
getopts('bpc:gn:', \%opts);
print_usage() if (@ARGV == 0 && -t STDIN);
my ($flag, $m, $ctr) = (0, 0, 0);
my $gap = $opts{g};
my $bwa = (defined $opts{b}) ? 1 : 0;
$flag |= 1 if (defined $opts{p});
$flag |= 2 if (defined $opts{c});
my $n = 2*$opts{n};
my @a = ();
my $prev_read_name = "ZZZ";
my @reads = ();
my ($found_correct_1, $found_correct_2, $is_correct_1, $is_correct_2, $found_pair_correct, $is_pair_correct) = (0, 0, 0, 0, 0, 0);
print STDERR "Analyzing...\nCurrently on:\n0";
while (<>) {
$ctr++;
if(0 == ($ctr % 10000)) {
print STDERR "\r$ctr";
}
next if (/^\@/);
my @t = split("\t");
next if (@t < 11);
my $sam = $_;
my $cur_read_name = $t[0];
if($prev_read_name ne $cur_read_name) { # process the read(s)
die unless (0 == length($prev_read_name) || 0 < scalar(@reads));
# go through each end
# want to know
# - is the correct location represented in each end?
# - if so, does the correct location have the best alignment score?
# - what's the combined alignment score of the best pair?
@a = process_reads(\@reads, $flag, $gap, $bwa);
$found_correct_1 += $a[0];
$found_correct_2 += $a[1];
$is_correct_1 += $a[2];
$is_correct_2 += $a[3];
$found_pair_correct += $a[4];
$is_pair_correct += $a[5];
$prev_read_name = $cur_read_name;
@reads = ();
$m++;
}
# store the read
push(@reads, $sam);
#print STDERR $line if (($flag&1) && !$is_correct && $q > 0);
}
@a = process_reads(\@reads, $flag, $gap, $bwa);
$found_correct_1 += $a[0];
$found_correct_2 += $a[1];
$is_correct_1 += $a[2];
$is_correct_2 += $a[3];
$found_pair_correct += $a[4];
$is_pair_correct += $a[5];
print STDERR "\r$ctr\n";
printf(STDERR "%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
$m, $found_correct_1, $found_correct_2,
$is_correct_1, $is_correct_2,
$found_pair_correct,
$is_pair_correct);
print STDERR "Analysis complete.\n";
}
sub print_usage {
print STDERR "Usage: dwgsim_eval.pl [-pcnd] [-g GAP] \n";
print STDERR "\t\t-p\t\tprint incorrect alignments\n";
print STDERR "\t\t-c\t\tcolor space alignments\n";
print STDERR "\t\t-n\tINT\tnumber of raw input paired-end reads\n";
print STDERR "\t\t-d\tINT\tdivide quality by this factor\n";
print STDERR "\t\t-i\t\tprint only alignments with indels\n";
print STDERR "\t\t-b\t\talignments are from BWA\n";
exit(1);
}
sub swap {
my ($a, $b) = @_;
return ($b, $a);
}
sub process_reads {
my ($reads, $flag, $gap, $bwa) = @_;
my ($found_correct_1, $found_correct_2, $is_correct_1, $is_correct_2, $found_pair_correct, $is_pair_correct) = (0, 0, 0, 0, 0, 0);
my ($correct_index_1, $correct_index_2, $max_AS_index_1, $max_AS_index_2, $max_AS_1, $max_AS_2) = (-1, -1, -1, -1, -1000000, -1000000);
# go through reads
for(my $i=0;$i[$i];
my @t = split(/\t/, $line);
die if (@t < 11);
my ($q, $chr, $left, $rght) = ($t[4], $t[2], $t[3], $t[3]);
# right coordinate
$_ = $t[5]; s/(\d+)[MDN]/$rght+=$1,'x'/eg;
--$rght;
# skip unmapped reads
next if (($t[1]&0x4) || $chr eq '*');
# parse read name
if($t[0] =~ m/^(\S+)_(\d+)_(\d+)_(\d)_(\d)_(\d+):(\d+):(\d+)_(\d+):(\d+):(\d+)_(\S+)/) {
my ($o_chr, $pos_1, $pos_2, $str_1, $str_2) = ($1, $2, $3, $4, $5);
my ($n_err_1, $n_sub_1, $n_indel_1, $n_err_2, $n_sub_2, $n_indel_2) = ($6, $7, $8, $9, $10, $11);
my $end = 2;
if(($t[1]&0x40)) { # read #1
$end = 1;
}
# check alignment score
for(my $j=11;$j