Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ nextflow run ebi-pf-team/interproscan6 \
-r 6.0.0 \
-profile docker \
-c licensed.conf \
--input /path/to/sequences.faayour.fasta \
--input /path/to/sequences.faa \
--applications deeptmhmm,phobius,signalp_euk,signalp_prok \
--use-gpu
```
Expand Down
82 changes: 76 additions & 6 deletions modules/prosite/patterns/main.nf → modules/pftools/main.nf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import groovy.io.FileType
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import uk.ac.ebi.interpro.Location
import uk.ac.ebi.interpro.Match
import uk.ac.ebi.interpro.Signature
import uk.ac.ebi.interpro.SignatureLibraryRelease

process RUN_PFSCAN {

process RUN_PSSCAN {
/*
The ps_scan.pl script is a wrapper for the pfscan tool that is provided by the
pftools developers. It automates running pfscan for all provided patterns and
Expand Down Expand Up @@ -34,20 +36,20 @@ process RUN_PFSCAN {
}


process PARSE_PFSCAN {
process PARSE_PSSCAN {
label 'mem_low', 'time_veryshort'
executor 'local'

input:
tuple val(meta), val(pfscan_out)
tuple val(meta), val(ps_scan_out)

output:
tuple val(meta), path("prositepatterns.json")
tuple val(meta), path("ps_scan.json")

exec:
Map<String, Map<String, Match>> patternsMatches = [:]
SignatureLibraryRelease library = new SignatureLibraryRelease("PROSITE patterns", null)
pfscan_out.eachLine { line ->
ps_scan_out.eachLine { line ->
line = line.trim()
if (!line || line.startsWith("pfscanV3 is not meant to be used with a single profile")) {
return
Expand Down Expand Up @@ -79,7 +81,75 @@ process PARSE_PFSCAN {
matchObj.addLocation(location)
}

def outputFilePath = task.workDir.resolve("prositepatterns.json")
def outputFilePath = task.workDir.resolve("ps_scan.json")
def json = JsonOutput.toJson(patternsMatches)
new File(outputFilePath.toString()).write(json)
}

process RUN_PFSEARCH {
label 'mem_min', 'time_medium', 'dynamic', 'ips6_container'

input:
tuple val(meta), path(fasta)
path dirpath
val profiles_dir

output:
tuple val(meta), stdout

script:
"""
find ${dirpath}/${profiles_dir} -type f | while read profile; do
pfsearchV3 -f -o 7 -t ${task.cpus} "\${profile}" "${fasta}"
done
"""
}

process PARSE_PFSEARCH {
label 'mem_low', 'time_veryshort'
executor 'local'

input:
tuple val(meta), val(pfsearch_out)
val signature_library
val dirpath
val blacklist_file

output:
tuple val(meta), path("pfsearch.json")

exec:
Map matches = [:]
SignatureLibraryRelease library = new SignatureLibraryRelease(signature_library, null)
def toSkip = []
if (dirpath && blacklist_file) {
toSkip = new File("${dirpath.toString()}/${blacklist_file}").readLines()
}

pfsearch_out.eachLine { line ->
def fields = line.split()
assert fields.size() == 10
String modelAccession = fields[0].split("\\|")[0]
if (toSkip && (modelAccession in toSkip)) {
return // skip flagged accessions
}

String seqId = fields[3]
int start = fields[4].toInteger()
int end = fields[5].toInteger()
Double score = Double.parseDouble(fields[7])
String alignment = fields[9]
String cigarAlignment = Match.encodeCigarAlignment(alignment)

matches.computeIfAbsent(seqId) { [:] }
Match matchObj = matches[seqId].computeIfAbsent(modelAccession) {
new Match(modelAccession, new Signature(modelAccession, library))
}
Location location = new Location(start, end, score, alignment, cigarAlignment)
matchObj.addLocation(location)
}
def outputFilePath = task.workDir.resolve("pfsearch.json")
def json = JsonOutput.toJson(matches)
new File(outputFilePath.toString()).write(json)
}

73 changes: 0 additions & 73 deletions modules/prosite/profiles/main.nf

This file was deleted.

2 changes: 1 addition & 1 deletion subworkflows/hamap/main.nf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include { RUN_PFSEARCH; PARSE_PFSEARCH } from "../../modules/prosite/profiles"
include { RUN_PFSEARCH ; PARSE_PFSEARCH } from "../../modules/pftools"

workflow HAMAP {
take:
Expand Down
6 changes: 3 additions & 3 deletions subworkflows/prosite/patterns/main.nf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include { RUN_PFSCAN; PARSE_PFSCAN } from "../../../modules/prosite/patterns"
include { RUN_PSSCAN; PARSE_PSSCAN } from "../../../modules/pftools"

workflow PROSITE_PATTERNS {
take:
Expand All @@ -8,14 +8,14 @@ workflow PROSITE_PATTERNS {
evafile // str repr of the path to the eva file in the data dir -> datadir/evafile

main:
RUN_PFSCAN(
RUN_PSSCAN(
ch_seqs,
dirpath,
datfile,
evafile
)

ch_prosite = PARSE_PFSCAN(RUN_PFSCAN.out)
ch_prosite = PARSE_PSSCAN(RUN_PSSCAN.out)

emit:
ch_prosite
Expand Down
2 changes: 1 addition & 1 deletion subworkflows/prosite/profiles/main.nf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include { RUN_PFSEARCH ; PARSE_PFSEARCH } from "../../../modules/prosite/profiles"
include { RUN_PFSEARCH ; PARSE_PFSEARCH } from "../../../modules/pftools"

workflow PROSITE_PROFILES {
take:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/modules/scan/hamap/parse_hamap.nf.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
nextflow_process {

name "Test Process PARSE_PFSEARCH"
script "modules/prosite/profiles/main.nf"
script "modules/pftools/main.nf"
process "PARSE_PFSEARCH"

test("Should run without failures") {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/modules/scan/prosite/patterns/main.nf.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
nextflow_process {

name "Test Process PARSE_PFSCAN"
script "modules/prosite/patterns/main.nf"
process "PARSE_PFSCAN"
name "Test Process PARSE_PSSCAN"
script "modules/pftools/main.nf"
process "PARSE_PSSCAN"

test("Should run without failures") {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
nextflow_process {

name "Test Process PARSE_PFSEARCH"
script "modules/prosite/profiles/main.nf"
script "modules/pftools/main.nf"
process "PARSE_PFSEARCH"

test("Should run without failures") {
Expand Down