pax_global_header 0000666 0000000 0000000 00000000064 13122167073 0014514 g ustar 00root root 0000000 0000000 52 comment=29e53dc8730dd798b927cee500005ce996de3be1
seer-1.1.4/ 0000775 0000000 0000000 00000000000 13122167073 0012455 5 ustar 00root root 0000000 0000000 seer-1.1.4/.gitignore 0000664 0000000 0000000 00000000575 13122167073 0014454 0 ustar 00root root 0000000 0000000 # Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
seer
kmds
map_back
combineKmers
filter_seer
# Editors
.vimrc
.lvimrc
.ycm_extra_conf.py*
# Submodules
armadillo-*
mlpack-1.0.*
boost_1_*
seer-1.1.4/.gitmodules 0000664 0000000 0000000 00000000233 13122167073 0014630 0 ustar 00root root 0000000 0000000 [submodule "dlib"]
path = dlib
url = https://github.com/davisking/dlib
[submodule "gzstream"]
path = gzstream
url = https://github.com/kanedo/gzstream
seer-1.1.4/.travis.yml 0000664 0000000 0000000 00000001612 13122167073 0014566 0 ustar 00root root 0000000 0000000 sudo: required
language: cpp
before_install:
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo apt-get update -qq
- sudo apt-get install g++-4.9 liblapack-dev libboost-program-options-dev -y
install:
- wget http://www.cs.unc.edu/Research/compgeom/gzstream/gzstream.tgz
- tar xzf gzstream.tgz
- pushd gzstream && make && popd
- wget https://www.dropbox.com/s/n0zxh86y5nk65km/armadillo-6.100.1.tar.gz?dl=0
- mv 'armadillo-6.100.1.tar.gz?dl=0' armadillo-6.100.1.tar.gz && tar xf armadillo-6.100.1.tar.gz
- pushd armadillo-6.100.1 && CXX=/usr/bin/g++-4.9 cmake . && make && sudo make install && popd
script: CXX=/usr/bin/g++-4.9 make CPPFLAGS="-I../gzstream -I../dlib -D DLIB_NO_GUI_SUPPORT=1 -D DLIB_USE_BLAS=1 -D DLIB_USE_LAPACK=1 -D NO_HDF5=1" SEER_LDLIBS="-L../gzstream -lgzstream -lz -larmadillo -lboost_program_options -llapack -lblas -lpthread" && make test
seer-1.1.4/LICENSE 0000664 0000000 0000000 00000043153 13122167073 0013470 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.
{description}
Copyright (C) {year} {fullname}
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.
{signature of Ty Coon}, 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.
seer-1.1.4/Makefile 0000775 0000000 0000000 00000000401 13122167073 0014113 0 ustar 00root root 0000000 0000000 export PREFIX=${HOME}/software
export BINDIR=$(PREFIX)/bin
all:
cd src && $(MAKE) all
clean:
cd src && $(MAKE) clean
cd test && $(MAKE) clean
install: all
cd src && $(MAKE) install
test: all
cd test && $(MAKE) test
.PHONY: all clean install test
seer-1.1.4/README.md 0000664 0000000 0000000 00000010552 13122167073 0013737 0 ustar 00root root 0000000 0000000 [](https://travis-ci.org/johnlees/seer)
# seer
Sequence element enrichment analysis. This document contains
installation instuctions. Usage can be found on the [wiki](https://github.com/johnlees/seer/wiki/Usage), and more information in the [paper](http://www.nature.com/articles/ncomms12797).
## Installation
### Use a pre-compiled release
Head to the [release](https://github.com/johnlees/seer/releases) page and download and unpack the tarball. If you have the dependencies installed use the dynamic version, otherwise use the static version (tested on Ubuntu only; static_all should work on other 64-bit Linux platforms).
### Use on a virtual machine
We have a virtual machine, containing SEER and other useful bioinformatics programs, which is available at
ftp://ftp.sanger.ac.uk/pub/pathogens/pathogens-vm/pathogens-vm.latest.ova
and can be imported as an appliance in [VirtualBox](https://www.virtualbox.org/).
### Compile source code
First clone the repository
git clone --recursive https://github.com/johnlees/seer
If you already have dlib:
git clone https://github.com/johnlees/seer
Currently tested on Linux only, installation should proceed as
make
make install
Full installation instructions are available below
## Dependencies
seer currently depends on
- gzstream
- armadillo
- boost
- dlib
- HDF5
You will also require
- gcc >4.9 or equivalent
- gcc libstdc++ >4.9
You probably already have boost, HDF5 and dlib (as long as you did clone --recursive).
### Installation on Ubuntu/biolinux
Running the following commands will install seer
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9 libhdf5-dev libopenblas-dev libboost-program-options-dev
git clone --recursive https://github.com/johnlees/seer
cd seer
wget http://www.cs.unc.edu/Research/compgeom/gzstream/gzstream.tgz
tar xzf gzstream.tgz
cd gzstream &&make CC=/usr/bin/gcc-4.9
cd ..
wget http://sourceforge.net/projects/arma/files/armadillo-6.700.6.tar.gz
tar xzf armadillo-6.700.6.tar.gz
cd armadillo-6.700.6
CXX=/usr/bin/g++-4.9 cmake .
make
sudo make install
sudo ldconfig /usr/lib64
cd ..
cd src && make CXX=/usr/bin/g++-4.9
If you are having trouble finding hdf5 (e.g. on Ubuntu 16.04) try
running:
make CPPFLAGS="-I../gzstream -I../dlib -I/usr/include/hdf5/serial -D DLIB_NO_GUI_SUPPORT=1 -D DLIB_USE_BLAS=1 -D DLIB_USE_LAPACK=1"
### General installation instructions
**gzstream**
Download and unpack to a folder gzstream in the root of the repository. Change into the directory and type
make
**HDF5**
Best installed with your distribution's package manager. Otherwise use
a binary from , or
if you wish to compile from source
gunzip < hdf5-X.Y.Z.tar.gz | tar xf -
cd hdf5-X.Y.Z
./configure --prefix=/usr/local/hdf5
make
make check
make install
make check-install
**armadillo**
Make sure HDF5 is installed first.
Download and unpack. Change into directory and type
cmake -DARMA_USE_HDF5=1 .
make
make install
**boost**
Best installed with your distribution's package manager, and you should use the c++11 version if possible.
For a manual installation, see for details on how to use ./b2 to install. I recommend that you create a user-config.jam file in the boost root which modifies the gcc compilation:
using gcc:
: std11
: g++
: -std=c++11
Then run
./bootstrap.sh
./b2 install toolset=gcc-std11
**dlib**
If not installed use the above git clone command to include with the
repository. Otherwise unpack header files to $(PREFIX)/include
**installation**
Currently tested on Linux only, installation should proceed as
make
make install
You may need to explicitly set the current GCC compiler, which you can
do by running
make CXX=g++-4.9
## Usage, interpretation of results, and troubleshooting
See the [wiki](https://github.com/johnlees/seer/wiki/Usage)
seer-1.1.4/dlib/ 0000775 0000000 0000000 00000000000 13122167073 0013367 5 ustar 00root root 0000000 0000000 seer-1.1.4/example_wrapper.py 0000775 0000000 0000000 00000014616 13122167073 0016235 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
#
# This is an example of a wrapper script for the whole seer analysis pipeline,
# based on having a cluster with LSF
#
# imports
import os,sys
from __future__ import print_function
import re
import argparse
import subprocess
# globals
subsampled_list = "kmds_tmp_files.txt"
job_num = re.compile('^Job <(\d+)>')
# subroutines
# Checks, for a list of job numbers, whether they are all done (or failed)
def check_done(jobs):
done = 1
for job in jobs:
bsub_ret = subprocess.check_call("bjobs -a -noheader -o \"stat exit_code delimiter=','\" " + str(job), shell=True)
status = bsub_ret.split(",")
if bsub_ret[1] == "RUN" | bsub_ret[1] == "PEND" | bsub_ret[1] == "WAIT":
done = 0
break
return done
# Command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("infile", help="A file containing a list of dsm output files")
parser.add_argument("pheno", help=".pheno file containing metadata")
parser.add_argument("-o", "--out_prefix", help="Prefix for output files",default="seer")
parser.add_argument("-t", "--threads", help="Threads to use",type=int,default=4)
parser.add_argument("--LSF", help="Submit over LSF",action="store_true",default=False)
parser.add_argument("--pcs", help="Number of principal coordinates to use in population structure",type=int,default=3)
parser.add_argument("--subsample", help="Proportion of total kmers to use in mds calculation",type=float,default=0.001)
parser.add_argument("--maf", help="Minimum minor allele frequency",type=float,default=0.01)
parser.add_argument("--chisq",help="Chi^2 filter cutoff",type=float,default=10e-5)
parser.add_argument("--pval", help="pvalue cutoff",type=float,default=10e-8)
parser.add_argument("--assemble", help="assemble significant kmers, and perform association",action="store_true",default=False)
parser.add_argument("--reference", help="map kmers back to this reference file")
parser.add_argument("--drafts", help="file of annotated draft assemblies to map kmers back to")
args = parser.parse_args()
# Read in dsm files
if not (os.path.isfile(args.infile) & os.path.isfile(args.pheno)):
raise Exception("Mandatory input files do not exist")
with open(args.infile,'r') as f:
dsm_files = f.readlines()
dsm_files = [x.strip('\n') for x in dsm_files]
# Run kmds --no_mds on each file in parallel
# Collect output
print("Filtering " + str(len(dsm_files)) + " files\n")
i = 0
subsampled_output = []
jobs = []
for dsm in dsm_files:
i += 1
length = args.subsample * int(subprocess.check_output("gzip -d -c " + dsm + " | wc -l", shell=True))
try:
kmds_command = ""
if args.LSF:
kmds_command = "bsub -o kmds.step1.%J." + str(i) + ".o -e kmds.step1.%J." + str(i) + ".e "
kmds_command += "kmds -k " + str(dsm) + " -p " + str(args.pheno) + " -o kmds.step1." + str(i) + " --no_mds --maf " + str(args.maf) + " --chisq " + str(args.chi2) + " --size " + str(length)
print(kmds_command)
if args.LSF:
job_return = subprocess.check_output(kmds_command, shell=True)
m = job_num.match(job_return)
jobs.append(m.group())
else:
retcode = subprocess.call(kmds_command, shell=True)
if retcode < 0:
print("kmds step 1 file " + str(i) + " failed with ", -retcode, file=sys.stderr)
subsampled_output.append("kmds.step1." + str(i))
except OSError as e:
print("Execution failed:", e, file=sys.stderr)
# Check all jobs have finished
if args.LSF:
while not (check_done(jobs)):
os.sleep(30)
jobs = []
write_list = open(subsampled_list,'w')
for subsample in subsampled_output:
write_list.write(subsample + "\n")
write_list.close()
# Run kmds --mds_concat on output
print("Calculating MDS components\n")
try:
kmds_command = ""
if args.LSF:
kmds_command = "bsub -o kmds.step2.%J.o -e kmds.step2.%J..e -n" + str(args.threads) + " -R \"span[hosts=1]\" -R \"select[mem>4000] rusage[mem=4000]\" -M4000 "
kmds_command += "kmds --mds_concat " + str(subsampled_list) + " -o all_structure --threads " + str(args.threads) + " --pc " + str(args.pcs)
print(kmds_command)
if args.LSF:
job_return = subprocess.check_output(kmds_command, shell=True)
m = job_num.match(job_return)
jobs.append(m.group())
else:
retcode = subprocess.call(kmds_command, shell=True)
if retcode < 0:
print("kmds step 2 file failed with ", -retcode, file=sys.stderr)
except OSError as e:
print("Execution failed:", e, file=sys.stderr)
if args.LSF:
while not (check_done(jobs)):
os.sleep(30)
jobs = []
# Run seer on each file in parallel
print("Association on " + str(len(dsm_files)) + " files\n")
i = 0
seer_output = []
for dsm in dsm_files:
i += 1
try:
seer_command = ""
if args.LSF:
seer_command = "bsub -o kmds.step1.%J." + str(i) + ".o -e kmds.step1.%J." + str(i) + ".e -n" + str(args.threads) + " -R \"span[hosts=1]\""
seer_command += "'seer -k " + str(dsm) + " -p " + str(args.pheno) + " --no_filtering --pval " + str(args.pval) + " --struct all_structure.dsm --threads " + str(args.threads) + " --print_samples > seer." + str(i) + ".result'"
print(seer_command)
if args.LSF:
job_return = subprocess.check_output(seer_command, shell=True)
m = job_num.match(job_return)
jobs.append(m.group())
else:
retcode = subprocess.call(seer_command, shell=True)
if retcode < 0:
print("seer file " + str(i) + " failed with ", -retcode, file=sys.stderr)
seer_output.append("kmds." + str(i))
except OSError as e:
print("Execution failed:", e, file=sys.stderr)
if args.LSF:
while not (check_done(jobs)):
os.sleep(30)
jobs = []
# TODO post-processing:
subprocess.check_call("cat seer.*.result > seer.result", shell=True)
for i in range(1, len(dsm_files)):
subprocess.check_call("rm seer." + str(i) + ".result", shell=True)
# map back to references
subprocess.call("map_back -k seer.result -r " + args.drafts + " > kmer_draft_locations.txt")
# assembly of significant kmers
if (args.assemble):
subprocess.call("VelvetOptimiser.pl --s 11 --e 71 --t 1 -f '-short -fasta ../../resultErytrhomycin.fa' --m -1 --k max --c tbp")
# use blat by default
# fall back to blast
print("All pans piped\nAssocation results written to seer.result")
seer-1.1.4/gzstream/ 0000775 0000000 0000000 00000000000 13122167073 0014311 5 ustar 00root root 0000000 0000000 seer-1.1.4/scripts/ 0000775 0000000 0000000 00000000000 13122167073 0014144 5 ustar 00root root 0000000 0000000 seer-1.1.4/scripts/R_mds.pl 0000775 0000000 0000000 00000010772 13122167073 0015557 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
use strict;
use warnings;
use Getopt::Long;
my $usage_message = < -p
Projects distance matrix into lower number of dimensions
Requires R and rhdf5 to be installed, see github wiki for more details
NB ensure order in dist matrix and pheno file is the same!
Options
Required
-d, --dist Distance matrix output by kmds/mash
-p, --pheno Phenotype file used by seer
Optional
-o, --output Output prefix (default 'all_structure')
--pc Number of dimensions to project into (default 10)
--no_hdf5 Write output as csv, use if seer compiled with 'NO_HDF5'
-R R executable (default 'which R')
-h, --help Displays this message
USAGE
my $tmp_file_name = "mds_tmp.Rscript";
#****************************************************************************************#
#* Main *#
#****************************************************************************************#
#* gets input parameters
my ($distance_file, $pheno, $output_prefix, $dimensions, ,$no_hdf5, $R_exec, $help);
GetOptions ("dist|d=s" => \$distance_file,
"pheno|p=s" => \$pheno,
"output|o=s" => \$output_prefix,
"no_hdf5" => \$no_hdf5,
"pc=i" => \$dimensions,
"R=s" => \$R_exec,
"help|h" => \$help
) or die($usage_message);
if (defined($help) || !defined($distance_file) || !defined($pheno))
{
print $usage_message;
}
else
{
# Set defaults
if (!defined($dimensions))
{
$dimensions = 10;
}
if (!defined($R_exec))
{
$R_exec = `which R`;
chomp $R_exec;
}
if (!defined($output_prefix))
{
$output_prefix = "all_structure";
}
# Check number of samples matches, write .samples if ok
open(PHENO, $pheno) || die("Could not open pheno file $pheno: $!\n");
my @samples;
while (my $line_in = )
{
chomp $line_in;
my @fields = split(/\t/, $line_in);
push(@samples, $fields[0]);
}
open(DIST, $distance_file) || die("Could not open distance file $distance_file: $!\n");
my $dist_line = ;
my @dist_cols = split(",", $dist_line);
if(scalar(@dist_cols) != scalar(@samples))
{
die("Number of samples in $pheno does not match those in $distance_file\n");
}
my $dist_rows = 1;
while (my $line_in = )
{
$dist_rows++;
}
if($dist_rows != scalar(@dist_cols))
{
die("Distance matrix $distance_file is not square\n");
}
close DIST;
open(SAMPLES, ">$output_prefix.samples") || die("Could not write to $output_prefix.samples\n");
foreach my $sample (@samples)
{
print SAMPLES $sample . "\n";
}
close SAMPLES;
#****************************************************************************************#
#* Rscript *#
#****************************************************************************************#
my $Rscript;
if ($no_hdf5)
{
$Rscript = <$tmp_file_name") || die("Could not open $tmp_file_name: $!\n");
print RSCRIPT $Rscript;
close(RSCRIPT);
print STDERR "Running projection\n";
my $R_command = "$R_exec CMD BATCH --no-save --no-restore $tmp_file_name";
system($R_command);
unlink($tmp_file_name, "$tmp_file_name.Rout");
}
exit(0);
seer-1.1.4/scripts/blast_top_hits.pl 0000775 0000000 0000000 00000007327 13122167073 0017533 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
use strict;
use warnings;
use Getopt::Long;
use Text::CSV;
# Features
# BLAST and BLAT
# Exact/full query matches only
#
my $clean = 0;
my $tmp_sort = "tmp_blat.psl";
my $help_message = <
Reduces a blast or blat output file to the top hit for each query sequence
only
Options
Required
--input BLAST output file in -m 6/-outfmt 6 or BLAT .psl file
--mode Either blast or blat
Optional
--full_query The entire query must be reported as a match to appear
in the output
-h, --help Shows this help.
HELP
#****************************************************************************************#
#* Main *#
#****************************************************************************************#
#* gets input parameters
my ($file_in, $mode, $full_query, $help);
GetOptions( "input|f=s" => \$file_in,
"mode=s" => \$mode,
"full_query" => \$full_query,
"help|h" => \$help
) or die($help_message);
# Basic error check on inputs
if (defined($help))
{
print STDERR $help_message;
}
elsif (!defined($file_in) || !-e $file_in)
{
print STDERR "Input file not found\n";
print STDERR $help_message;
}
elsif (!defined($mode))
{
print STDERR "Operation mode must be either blast or blat\n";
print STDERR $help_message;
}
else
{
my (@columns, $qseqid, $qstart, $qend, $length);
if ($mode =~ /blat/i)
{
# psl format
# match mis- rep. N's Q gap Q gap T gap T gap strand Q Q Q Q T T T T block blockSizes qStarts tStarts
# match match count bases count bases name size start end name size start end count
@columns = qw( match mismatch repmatch Ns Qgapcount Qgapbases Tgapcount Tgapbases strand Qname Qsize Qstart Qend Tname Tsize Tstart Tend blockcount blocksizes qstarts tstarts );
$mode = "blat";
$qseqid = "Qname";
$qstart = "Qstart";
$qend = "Qend";
$length = "match";
# Ensure sorted by query, then match score
system("sort -k10,10 -k1,1nr $file_in > $tmp_sort");
$file_in = $tmp_sort;
$clean = 1;
}
elsif ($mode =~ /blast/i)
{
# blast outfmt 6
#qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore
@columns = qw( qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore );
$mode = "blast";
$qseqid = "qseqid";
$qstart = "qstart";
$qend = "qend";
$length = "length";
}
else
{
die("Operation mode $mode not supported. Use either blast or blat\n");
}
my $csv = Text::CSV->new ( { binary => 1, sep_char => "\t", auto_diag => 1, eol => $/ } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
my %rec;
$csv->bind_columns (\@rec{@columns});
open my $blast_in, "<:encoding(utf8)", "$file_in" or die "$file_in: $!";
my $previous_query = "";
while ($csv->getline($blast_in))
{
# Using speed advice from http://www.perlmonks.org/?node_id=937023
if ($rec{$qseqid} ne $previous_query)
{
if (!$full_query || ((($mode eq "blast" && $rec{$qstart} == 1) || $rec{$qstart} == 0) && $rec{$qend} == $rec{$length}))
{
$csv->print(*STDOUT, [ @rec{@columns} ]);
}
$previous_query = $rec{$qseqid};
}
}
if ($clean)
{
unlink $file_in;
}
}
exit(0);
seer-1.1.4/scripts/blastn_to_phandango.pl 0000775 0000000 0000000 00000004150 13122167073 0020510 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
use strict;
use warnings;
use Getopt::Long;
my $usage_message = < -a > phandango.plot
Creates a plot file for visualisation in phandango
Options
Required
-b, --blast blast results
-a, --assoc fastlmm results
-h, --help Displays this message
USAGE
#****************************************************************************************#
#* Main *#
#****************************************************************************************#
#* gets input parameters
my ($assoc_file, $blast_file, $help);
GetOptions ("assoc|a=s" => \$assoc_file,
"blast|b=s" => \$blast_file,
"help|h" => \$help
) or die($usage_message);
if (defined($help) || !defined($assoc_file) || !defined($blast_file))
{
print $usage_message;
}
else
{
open(ASSOC, $assoc_file) || die("Could not open assoc file $assoc_file: $!\n");
my @pvals;
while (my $assoc_line = )
{
chomp $assoc_line;
my (@assoc_fields) = split("\t", $assoc_line);
push(@pvals, -log($assoc_fields[5])/log(10));
}
close ASSOC;
open(BLAST, $blast_file) || die("Could not open blast file $blast_file: $!\n");
my %points;
while (my $blast_line = )
{
chomp $blast_line;
my (@blast_fields) = split("\t", $blast_line);
# Get position, check for reverse complement
my $start = $blast_fields[8];
my $end = $blast_fields[9];
if ($start > $end)
{
my $tmp = $start;
$start = $end;
$end = $tmp;
}
$points{$blast_fields[0]}{pval} = $pvals[$blast_fields[0]-1];
$points{$blast_fields[0]}{start} = $start;
$points{$blast_fields[0]}{pos} = "$start..$end";
}
# Sort and print the output
my @keys = sort { $points{$a}{start} <=> $points{$b}{start} } keys(%points);
foreach my $kmer (@keys)
{
print join("\t", "26", ".", $points{$kmer}{pos}, $points{$kmer}{pval}, "0") . "\n";
}
}
exit(0);
seer-1.1.4/scripts/hits_to_fastq.pl 0000775 0000000 0000000 00000003522 13122167073 0017355 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
use strict;
use warnings;
use Getopt::Long;
my $usage_message = < -b
Creates a fastq for mapping from significant kmers
Options
Required
-k, --kmers Significant kmers, as output by seer
-b, --bonf Bonferroni correction to use (try 10e-8)
Optional
-h, --help Displays this message
USAGE
#****************************************************************************************#
#* Main *#
#****************************************************************************************#
#* gets input parameters
my ($kmer_file, $bonf, $help);
GetOptions ("kmers|k=s" => \$kmer_file,
"bonf|b=s" => \$bonf,
"help|h" => \$help
) or die($usage_message);
if (defined($help) || !defined($kmer_file) || !defined($bonf))
{
print $usage_message;
}
else
{
open(KMERS, $kmer_file) || die("Could not open kmer file: $kmer_file\n");
my $header = ;
my $i = 1;
while (my $line_in = )
{
chomp $line_in;
my ($kmer, $maf, $p_unadj, $p_adj, @junk) = split("\t", $line_in);
my $corrected_p = $p_adj / $bonf;
if ($corrected_p > 1)
{
$corrected_p = 1;
}
my $ascii_val;
if ($corrected_p == 0)
{
$ascii_val = 126;
}
else
{
$ascii_val = int(-10*log($corrected_p)/log(10)) + 33;
if ($ascii_val < 33)
{
$ascii_val = 33;
}
elsif ($ascii_val > 126)
{
$ascii_val = 126;
}
}
my $qual = chr($ascii_val) x length($kmer);
print join("\n", "\@$i", $kmer, "+", $qual) . "\n";
$i++;
}
close KMERS
}
exit(0);
seer-1.1.4/scripts/mapping_to_phandango.pl 0000775 0000000 0000000 00000006205 13122167073 0020663 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
use strict;
use warnings;
use Getopt::Long;
my $usage_message = < -k > phandango.plot
Creates a plot file for visualisation in phandango
Options
Required
-s, --sam Sam file of kmers mapped to reference (unsorted)
-k, --kmers Kmers that were mapped
Optional
-m, --map Minimum mapping quality
--print_kmer Also print k-mer sequence in output
-h, --help Displays this message
USAGE
#****************************************************************************************#
#* Main *#
#****************************************************************************************#
#* gets input parameters
my ($kmer_file, $print_kmer, $sam_file, $min_qual, $help);
GetOptions ("kmers|k=s" => \$kmer_file,
"print_kmer" => \$print_kmer,
"sam|s=s" => \$sam_file,
"map|m=s" => \$min_qual,
"help|h" => \$help
) or die($usage_message);
if (defined($help) || !defined($kmer_file) || !defined($sam_file))
{
print $usage_message;
}
else
{
if (!defined($min_qual))
{
$min_qual = 0;
}
open(SAM, $sam_file) || die("Could not open sam file $sam_file: $!\n");
open(KMERS, $kmer_file) || die("Could not open kmer file $kmer_file: $!\n");
my $header = ;
my @header_fields = split("\t", $header);
my $lrt = 0;
if ($header_fields[4] eq "lrt_p_val")
{
$lrt = 1;
}
my %points;
while (my $sam_line = )
{
chomp $sam_line;
if ($sam_line !~ /^@/)
{
my ($kmer_id, $flag, $chrom, $pos, $map_qual, $cigar, $mate_chrom, $mate_pos, $insert_size, $sequence, $quality, @optional) = split("\t", $sam_line);
# Get position
my $start = $pos;
my $end = $pos + length($sequence) - 1;
my $kmer = ;
chomp $kmer;
# Don't report unmapped or low quality mapped kmers
if ($map_qual > $min_qual && !($flag & 4))
{
my ($kmer, $maf, $unadj, $adj, @other) = split("\t", $kmer);
if ($lrt)
{
$adj = $other[0];
}
if ($kmer ne $sequence)
{
print STDERR "WARNING: line $kmer_id sequence mismatch. Are input files in same order?\n";
}
my $log_p = 386; # Exponent limit of a double
if ($adj > 0)
{
$log_p = -log($adj)/log(10);
}
$points{$kmer}{pval} = $log_p;
$points{$kmer}{start} = $start;
$points{$kmer}{pos} = "$start..$end";
}
}
}
# Sort and print the output
my @keys = sort { $points{$a}{start} <=> $points{$b}{start} } keys(%points);
foreach my $kmer (@keys)
{
if (defined($print_kmer))
{
print join("\t", "26", $kmer, $points{$kmer}{pos}, $points{$kmer}{pval}, "0") . "\n";
}
else
{
print join("\t", "26", ".", $points{$kmer}{pos}, $points{$kmer}{pval}, "0") . "\n";
}
}
}
exit(0);
seer-1.1.4/scripts/mash2matrix.pl 0000775 0000000 0000000 00000002275 13122167073 0016751 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
use strict;
use warnings;
my $usage_message = < > all_distances.csv
Uses mash (http://mash.readthedocs.io/) to create all pairwise distances
between samples.
NB: the input to mash should be the same order as the .pheno file
generate with:
cut -f 1 metadata.pheno | tr '\n' ' '
Then run
mash sketch -o reference
mash dist reference.msh reference.msh > mash_distances.txt
./mash2matrix.pl mash_distances.txt > all_distances.csv
USAGE
my $dist_file = $ARGV[0];
if (!-e $dist_file)
{
print STDERR $usage_message;
}
else
{
open(INPUT, $dist_file) || die("Could not open $dist_file\n");
my %row_idx;
my @mat_out;
my $i = 0;
while (my $line_in = )
{
chomp $line_in;
my ($el1, $el2, $dist, @junk) = split("\t", $line_in);
if (!defined($row_idx{$el1}))
{
$row_idx{$el1} = $i++;
}
if (!defined($row_idx{$el2}))
{
$row_idx{$el2} = $i++;
}
$mat_out[$row_idx{$el1}][$row_idx{$el2}] = $dist;
}
for (my $i = 0; $i < scalar(@{$mat_out[0]}); $i++)
{
print join(",", @{$mat_out[$i]}) . "\n";
}
}
exit(0);
seer-1.1.4/scripts/reformat_output.pl 0000775 0000000 0000000 00000004373 13122167073 0017752 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
use strict;
use warnings;
use Getopt::Long;
my $usage_message = < -p
Reformats output for easier reading as tsv. Prints to stdout
Options
Required
-k, --kmers Filtered significant kmers, as output by seer + filter_seer
-p, --pheno Phenotype file used by seer
Optional
-h, --help Displays this message
USAGE
#****************************************************************************************#
#* Main *#
#****************************************************************************************#
#* gets input parameters
my ($kmer_file, $pheno, $help);
GetOptions ("kmers|k=s" => \$kmer_file,
"pheno|p=s" => \$pheno,
"help|h" => \$help
) or die($usage_message);
if (defined($help) || !defined($kmer_file) || !defined($pheno))
{
print $usage_message;
}
else
{
# Read possible samples
open(PHENO, $pheno) || die("Could not open pheno file $pheno\n");
my @samples;
while (my $pheno_line = )
{
chomp $pheno_line;
my ($sample, $junk, $pheno) = split("\t", $pheno_line);
push(@samples, $sample);
}
# Keep everything sorted (as depends on kmer counting program used)
@samples = sort @samples;
close PHENO;
# Print header row to stdout
open(KMERS, $kmer_file) || die("Could not open kmer file $kmer_file\n");
print join("\t", "sequence", "maf", "unadj_p_val", "p_val", "beta", "se", "comments", @samples) . "\n";
while (my $kmer_line = )
{
chomp $kmer_line;
my ($sequence, $maf, $unadj, $adj, $beta, $se, $comment, @kmer_samples) = split("\t", $kmer_line);
@kmer_samples = sort @kmer_samples;
print join("\t", $sequence, $maf, $unadj, $adj, $beta, $se, $comment) . "\t";
my $next_sample = shift(@kmer_samples);
foreach my $sample (@samples)
{
print "\t";
if ($sample eq $next_sample)
{
print $sample;
if (scalar(@kmer_samples) != 0)
{
$next_sample = shift(@kmer_samples);
}
}
}
print "\n";
}
close KMERS;
}
seer-1.1.4/seer-logo.png 0000664 0000000 0000000 00000073312 13122167073 0015065 0 ustar 00root root 0000000 0000000 PNG
IHDR } B pHYs tEXtSoftware Adobe ImageReadyqe<