Skip to content

Commit

Permalink
Now creates the output directories if non existent
Browse files Browse the repository at this point in the history
  • Loading branch information
iquasere committed Apr 6, 2021
1 parent 5e7e9d3 commit 3faf980
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions upimapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import urllib.request
import subprocess
import psutil
import pathlib
from io import StringIO

import pandas as pd
from progressbar import ProgressBar

from uniprot_support import UniprotSupport

__version__ = '1.1.3'
__version__ = '1.1.4'

upmap = UniprotSupport()

Expand Down Expand Up @@ -71,8 +72,12 @@ def get_arguments(self):
diamond_args.add_argument("-t", "--threads", default='1', help="Number of threads to use in annotation steps")
diamond_args.add_argument("-mts", "--max-target-seqs", default='50',
help="Number of annotations to output per sequence inputed")
diamond_args.add_argument("-b", "--block-size", help="Number of annotations to output per sequence inputed")
diamond_args.add_argument("-c", "--index-chunks", help="Number of annotations to output per sequence inputed")
diamond_args.add_argument("-b", "--block-size", help="Billions of sequence letters to be processed at a time "
"(UPIMAPI determines best value for this parameter if not "
"set")
diamond_args.add_argument("-c", "--index-chunks", help="Number of chunks for processing the seed index "
"(UPIMAPI determines best value for this parameter if not "
"set")

args = parser.parse_args()
args.diamond_output = args.diamond_output.rstrip('/')
Expand Down Expand Up @@ -240,8 +245,8 @@ def recursive_uniprot_fasta(self, all_ids, output, max_iter=5, step=1000):
'information are available at {} and information obtained is available at {}'.format(
str(len(ids_missing)), ids_unmapped_output, output))

def recursive_uniprot_information(self, ids, output, max_iter=5, excel=False,
columns=list(), databases=list(), step=1000):
def recursive_uniprot_information(self, ids, output, max_iter=5, excel=False, columns=list(), databases=list(),
step=1000):
if os.path.isfile(output) and os.stat(output).st_size > 1:
try:
result = (pd.read_csv(output, sep='\t', low_memory=False) if not
Expand Down Expand Up @@ -341,9 +346,12 @@ def run_diamond(self, query, aligned, unaligned, database, threads='12', max_tar

def upimapi(self):
args = self.get_arguments()
pathlib.Path('/'.join(args.output.split('/')[:-1])).mkdir(parents=True, exist_ok=True)

# Using annotation with DIAMOND
if args.use_diamond:
pathlib.Path(args.diamond_output).mkdir(parents=True, exist_ok=True)

if not args.database.endswith(".dmnd"):
self.generate_diamond_database(args.database, '{}.dmnd'.format('.'.join(args.database.split('.')[:-1])))
args.database = '{}.dmnd'.format('.'.join(args.database.split('.')[:-1]))
Expand Down

0 comments on commit 3faf980

Please sign in to comment.