diff --git a/README.md b/README.md index da3da1d..84a61ad 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ Read our [short SUPPA tutorial on an example dataset](https://github.com/comprna * [Overview](#overview) * [Installation](#installation) + * [From the tar.gz archive](#from-the-targz-archive) + * [Using pip](#using-pip) + * [Using bioconda](#using-bioconda) * [Command and subcommand structure](#command-and-subcommand-structure) * [Generation of transcript events and local alternative splicing events](#generation-of-transcript-events-and-local-alternative-splicing-events) * [Input files](#input-files) @@ -72,10 +75,34 @@ SUPPA has been developed in Python 3.4. If necessary, to install python3 we recommend to download from the official site https://www.python.org/downloads/ the corresponding version for your OS. +## From the tar.gz archive + +Uncompress the archive using: +``` +tar xvzf SUPPA-2.3.tar.gz +cd SUPPA +``` + +As root/administrator, you can install with: +``` +python3 setup.py install +``` +or as a non-privilegied user for a user specific install: +``` +python3 setup.py install --user +``` +in this case, on a unix-like environment, the executable are installed by default in `~/.local/bin`. You can add this path to the shell search path with (Bash shell): + +``` +if ! grep -q 'PATH.*~/\.local/bin' ~/.bashrc ; then echo 'export PATH=$PATH:~/.local/bin' >>~/.bashrc; fi +``` + +## Using pip + A installation using pip is available using the next command: ``` -pip install SUPPA==2.2.1 +pip install SUPPA==2.3 ``` By default SUPPA is installed into the Python package library directory. The following command can be executed to obtain the directory location: @@ -85,6 +112,8 @@ pip show SUPPA SUPPA is ready to use. Once downloaded, it can be used directly from the command line by specifying the absolute path to the SUPPA executable (suppa.py). +## Using bioconda + Another option is via bioconda (thanks to Devon Ryan) ``` @@ -98,7 +127,7 @@ conda install -c bioconda suppa SUPPA works with a command/subcommand structure: ``` -python3.4 suppa.py subcommand options +python3 suppa2.py subcommand options ``` where the subcommand can be one of these five: @@ -165,7 +194,7 @@ The *generateEvents* operation uses the lines where the feature (column 3) is "e To generate the events from the GTF file one has to run the following command: ``` -python3.4 suppa.py generateEvents [options] +python3 suppa2.py generateEvents [options] ``` List of options available: @@ -202,13 +231,13 @@ List of options available: The command line to generate local AS events will be of the form: ``` -python3.4 suppa.py generateEvents -i -o -f ioe -e +python3 suppa2.py generateEvents -i -o -f ioe -e ``` The command to generate the transcript "events" would be of the form: ``` -python3.4 suppa.py generateEvents -i -o -f ioi +python3 suppa2.py generateEvents -i -o -f ioi ``` ## Output files @@ -377,7 +406,7 @@ transcript3 At the moment the PSI per transcript isoform is calculated in the following way: ``` -python3.4 suppa.py psiPerIsoform [options] +python3 suppa2.py psiPerIsoform [options] ``` List of options available: @@ -394,7 +423,7 @@ List of options available: An example of the usage of the program is: ``` -python3.4 suppa.py psiPerIsoform -g -e -o +python3 suppa2.py psiPerIsoform -g -e -o ``` ### **PSI per local event** ### @@ -402,7 +431,7 @@ python3.4 suppa.py psiPerIsoform -g -e -o --expression-file -o +python3 suppa2.py psiPerEvent --ioe-file --expression-file -o ``` ### **Output files** ### @@ -456,7 +485,7 @@ ENSG00000000419.12;SE:chr20:50940933-50941105:50941209-50942031:- 0.023022 Transcript expression files used with SUPPA typically come from calculations with multiple samples. To facilitate the generation of a single file with all the transcript expression values for all samples, SUPPA distribution includes a program to combine multiple simple transcript expression files into one single file: ``` -python3.4 suppa.py joinFiles [options] +python3 suppa2.py joinFiles [options] ``` @@ -474,7 +503,7 @@ where the options are: We show below an example of the usage of the program for reading multiple output files from Sailfish to join together the 3rd column, given that all files have in the first column the transcript ids (which are kept for the output): ``` -python3.4 suppa.py joinFiles -f tpm -i sample1.tpm sample2.tpm sample3.tpm -o all_samples_tpms +python3 suppa2.py joinFiles -f tpm -i sample1.tpm sample2.tpm sample3.tpm -o all_samples_tpms ``` The output will look like an expression file with multiple files as described above. @@ -521,7 +550,7 @@ where the expression values are given in TPM units. ### **Command and options** ### To calculate the dpsi from the *ioe*, *psi* and the *expression file* one has to run the following command: ``` -python3.4 suppa.py diffSplice [options] +python3 suppa2.py diffSplice [options] ``` List of options available: @@ -564,7 +593,7 @@ List of options available: An example of the usage of the program with transcripts is, indicating that replicates are paired (-pa), to apply a multple testing correction (-gc) and perform pairwise comparison between all conditions (-c): ``` -python3.4 suppa.py diffSplice --method --input --psi --expression-file --area <1000> --lower-bound <0.05> -pa -gc -c -o +python3 suppa2.py diffSplice --method --input --psi --expression-file --area <1000> --lower-bound <0.05> -pa -gc -c -o ``` ### **Differential splicing with local events** ### @@ -572,7 +601,7 @@ python3.4 suppa.py diffSplice --method --input --psi --input --psi --expression-file --area <1000> --lower-bound <0.05> -gc -o +python3 suppa2.py diffSplice --method --input --psi --expression-file --area <1000> --lower-bound <0.05> -gc -o ``` ### **Output files** ### @@ -661,7 +690,7 @@ event3 --psivec --sig-threshold <0.05> --eps <0.05> --min-pts <20> --groups <1-3,4-6> -o +python3 suppa2.py clusterEvents --dpsi --psivec --sig-threshold <0.05> --eps <0.05> --min-pts <20> --groups <1-3,4-6> -o ``` diff --git a/__pycache__/eventClusterer.cpython-35.pyc b/__pycache__/eventClusterer.cpython-35.pyc deleted file mode 100644 index cf1db5d..0000000 Binary files a/__pycache__/eventClusterer.cpython-35.pyc and /dev/null differ diff --git a/__pycache__/eventGenerator.cpython-35.pyc b/__pycache__/eventGenerator.cpython-35.pyc deleted file mode 100644 index cf402e8..0000000 Binary files a/__pycache__/eventGenerator.cpython-35.pyc and /dev/null differ diff --git a/__pycache__/fileMerger.cpython-35.pyc b/__pycache__/fileMerger.cpython-35.pyc deleted file mode 100644 index 269e008..0000000 Binary files a/__pycache__/fileMerger.cpython-35.pyc and /dev/null differ diff --git a/__pycache__/psiCalculator.cpython-35.pyc b/__pycache__/psiCalculator.cpython-35.pyc deleted file mode 100644 index b7e35d4..0000000 Binary files a/__pycache__/psiCalculator.cpython-35.pyc and /dev/null differ diff --git a/__pycache__/psiPerGene.cpython-35.pyc b/__pycache__/psiPerGene.cpython-35.pyc deleted file mode 100644 index d926188..0000000 Binary files a/__pycache__/psiPerGene.cpython-35.pyc and /dev/null differ diff --git a/__pycache__/significanceCalculator.cpython-35.pyc b/__pycache__/significanceCalculator.cpython-35.pyc deleted file mode 100644 index 8f490d1..0000000 Binary files a/__pycache__/significanceCalculator.cpython-35.pyc and /dev/null differ diff --git a/lib/__pycache__/__init__.cpython-35.pyc b/lib/__pycache__/__init__.cpython-35.pyc deleted file mode 100644 index ae83a39..0000000 Binary files a/lib/__pycache__/__init__.cpython-35.pyc and /dev/null differ diff --git a/lib/__pycache__/cluster_tools.cpython-35.pyc b/lib/__pycache__/cluster_tools.cpython-35.pyc deleted file mode 100644 index 114eceb..0000000 Binary files a/lib/__pycache__/cluster_tools.cpython-35.pyc and /dev/null differ diff --git a/lib/__pycache__/diff_tools.cpython-35.pyc b/lib/__pycache__/diff_tools.cpython-35.pyc deleted file mode 100644 index ce97843..0000000 Binary files a/lib/__pycache__/diff_tools.cpython-35.pyc and /dev/null differ diff --git a/lib/__pycache__/event.cpython-35.pyc b/lib/__pycache__/event.cpython-35.pyc deleted file mode 100644 index 35432f3..0000000 Binary files a/lib/__pycache__/event.cpython-35.pyc and /dev/null differ diff --git a/lib/__pycache__/gtf_store.cpython-35.pyc b/lib/__pycache__/gtf_store.cpython-35.pyc deleted file mode 100644 index 6e8007d..0000000 Binary files a/lib/__pycache__/gtf_store.cpython-35.pyc and /dev/null differ diff --git a/lib/__pycache__/optics.cpython-35.pyc b/lib/__pycache__/optics.cpython-35.pyc deleted file mode 100644 index 871f6ff..0000000 Binary files a/lib/__pycache__/optics.cpython-35.pyc and /dev/null differ diff --git a/lib/__pycache__/tools.cpython-35.pyc b/lib/__pycache__/tools.cpython-35.pyc deleted file mode 100644 index a6149d9..0000000 Binary files a/lib/__pycache__/tools.cpython-35.pyc and /dev/null differ diff --git a/lib/__pycache__/var_event.cpython-35.pyc b/lib/__pycache__/var_event.cpython-35.pyc deleted file mode 100644 index 8648364..0000000 Binary files a/lib/__pycache__/var_event.cpython-35.pyc and /dev/null differ diff --git a/scripts/Volcano_MA_plot.R b/scripts/suppa2_Volcano_MA_plot.R old mode 100644 new mode 100755 similarity index 99% rename from scripts/Volcano_MA_plot.R rename to scripts/suppa2_Volcano_MA_plot.R index fa564c1..0b2cd0a --- a/scripts/Volcano_MA_plot.R +++ b/scripts/suppa2_Volcano_MA_plot.R @@ -1,3 +1,5 @@ +#! /usr/bin/env Rscript + library(scales) library(ggplot2) library(ggrepel) diff --git a/scripts/format_Ensembl_ids.R b/scripts/suppa2_format_Ensembl_ids.R similarity index 96% rename from scripts/format_Ensembl_ids.R rename to scripts/suppa2_format_Ensembl_ids.R index 25fd16d..a612d22 100755 --- a/scripts/format_Ensembl_ids.R +++ b/scripts/suppa2_format_Ensembl_ids.R @@ -1,4 +1,5 @@ -#!/usr/bin/Rscript +#! /usr/bin/env Rscript + #with this script, running from bash, we want to format the ids fo the Ensembl transcripts for running SUPPA # Parse command line arguments diff --git a/scripts/format_unique_fasta_RefSeq_annotation.py b/scripts/suppa2_format_unique_fasta_RefSeq_annotation.py similarity index 99% rename from scripts/format_unique_fasta_RefSeq_annotation.py rename to scripts/suppa2_format_unique_fasta_RefSeq_annotation.py index d446d6f..1d6befd 100755 --- a/scripts/format_unique_fasta_RefSeq_annotation.py +++ b/scripts/suppa2_format_unique_fasta_RefSeq_annotation.py @@ -1,3 +1,5 @@ +#! /usr/bin/env python3 + """ @authors: Juan L. Trincado @email: juanluis.trincado@upf.edu diff --git a/scripts/generate_boxplot_event.py b/scripts/suppa2_generate_boxplot_event.py old mode 100644 new mode 100755 similarity index 99% rename from scripts/generate_boxplot_event.py rename to scripts/suppa2_generate_boxplot_event.py index 02f05d6..0fda815 --- a/scripts/generate_boxplot_event.py +++ b/scripts/suppa2_generate_boxplot_event.py @@ -1,3 +1,5 @@ +#! /usr/bin/env python3 + # The next script will format a phenotype table (junctions, events, trasncripts...) # for runnning FastQTL analysis @@ -159,4 +161,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/multipleFieldSelection.py b/scripts/suppa2_multipleFieldSelection.py old mode 100644 new mode 100755 similarity index 99% rename from multipleFieldSelection.py rename to scripts/suppa2_multipleFieldSelection.py index b29b958..21436ce --- a/multipleFieldSelection.py +++ b/scripts/suppa2_multipleFieldSelection.py @@ -1,3 +1,5 @@ +#! /usr/bin/env python3 + # -*- coding: utf-8 -*- """ Created on Thu May 22 11:24:33 2014 diff --git a/scripts/split_file.R b/scripts/suppa2_split_file.R similarity index 86% rename from scripts/split_file.R rename to scripts/suppa2_split_file.R index 41bdd1b..ce78e1a 100755 --- a/scripts/split_file.R +++ b/scripts/suppa2_split_file.R @@ -1,4 +1,4 @@ -#!/soft/R/R-3.1.0/bin/Rscript +#! /usr/bin/env Rscript #Given two pairs of lists of samples, split [1] in two files with the samples indicated in [2] and [3] #[1] First argument: input file that we want to split @@ -7,13 +7,17 @@ #[4] Fourth argument: output file of the first condition #[5] Fifth argument: output file of the second condition +## bug in setuptools, this script is recognized as python if not included +## bugs #355, #1178 +data.frame(a="")$a + # Parse command line arguments print("Parsing samples...") CHARACTER_command_args <- commandArgs(trailingOnly=TRUE) #Load the input file print(paste0("Loading ",CHARACTER_command_args[1],"...")) -input_file <- read.table(CHARACTER_command_args[1],header=TRUE) +input_file <- read.table(CHARACTER_command_args[1],row.names=1,header=TRUE, check.names=FALSE) #Load the list of samples of the first condition first_condition <- unlist(strsplit(CHARACTER_command_args[2],",")) diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..a672b7e --- /dev/null +++ b/setup.py @@ -0,0 +1,36 @@ +#! /usr/bin/env python3 + +from setuptools import setup, find_packages + +setup( + name='SUPPA', + packages=find_packages(), + scripts=['suppa2.py', + 'scripts/suppa2_multipleFieldSelection.py', + 'scripts/suppa2_format_Ensembl_ids.R', + 'scripts/suppa2_split_file.R', + 'scripts/suppa2_Volcano_MA_plot.R', + 'scripts/suppa2_generate_boxplot_event.py', + 'scripts/suppa2_format_unique_fasta_RefSeq_annotation.py'], + version='2.3', + description='A tool to study splicing across multiple conditions at high speed and accuracy.', + author='GP Alamancos', + author_email='eduardo.eyras@upf.edu', + license='MIT', + url='https://github.com/comprna/SUPPA', + download_url='https://github.com/comprna/SUPPA/archive/v2.3.tar.gz', + keywords=['alternative', 'splicing', 'analysis', 'transcriptomics'], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Topic :: Scientific/Engineering :: Bio-Informatics', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: MIT License', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3.5'], + install_requires=['scipy>=0.15.1', + 'numpy>=1.11.0', + 'pandas>=0.18.0', + 'statsmodels>=0.6.1', + 'scikit-learn>=0.16.1'], + python_requires='>=3', +) diff --git a/lib/__init__.py b/suppa/__init__.py similarity index 100% rename from lib/__init__.py rename to suppa/__init__.py diff --git a/lib/cluster_tools.py b/suppa/cluster_tools.py similarity index 99% rename from lib/cluster_tools.py rename to suppa/cluster_tools.py index f4d5cf8..5df9960 100644 --- a/lib/cluster_tools.py +++ b/suppa/cluster_tools.py @@ -13,7 +13,7 @@ from sklearn.cluster import DBSCAN from collections import defaultdict from sklearn.metrics import silhouette_score -from lib.optics import * +from .optics import * diff --git a/lib/diff_tools.py b/suppa/diff_tools.py similarity index 100% rename from lib/diff_tools.py rename to suppa/diff_tools.py diff --git a/lib/event.py b/suppa/event.py similarity index 99% rename from lib/event.py rename to suppa/event.py index c70c683..ae23847 100644 --- a/lib/event.py +++ b/suppa/event.py @@ -607,7 +607,7 @@ def process_events(my_gene, event, ioe_writer, gtf_writer, edge_len, th): gtf_writer.write(gtf_line, etype) # to avoid circular dependencies -from lib.var_event import * +from .var_event import * def create_event_classes(all_events, b_type): diff --git a/eventClusterer.py b/suppa/eventClusterer.py similarity index 99% rename from eventClusterer.py rename to suppa/eventClusterer.py index 881ad66..8094cb5 100644 --- a/eventClusterer.py +++ b/suppa/eventClusterer.py @@ -9,7 +9,7 @@ import os import logging -from lib.cluster_tools import cluster_analysis +from .cluster_tools import cluster_analysis from argparse import ArgumentParser, RawTextHelpFormatter diff --git a/eventGenerator.py b/suppa/eventGenerator.py similarity index 98% rename from eventGenerator.py rename to suppa/eventGenerator.py index 9d42b16..19853e8 100644 --- a/eventGenerator.py +++ b/suppa/eventGenerator.py @@ -9,9 +9,9 @@ import sys import logging from argparse import ArgumentParser, RawTextHelpFormatter -from lib.tools import * -from lib.gtf_store import * -from lib.event import * +from .tools import * +from .gtf_store import * +from .event import * # Setting argument parser # parser = argparse.ArgumentParser() diff --git a/fileMerger.py b/suppa/fileMerger.py similarity index 100% rename from fileMerger.py rename to suppa/fileMerger.py diff --git a/lib/gtf_store.py b/suppa/gtf_store.py similarity index 100% rename from lib/gtf_store.py rename to suppa/gtf_store.py diff --git a/lib/optics.py b/suppa/optics.py similarity index 100% rename from lib/optics.py rename to suppa/optics.py diff --git a/psiCalculator.py b/suppa/psiCalculator.py similarity index 98% rename from psiCalculator.py rename to suppa/psiCalculator.py index 996ec9f..54ed758 100644 --- a/psiCalculator.py +++ b/suppa/psiCalculator.py @@ -10,7 +10,7 @@ import logging import numpy as np from argparse import ArgumentParser, RawTextHelpFormatter -from lib.tools import * +from .tools import * description = \ @@ -158,7 +158,7 @@ def main(): writer = Writer.getWriter("PSI") logger.info("Generating output %s" % (output_file + ".psi")) writer.openFile(output_file) - writer.writeLine("\t".join(col_ids), False) + writer.writeLine("\t".join(["Name"] + col_ids), False) for key, value in sorted(psi_dictionary.items()): logger.debug("Calculating psi for %s" % key) psi_line = PsiWriter.lineGenerator(key, value, col_ids) @@ -183,4 +183,4 @@ def main(): logger.info("Done") if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/psiPerGene.py b/suppa/psiPerGene.py similarity index 98% rename from psiPerGene.py rename to suppa/psiPerGene.py index 0019f17..4d2e84c 100644 --- a/psiPerGene.py +++ b/suppa/psiPerGene.py @@ -10,8 +10,8 @@ import sys import logging from argparse import ArgumentParser, RawTextHelpFormatter -from lib.tools import * -from lib.gtf_store import * +from .tools import * +from .gtf_store import * description = \ diff --git a/significanceCalculator.py b/suppa/significanceCalculator.py similarity index 99% rename from significanceCalculator.py rename to suppa/significanceCalculator.py index 0ccb105..9e8e88a 100644 --- a/significanceCalculator.py +++ b/suppa/significanceCalculator.py @@ -12,7 +12,7 @@ import os import logging -from lib.diff_tools import multiple_conditions_analysis +from .diff_tools import multiple_conditions_analysis from argparse import * diff --git a/lib/tools.py b/suppa/tools.py similarity index 99% rename from lib/tools.py rename to suppa/tools.py index 276e5e6..4921465 100644 --- a/lib/tools.py +++ b/suppa/tools.py @@ -9,7 +9,7 @@ import sys import logging from abc import ABCMeta, abstractmethod -from lib.event import * +from .event import * #Setting logging preferences @@ -376,9 +376,9 @@ def readLine(self, header = True): fields = line.rstrip("\n").split("\t") if lineNumber == 0 and header: #Skip the header line #Calculating the number of fields required - min_fields = (len(line.rstrip("\n").split("\t")) + 1) + min_fields = len(fields) #Storing column_id for the expression fields - colIds = fields + colIds = fields[1:] continue if line.startswith('#'): logger.debug("Line %i starts with #. Skipping line..." % ( diff --git a/lib/var_event.py b/suppa/var_event.py similarity index 99% rename from lib/var_event.py rename to suppa/var_event.py index 4da829e..b082068 100644 --- a/lib/var_event.py +++ b/suppa/var_event.py @@ -1,5 +1,5 @@ import itertools -from lib.event import Event +from .event import Event class VariableEvent(Event): diff --git a/suppa.py b/suppa2.py old mode 100644 new mode 100755 similarity index 91% rename from suppa.py rename to suppa2.py index 8fa0bc8..4cc1783 --- a/suppa.py +++ b/suppa2.py @@ -1,102 +1,103 @@ -# -*- coding: utf-8 -*- -""" -Created on Wed Aug 06 17:51:05 2014 - -@author: Gael P Alamancos -@email: gael.perez[at]upf.edu -""" - -import fileMerger as joinFiles -import psiPerGene as psiPerIsoform -import psiCalculator as psiPerEvent -import eventGenerator as generateEvents -import eventClusterer as clusterAnalysis -import significanceCalculator as diffSplice -import logging -import argparse -import sys - - -description = "Description:\n\n" + \ - "SUPPA allows you to generate all the possible Alternative Splicing events from an annotation file, \n" \ - "calculate the PSI values per event, calculate differential splicing across multiple conditions \n" \ - "with replicates, and cluster events across conditions \n" \ - "For further information, see the help of each subcommand." - -parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter, prog='SUPPA') -# Version -parser.add_argument('-v','--version', action='version', version='%(prog)s 2.3') -subparsers = parser.add_subparsers() - -# EventGenerator parser -eventGeneratorSubparser = subparsers.add_parser( - "generateEvents", parents=[generateEvents.parser], - help="Calculates the Alternative Splicing events from an annotation file.") -eventGeneratorSubparser.set_defaults(which="generateEvents") - -# psiCalculator parser -psiCalculatorSubparser = subparsers.add_parser( - "psiPerEvent", parents=[psiPerEvent.parser], - help="Calculates the PSI value for each event previously generated.") -psiCalculatorSubparser.set_defaults(which="psiPerEvent") - -# psiPerGene parser -psiPerGeneSubparser = subparsers.add_parser( - "psiPerIsoform", parents=[psiPerIsoform.parser], - help="Calculates the PSI value for each isoform.") -psiPerGeneSubparser.set_defaults(which="psiPerIsoform") - -# significanceCalculator parser -significanceCalculatorSubparser = subparsers.add_parser( - "diffSplice", parents=[diffSplice.parser], - help="Calculates differentially spliced events across multiple conditions.") -significanceCalculatorSubparser.set_defaults(which="diffSplice") - -# eventClusterer parser -eventClustererSubparser = subparsers.add_parser( - "clusterEvents", parents=[clusterAnalysis.parser], - help="Calculates clusters of events across conditions.") -eventClustererSubparser.set_defaults(which="clusterEvents") - -# fileMerger parser -fileMergerSubparser = subparsers.add_parser( - "joinFiles", parents=[joinFiles.parser], - help="Join multiple tab separated files into a single file.") -fileMergerSubparser.set_defaults(which="joinFiles") - -# Setting logging preferences -logger = logging.getLogger(__name__) - - -def main(): - - if len(sys.argv) == 1: - parser.print_help() - sys.exit(1) - - try: - args = parser.parse_args() - if args.which == "generateEvents": - generateEvents.parser = parser # Setting the module aparser - generateEvents.main() - elif args.which == "psiPerEvent": - psiPerEvent.parser = parser # Setting the module parser - psiPerEvent.main() - elif args.which == "psiPerIsoform": - psiPerIsoform.parser = parser # Setting the module parser - psiPerIsoform.main() - elif args.which == "diffSplice": - diffSplice.parser = parser # Setting the module parser - diffSplice.main() - elif args.which == "clusterEvents": - clusterAnalysis.parser = parser # Setting the module parser - clusterAnalysis.main() - elif args.which == "joinFiles": - joinFiles.parser = parser # Setting the module parser - joinFiles.main() - except Exception: - logger.error("Unknown error: {}".format(sys.exc_info())) - sys.exit(1) - -if __name__ == '__main__': - main() +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Wed Aug 06 17:51:05 2014 + +@author: Gael P Alamancos +@email: gael.perez[at]upf.edu +""" + +import suppa.fileMerger as joinFiles +import suppa.psiPerGene as psiPerIsoform +import suppa.psiCalculator as psiPerEvent +import suppa.eventGenerator as generateEvents +import suppa.eventClusterer as clusterAnalysis +import suppa.significanceCalculator as diffSplice +import logging +import argparse +import sys + + +description = "Description:\n\n" + \ + "SUPPA allows you to generate all the possible Alternative Splicing events from an annotation file, \n" \ + "calculate the PSI values per event, calculate differential splicing across multiple conditions \n" \ + "with replicates, and cluster events across conditions \n" \ + "For further information, see the help of each subcommand." + +parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter, prog='SUPPA') +# Version +parser.add_argument('-v','--version', action='version', version='%(prog)s 2.3') +subparsers = parser.add_subparsers() + +# EventGenerator parser +eventGeneratorSubparser = subparsers.add_parser( + "generateEvents", parents=[generateEvents.parser], + help="Calculates the Alternative Splicing events from an annotation file.") +eventGeneratorSubparser.set_defaults(which="generateEvents") + +# psiCalculator parser +psiCalculatorSubparser = subparsers.add_parser( + "psiPerEvent", parents=[psiPerEvent.parser], + help="Calculates the PSI value for each event previously generated.") +psiCalculatorSubparser.set_defaults(which="psiPerEvent") + +# psiPerGene parser +psiPerGeneSubparser = subparsers.add_parser( + "psiPerIsoform", parents=[psiPerIsoform.parser], + help="Calculates the PSI value for each isoform.") +psiPerGeneSubparser.set_defaults(which="psiPerIsoform") + +# significanceCalculator parser +significanceCalculatorSubparser = subparsers.add_parser( + "diffSplice", parents=[diffSplice.parser], + help="Calculates differentially spliced events across multiple conditions.") +significanceCalculatorSubparser.set_defaults(which="diffSplice") + +# eventClusterer parser +eventClustererSubparser = subparsers.add_parser( + "clusterEvents", parents=[clusterAnalysis.parser], + help="Calculates clusters of events across conditions.") +eventClustererSubparser.set_defaults(which="clusterEvents") + +# fileMerger parser +fileMergerSubparser = subparsers.add_parser( + "joinFiles", parents=[joinFiles.parser], + help="Join multiple tab separated files into a single file.") +fileMergerSubparser.set_defaults(which="joinFiles") + +# Setting logging preferences +logger = logging.getLogger(__name__) + + +def main(): + + if len(sys.argv) == 1: + parser.print_help() + sys.exit(1) + + try: + args = parser.parse_args() + if args.which == "generateEvents": + generateEvents.parser = parser # Setting the module aparser + generateEvents.main() + elif args.which == "psiPerEvent": + psiPerEvent.parser = parser # Setting the module parser + psiPerEvent.main() + elif args.which == "psiPerIsoform": + psiPerIsoform.parser = parser # Setting the module parser + psiPerIsoform.main() + elif args.which == "diffSplice": + diffSplice.parser = parser # Setting the module parser + diffSplice.main() + elif args.which == "clusterEvents": + clusterAnalysis.parser = parser # Setting the module parser + clusterAnalysis.main() + elif args.which == "joinFiles": + joinFiles.parser = parser # Setting the module parser + joinFiles.main() + except Exception: + logger.error("Unknown error: {}".format(sys.exc_info())) + sys.exit(1) + +if __name__ == '__main__': + main()