diff --git a/gtf2bed/Haskell/LICENSE b/gtf2bed/Haskell/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..65927ec5f09261ae291beb77d4a3138c483899f4 --- /dev/null +++ b/gtf2bed/Haskell/LICENSE @@ -0,0 +1,30 @@ +Copyright Blaise Li (c) 2016 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Blaise Li nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/gtf2bed/Haskell/README.md b/gtf2bed/Haskell/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c1357e68094802d069d57696b6fd8a2fc7b8c05b --- /dev/null +++ b/gtf2bed/Haskell/README.md @@ -0,0 +1,16 @@ +Goal +==== + +This program converts text passed to its standard input to bed format, using +the `gene_id` annotation to make the 4th column. + +Example usage +============= + + gft2bed < genes.gtf > genes.bed + +Compiling +========= + +This program needs to be compiled and installed using the stack Haskell package +manager. See the `install.sh` script. diff --git a/gtf2bed/Haskell/Setup.hs b/gtf2bed/Haskell/Setup.hs new file mode 100644 index 0000000000000000000000000000000000000000..9a994af677b0dfd41b4e3b76b3e7e604003d64e1 --- /dev/null +++ b/gtf2bed/Haskell/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/gtf2bed/Haskell/gtf2bed.cabal b/gtf2bed/Haskell/gtf2bed.cabal new file mode 100644 index 0000000000000000000000000000000000000000..50a4b16ee3c1b48d3d89ce2a7c070ceb37438a08 --- /dev/null +++ b/gtf2bed/Haskell/gtf2bed.cabal @@ -0,0 +1,19 @@ +name: gtf2bed +version: 0.1.0.0 +synopsis: Program that converts gtf into bed +description: Please see README.md +homepage: https://gitlab.pasteur.fr/bli/bioinfo_utils/blob/master/README.md +license: BSD3 +license-file: LICENSE +author: Blaise Li +maintainer: blaise.li@normalesup.org +copyright: (CC-BY-SA) Blaise Li +category: Bioinformatics +build-type: Simple +cabal-version: >=1.10 + +executable gtf2bed + hs-source-dirs: src + main-is: Main.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5, bytestring diff --git a/gtf2bed/Haskell/install.sh b/gtf2bed/Haskell/install.sh new file mode 100755 index 0000000000000000000000000000000000000000..1eb18fd0c59c43869db07f28e72a639f9b556e0d --- /dev/null +++ b/gtf2bed/Haskell/install.sh @@ -0,0 +1,78 @@ +#!/bin/bash -l + +# http://linuxcommand.org/wss0150.php +PROGNAME=$(basename $0) + +function error_exit +{ +# ---------------------------------------------------------------- +# Function for exit due to fatal program error +# Accepts 1 argument: +# string containing descriptive error message +# ---------------------------------------------------------------- + echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2 + exit 1 +} + +function try_load_gmp_module +{ + (module --version 2> /dev/null && module load gmp) || : +} + +if [ $(id -u) = 0 ] +then + # We don't want things to be installed in root's home directory. + install="install --local-bin-path /usr/local/bin" +else + install="install" +fi + +config_file="${HOME}/.stack/config.yaml" + +stack --version 2> /dev/null \ + || (echo "loading stack" && module load stack/1.4.0) + +if [ "${config_file}" ] +then + stack exec -- ghc --version > /dev/null \ + || (try_load_gmp_module \ + && stack setup \ + && INCLUDE_PATH=$(echo ${CMAKE_INCLUDE_PATH} | tr ":" ",") \ + && LIBRARY_PATH=$(echo ${CMAKE_LIBRARY_PATH} | tr ":" ",") \ + && include_config="extra-include-dirs: [${INCLUDE_PATH}]" \ + && libdir_config="extra-lib-dirs: [${LIBRARY_PATH}]" \ + && echo "" >> ${config_file} \ + && echo ${include_config} >> ${config_file} \ + && echo ${libdir_config} >> ${config_file}) \ + || error_exit "stack setup failed" + make_stack_options () { + stack_options="" + } +else + stack exec -- ghc --version > /dev/null \ + || (try_load_gmp_module && stack setup) \ + || error_exit "stack setup failed" + # https://unix.stackexchange.com/a/60690/55127 + # Delay variable evaluation in order to adapt to loaded libraries + make_stack_options () { + INCLUDE_PATH=$(echo ${CMAKE_INCLUDE_PATH} | tr ":" ",") \ + LIBRARY_PATH=$(echo ${CMAKE_LIBRARY_PATH} | tr ":" ",") \ + stack_options="--extra-include-dirs=${INCLUDE_PATH} --extra-lib-dirs=${LIBRARY_PATH}" + } +fi + +# cd ${HOME} to ignore local project stack config +hlint --version 2> /dev/null \ + || (try_load_gmp_module && (cd ${HOME} && make_stack_options && stack ${stack_options} ${install} hlint)) \ + || error_exit "hlint install failed" +scan --version 2> /dev/null \ + || (try_load_gmp_module && (cd ${HOME} && make_stack_options && stack ${stack_options} ${install} scan)) \ + || error_exit "scan install failed" +doctest --version 2> /dev/null \ + || (try_load_gmp_module && (cd ${HOME} && make_stack_options && stack ${stack_options} ${install} doctest)) \ + || error_exit "doctest install failed" + +make_stack_options +stack ${stack_options} build --exec "hlint src/Main.hs" --exec "scan -j False src/Main.hs" --exec "doctest src/Main.hs" + +stack ${install} diff --git a/gtf2bed/ensembl_gtf2bed.hs b/gtf2bed/Haskell/src/Main.hs similarity index 100% rename from gtf2bed/ensembl_gtf2bed.hs rename to gtf2bed/Haskell/src/Main.hs diff --git a/gtf2bed/Haskell/stack.yaml b/gtf2bed/Haskell/stack.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4410f30a9012a8f6a32a97e08dff95dd889960b8 --- /dev/null +++ b/gtf2bed/Haskell/stack.yaml @@ -0,0 +1,71 @@ +# This file was automatically generated by 'stack init' +# +# Some commonly used options have been documented as comments in this file. +# For advanced use and comprehensive documentation of the format, please see: +# http://docs.haskellstack.org/en/stable/yaml_configuration/ + +# Resolver to choose a 'specific' stackage snapshot or a compiler version. +# A snapshot resolver dictates the compiler version and the set of packages +# to be used for project dependencies. For example: +# +# resolver: lts-3.5 +# resolver: nightly-2015-09-21 +# resolver: ghc-7.10.2 +# resolver: ghcjs-0.1.0_ghc-7.10.2 +# resolver: +# name: custom-snapshot +# location: "./custom-snapshot.yaml" +#resolver: lts-7.1 +resolver: lts-8.23 + +# User packages to be built. +# Various formats can be used as shown in the example below. +# +# packages: +# - some-directory +# - https://example.com/foo/bar/baz-0.0.2.tar.gz +# - location: +# git: https://github.com/commercialhaskell/stack.git +# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a +# extra-dep: true +# subdirs: +# - auto-update +# - wai +# +# A package marked 'extra-dep: true' will only be built if demanded by a +# non-dependency (i.e. a user package), and its test suites and benchmarks +# will not be run. This is useful for tweaking upstream packages. +packages: +- '.' +# Dependency packages to be pulled from upstream that are not in the resolver +# (e.g., acme-missiles-0.3) +extra-deps: [] + +# Override default flag values for local packages and extra-deps +flags: {} + +# Extra package databases containing global packages +extra-package-dbs: [] + +# Control whether we use the GHC we find on the path +# system-ghc: true +# +# Require a specific version of stack, using version ranges +# require-stack-version: -any # Default +# require-stack-version: ">=1.2" +# +# Override the architecture used by stack, especially useful on Windows +# arch: i386 +# arch: x86_64 +# +# Extra directories used by stack for building +# extra-include-dirs: [/path/to/dir] +# extra-lib-dirs: [/path/to/dir] +# +# Allow a newer minor version of GHC than the snapshot specifies +# compiler-check: newer-minor +ghc-options: + "*": -O -Wall +rebuild-ghc-options: + true