From 7a74fecbdaa346e905790478eb084c996473bf50 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Mon, 15 Feb 2021 12:22:19 +0000 Subject: [PATCH] saving work for mcsm_na --- dynamut/run_results.py | 2 ++ mcsm_na/examples.py | 2 +- mcsm_na/get_results.py | 53 ------------------------------------------ mcsm_na/run_submit.py | 15 ++++++++---- 4 files changed, 13 insertions(+), 59 deletions(-) delete mode 100644 mcsm_na/get_results.py diff --git a/dynamut/run_results.py b/dynamut/run_results.py index b6fec62..b796a2d 100644 --- a/dynamut/run_results.py +++ b/dynamut/run_results.py @@ -23,8 +23,10 @@ datadir = homedir + '/git/Data' indir = datadir + '/' + drug + '/input' outdir = datadir + '/' + drug + '/output' +# batch 1: 00.txt my_url_file = outdir + '/dynamut_temp/dynamut_result_url_gid_b1.txt' my_suffix = 'gid_b1' + #========================== # CALL: get_results() # Data: gid+streptomycin diff --git a/mcsm_na/examples.py b/mcsm_na/examples.py index fb98dd1..34969f7 100644 --- a/mcsm_na/examples.py +++ b/mcsm_na/examples.py @@ -9,7 +9,7 @@ import os homedir = os.path.expanduser('~') os.chdir (homedir + '/git/LSHTM_analysis/mcsm_na') from submit_mcsm_na import * -from get_results import * +from get_results_mcsm_na import * #%%##################################################################### #EXAMPLE RUN for different stages #===================== diff --git a/mcsm_na/get_results.py b/mcsm_na/get_results.py deleted file mode 100644 index 59cb213..0000000 --- a/mcsm_na/get_results.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Created on Wed Aug 19 14:33:51 2020 - -@author: tanu -""" -#%% load packages -import os,sys -import subprocess -import argparse -import requests -import re -import time -from bs4 import BeautifulSoup -import pandas as pd -from pandas.api.types import is_string_dtype -from pandas.api.types import is_numeric_dtype -#%%##################################################################### - -def get_results(url_file, host_url, output_dir, outfile_suffix): - # initilialise empty df - #mcsm_na_results_out_df = pd.DataFrame() - with open(url_file, 'r') as f: - for count, line in enumerate(f): - line = line.strip() - print('URL no.', count+1, '\n', line) - - #============================ - # Writing results file: csv - #============================ - mcsm_na_results_dir = output_dir + '/mcsm_na_results' - if not os.path.exists(mcsm_na_results_dir): - print('\nCreating dir: mcsm_na_results within:', output_dir ) - os.makedirs(mcsm_na_results_dir) - - # TODO: add as a cmd option - # Download .tar.gz file - prediction_number = re.search(r'([0-9]+\.[0-9]+$)', line).group(0) - print('CHECK prediction no:', prediction_number) - txt_url = f"{host_url}/mcsm_na/static/results/" + prediction_number + '.txt' - print('CHECK txt url:', txt_url) - - out_filename = mcsm_na_results_dir + '/' + outfile_suffix + '_output_' + prediction_number + '.txt' - response_txt = requests.get(txt_url, stream = True) - if response_txt.status_code == 200: - print('\nDownloading .txt:', txt_url - , '\n\nSaving file as:', out_filename) - with open(out_filename, 'wb') as f: - f.write(response_txt.raw.read()) - -#%%##################################################################### - diff --git a/mcsm_na/run_submit.py b/mcsm_na/run_submit.py index ebc90bd..f9c97f0 100755 --- a/mcsm_na/run_submit.py +++ b/mcsm_na/run_submit.py @@ -8,7 +8,7 @@ Created on Fri Feb 12 12:15:26 2021 #%% load packages import os homedir = os.path.expanduser('~') -os.chdir (homedir + '/git/LSHTM_analysis/dynamut') +os.chdir (homedir + '/git/LSHTM_analysis/mcsm_na') from submit_mcsm_na import * ######################################################################## # variables @@ -26,10 +26,15 @@ outdir = datadir + '/' + drug + '/output' my_nuc_type = 'RNA' my_pdb_file = indir + '/gid_complex.pdb' -# batch 1: 00.txt -my_mutation_list = outdir + '/snp_batches/20/snp_batch_00.txt' -my_suffix = 'gid_b1' -#RAN: 11 Feb, ~17:37 +# batch 1: 00.txt: # RAN: 11 Feb, ~17:37, RETRIEVED: 15 Feb~ 12:18 +#my_mutation_list = outdir + '/snp_batches/20/snp_batch_00.txt' +#my_suffix = 'gid_b1' + + +# batch 2: 01.txt +my_mutation_list = outdir + '/snp_batches/20/snp_batch_01.txt' +my_suffix = 'gid_b2' +# RAN: 15 Feb: 12:18 #========================== # CALL: submit_mcsm_na()