-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import glob | ||
import os | ||
import subprocess as sp | ||
import sys | ||
|
||
|
||
PROPERTIES="interproscan.properties" | ||
|
||
|
||
def load_properties(file, properties): | ||
with open(file, "rt") as fh: | ||
for line in map(str.strip, fh): | ||
if not line or line[0] == "#": | ||
continue | ||
|
||
fields = line.split("=", 1) | ||
if len(fields) == 2: | ||
key = fields[0].strip() | ||
value = fields[1].strip() | ||
properties[key] = value | ||
|
||
try: | ||
bin_dir = properties["bin.directory"] | ||
data_dir = properties["data.directory"] | ||
except KeyError: | ||
return | ||
|
||
for key, value in properties.items(): | ||
if "${bin.directory}" in value: | ||
value = value.replace("${bin.directory}", bin_dir) | ||
|
||
if "${data.directory}" in value: | ||
value = value.replace("${data.directory}", data_dir) | ||
|
||
properties[key] = value | ||
|
||
|
||
def is_ready(hmmfile): | ||
for ext in [".h3m", ".h3i", ".h3f", ".h3p"]: | ||
if not os.path.isfile(hmmfile + ext): | ||
return False | ||
|
||
return True | ||
|
||
|
||
def hmmpress(binary, force, database): | ||
if force: | ||
cmd = [binary, "-f", database] | ||
else: | ||
cmd = [binary, database] | ||
|
||
proc = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE) | ||
outs, errs = proc.communicate() | ||
|
||
if proc.returncode != 0: | ||
sys.stderr.write(errs.decode()) | ||
sys.exit(1) | ||
|
||
|
||
def realpath(path): | ||
return os.path.realpath(os.path.expanduser(path)) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="index HMM databases") | ||
parser.add_argument("properties", help="InterProScan properties file") | ||
parser.add_argument("-f", "--force", action="store_true", | ||
help="re-index all HMM databases (default: off)") | ||
args = parser.parse_args() | ||
|
||
properties = {} | ||
load_properties(PROPERTIES, properties) | ||
|
||
if realpath(args.properties) != realpath(PROPERTIES): | ||
load_properties(args.properties, properties) | ||
|
||
ignore = {"binary.tmhmm.path", "funfam.hmm.path", "smart.hmm.path"} | ||
for key, path in properties.items(): | ||
if "hmm.path" in key and key not in ignore: | ||
bin_key = "binary.hmmer3.path" | ||
|
||
if os.path.isfile(path): | ||
hmmfiles = [path] | ||
else: | ||
hmmfiles = glob.iglob(os.path.join(path, "**", "*.hmm"), | ||
recursive=True) | ||
|
||
for hmmfile in hmmfiles: | ||
if args.force or not is_ready(hmmfile): | ||
try: | ||
bin_path = os.path.join(properties[bin_key], "hmmpress") | ||
except KeyError: | ||
continue | ||
else: | ||
hmmpress(bin_path, args.force, hmmfile) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Empty file modified
0
core/jms-implementation/support-mini-x86-32/test_proteins_new.fasta
100755 → 100644
Empty file.
Empty file modified
0
core/jms-implementation/support-mini-x86-32/test_proteins_redundant.fasta
100755 → 100644
Empty file.