Skip to content

Commit

Permalink
Fix installation process #18 (#19)
Browse files Browse the repository at this point in the history
* Fix installation issues (part 1) - #18

* Update script entrypoint and CI pipeline - #18

* Fix CI workflow

* Fix CI workflow

* Fix possible python versions - #18
  • Loading branch information
jludwiczak authored Oct 2, 2022
1 parent 2d9caf5 commit ca16e92
Show file tree
Hide file tree
Showing 10 changed files with 1,955 additions and 125 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -15,8 +15,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine pytest pytest-cov
pip install -r requirements.txt
pip install .
- name: Set environment
run: |
echo "PYTHONPATH=/home/runner/work/DeepCoil/DeepCoil" >> $GITHUB_ENV
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

## v2.0.2
- Fixed installation issues.

### v2.0.1
- Updated DC2 neural network weights.

Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
**Older DeepCoil versions are available [here](https://github.com/labstructbioinf/DeepCoil/releases).**

### **Requirements and installation** ###
DeepCoil requires `python>=3.6.1` and `pip>=19.0`. Other requirements are specified in the `requirements.txt` file.
DeepCoil requires `python>=3.7,<3.9` and `pip>=19.0`.

The most convenient way to install **DeepCoil** is to use pip:
```bash
Expand Down
83 changes: 0 additions & 83 deletions bin/deepcoil

This file was deleted.

85 changes: 85 additions & 0 deletions deepcoil/run_deepcoil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import os
import argparse
from Bio import SeqIO
from deepcoil import DeepCoil
from deepcoil.utils import is_fasta, sharpen_preds, plot_preds


def main():

parser = argparse.ArgumentParser(description='DeepCoil')
parser.add_argument('-i',
help='Input file with sequence in fasta format.',
required=True,
metavar='FILE')
parser.add_argument('-out_path',
help='Output directory',
default='.',
metavar='DIR')
parser.add_argument('-n_cpu',
help='Number of CPUs to use in the prediction',
default=-1,
type=int,
metavar='NCPU')
parser.add_argument('--gpu',
help='Use GPU. This option overrides -n_cpu option',
action='store_true')
parser.add_argument('--plot',
help='Plot predictions. Images will be stored in the path defined by the -out_path',
action='store_true')
parser.add_argument('--dpi',
help='DPI of the produced images',
default=300,
type=int,
metavar='DPI')
args = parser.parse_args()

# Check if input file exists
if not os.path.isfile(args.i):
print('ERROR: Input file does not exist!')
exit()
# Check if input is valid fasta file
if not is_fasta(args.i):
print("ERROR: Malformed fasta file. Please check input!")
exit()
# Check if output dir exists
if not os.path.isdir(args.out_path):
print("ERROR: Output directory does not exist!")
exit()

# Verify fasta file
raw_data = list(SeqIO.parse(args.i, "fasta"))
data = {''.join(e for e in str(entry.id) if (e.isalnum() or e == '_')): str(entry.seq) for entry in raw_data}
if not len(data) == len(raw_data):
print("ERROR: Sequence identifiers in the fasta file are not unique!")
exit()

print("Loading DeepCoil model...")
dc = DeepCoil(use_gpu=args.gpu, n_cpu=args.n_cpu)

print('Predicting...')
preds = dc.predict(data)

print('Writing output...')

inp_keys = set(data.keys())
out_keys = set(preds.keys())

if len(out_keys) < len(inp_keys):
print('WARNING: Predictions for some sequences were not calculated due to length limitations and/or other errors.' \
' Inspect the warnings and results carefully!')

for entry in out_keys:
f = open(f'{args.out_path}/{entry}.out', 'w')
cc_pred_raw = preds[entry]['cc']
cc_pred = sharpen_preds(cc_pred_raw)
hept_pred = preds[entry]['hept']
f.write('aa\tcc\traw_cc\tprob_a\tprob_d\n')
for aa, cc_prob, cc_prob_raw, a_prob, d_prob in zip(data[entry], cc_pred, cc_pred_raw, hept_pred[:, 1], hept_pred[:, 2]):
f.write('{0}\t{1:.3f}\t{2:.3f}\t{3:.3f}\t{4:.3f}\n'.format(aa, float(cc_prob), float(cc_prob_raw), float(a_prob), float(d_prob)))
f.close()
if args.plot:
for entry in out_keys:
plot_preds(preds[entry], out_file=f'{args.out_path}/{entry}.png', dpi=args.dpi)
print("Done!")

Loading

0 comments on commit ca16e92

Please sign in to comment.