Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging to stdout and better errors #186

Merged
merged 10 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### `Added`

- [#180](https://github.com/nf-core/epitopeprediction/pull/180) - Add support for `VEP` annotated VCF files [#172](https://github.com/nf-core/epitopeprediction/issues/172)
- [#186](https://github.com/nf-core/epitopeprediction/pull/186) - Log messages from `epaa.py` script to stdout and provide `sys.exit` error messages.

### `Changed`

Expand Down
21 changes: 17 additions & 4 deletions bin/epaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@
# instantiate global logger object
logger = logging.getLogger(__name__)
# turn off passing of messages to root logger
logger.propagate = False
# logger.propagate = False
logger.setLevel(logging.DEBUG)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)

ID_SYSTEM_USED = EIdentifierTypes.ENSEMBL
transcriptProteinMap = {}
transcriptSwissProtMap = {}
Expand Down Expand Up @@ -498,7 +504,7 @@ def read_vcf(filename, pass_only=True):
list_vars.append(var)
else:
logger.error("No supported variant annotation string found. Aborting.")
sys.exit(1)
sys.exit("No supported variant annotation string found. Input VCFs require annotation with SNPEff or VEP prior to running the epitope prediction pipeline.")
transToVar = {}

# fix because of memory/timing issues due to combinatorial explosion
Expand Down Expand Up @@ -1294,9 +1300,14 @@ def __main__():

if len(sys.argv) <= 1:
parser.print_help()
sys.exit(1)
sys.exit("Provide at least one argument to epaa.py.")

filehandler = logging.FileHandler("{}_prediction.log".format(args.identifier))
filehandler.setLevel(logging.DEBUG)
filehandler.setFormatter(formatter)
logger.addHandler(filehandler)

logger.addHandler(logging.FileHandler("{}_prediction.log".format(args.identifier)))
logger.info("Running Epitope Prediction And Annotation version: " + str(VERSION))
logger.info("Starting predictions at " + str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))

metadata = []
Expand All @@ -1308,9 +1319,11 @@ def __main__():

# read in variants or peptides
if args.peptides:
logger.info("Running epaa for peptides...")
peptides, metadata = read_peptide_input(args.peptides)
else:
if args.somatic_mutations.endswith(".GSvar") or args.somatic_mutations.endswith(".tsv"):
logger.info("Running epaa for variants...")
variant_list, transcripts, metadata = read_GSvar(args.somatic_mutations)
elif args.somatic_mutations.endswith(".vcf"):
variant_list, transcripts, metadata = read_vcf(args.somatic_mutations)
Expand Down
4 changes: 2 additions & 2 deletions modules/local/epytope_peptide_prediction.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ process EPYTOPE_PEPTIDE_PREDICTION {

output:
tuple val(meta), path("*.json"), emit: json
tuple val(meta), path("*.tsv"), optional: true, emit: predicted
tuple val(meta), path("*.fasta"), optional: true, emit: fasta
tuple val(meta), path("*.tsv"), emit: predicted, optional: true
tuple val(meta), path("*.fasta"), emit: fasta, optional: true
path "versions.yml", emit: versions

script:
Expand Down