Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
ready for first container release
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Iszatt authored and Josh Iszatt committed May 18, 2023
1 parent 2ed75cf commit 237d25d
Show file tree
Hide file tree
Showing 11 changed files with 834 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ Iszatt J.(2023).Phanatic(v2.2.0)[Source code].Github:https://github.com/JoshuaIs
```

## Installation
To run this pipeline you first need a working docker installation.

Install using pip
```sh

pip install Phanatic==2.2.0
```

Run the help command to see options
```sh

phanatic.py -h
```

## Output
Expand Down
661 changes: 661 additions & 0 deletions pip/LICENSE.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions pip/Phanatic.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Metadata-Version: 2.1
Name: Phanatic
Version: 2.2.0
Summary: Python package to run de novo bacteriophage assembly container.
Home-page: https://github.com/JoshuaIszatt/Phanatic
Author: Joshua Iszatt
Author-email: joshiszatt@gmail.com
License: AGPL-3.0
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.6
License-File: LICENSE.md
9 changes: 9 additions & 0 deletions pip/Phanatic.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
LICENSE.md
setup.py
Phanatic/__init__.py
Phanatic/main.py
Phanatic.egg-info/PKG-INFO
Phanatic.egg-info/SOURCES.txt
Phanatic.egg-info/dependency_links.txt
Phanatic.egg-info/entry_points.txt
Phanatic.egg-info/top_level.txt
1 change: 1 addition & 0 deletions pip/Phanatic.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions pip/Phanatic.egg-info/entry_points.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[console_scripts]
phanatic.py = Phanatic.main:main
1 change: 1 addition & 0 deletions pip/Phanatic.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Phanatic
Empty file added pip/Phanatic/__init__.py
Empty file.
108 changes: 108 additions & 0 deletions pip/Phanatic/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
def main():

import os
import sys
import subprocess
import argparse
import random
import pandas as pd

# Did you know prompts
prompts = [
"Phanatic currently only supports short, paired end, illumina reads (default 'PE_illumina_150').",
"I (J. Iszatt) made Phanatic to assemble S. aureus phage genomes as part of my PhD project.",
"This is a short read assembler primarily designed for bacteriophage",
"My favourite bacteriophage is a Silviavirus named Koomba-kaat_1",
"You can use your own config file to customise the assembly and functions"
]
random_prompt = random.choice(prompts)

# Creating function to check directory path
def valid_dir(dir_path):
if not os.path.isdir(dir_path):
raise argparse.ArgumentTypeError(
f"{dir_path} is not a valid directory path")
if not os.access(dir_path, os.R_OK):
raise argparse.ArgumentTypeError(
f"{dir_path} is not a readable directory")
return dir_path

def valid_file(file_path):
if not os.path.isfile(file_path):
raise argparse.ArgumentTypeError(
f"{file_path} is not a valid file path")
if not os.access(file_path, os.R_OK):
raise argparse.ArgumentTypeError(
f"{file_path} is not a readable file")
return file_path

# Parsing arguments
image = 'iszatt/phanatic:2.2.0'
parser = argparse.ArgumentParser(description=f"Easy short read assembly. Joshua J Iszatt: https://github.com/JoshuaIszatt")

# Input/output options
parser.add_argument('-i', '--input', type=valid_dir, help='Input reads files')
parser.add_argument('-o', '--output', type=valid_dir, help='Direct output to this location')
parser.add_argument('-r', '--reads', type=str, choices=['PE_illumina_150'], default='PE_illumina_150', help='Pipeline options')
parser.add_argument('-c', '--config', type=valid_file, help='Use config file to customise assembly')
parser.add_argument('-v', '--version', action="store_true", help='Print the docker image version')
parser.add_argument('--show_console', action="store_true", help='Include this flag to write output to console')
parser.add_argument('--manual', action="store_true", help='Enter container interactively')
args = parser.parse_args()

# Printing version
if args.version:
print(image)
sys.exit(0)

# Obtaining absolute paths if entered correctly
if args.input and args.output:
input_path = os.path.abspath(args.input)
output_path = os.path.abspath(args.output)
elif args.input and not args.output:
sys.exit("No output directory specified\nRun --help to see options")
elif args.output and not args.input:
sys.exit("No input directory specified\nRun --help to see options")
else:
sys.exit("No input or output directories specified\nRun --help to see options")


# Printing command variables
print(
f"Program run: {image}",
f"Input path: {input_path}",
f"Output path: {output_path}",
f"Reads type: {args.reads}",
">>>",
f"Did you know:",
f"{random_prompt}",
">>>\n",
sep='\n'
)

# Copying config file to output dir
if args.config:
print(f"Using {args.config} file \n")
os.system(f"cp {args.config} {args.output}/config.ini")

if args.show_console:
docker = "docker run"
else:
docker = "docker run -d"

# Running docker
if args.manual:
os.system(f"docker exec -it \
$(docker run -d \
-v {input_path}:/assemble/input \
-v {output_path}:/assemble/output \
{image} sleep 1d) bash")
else:
command = ["%s -v %s:/assemble/input -v %s:/assemble/output %s /assemble/bin/assemble.sh" %
(docker, input_path, output_path, image)]
result = subprocess.Popen(command, shell=True)
print(command)


if __name__ == "__main__":
exit(main())
Binary file added pip/dist/Phanatic-2.2.0.tar.gz
Binary file not shown.
30 changes: 30 additions & 0 deletions pip/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from setuptools import find_packages, setup

setup(
name="Phanatic",
version="2.2.0",
description="Python package to run de novo bacteriophage assembly container.",
url="https://github.com/JoshuaIszatt/Phanatic",
author="Joshua Iszatt",
author_email="joshiszatt@gmail.com",
license="AGPL-3.0",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
install_requires=[""],
python_requires=">=3.6",
packages=find_packages(),
data_files=[("", ["LICENSE.md"])],
entry_points={
'console_scripts': [
'phanatic.py = Phanatic.main:main',
],
},
)

0 comments on commit 237d25d

Please sign in to comment.