fixed indentation error and ran mcsm_wrapper dcs

This commit is contained in:
Tanushree Tunstall 2020-04-17 12:19:08 +01:00
parent bc03aab82d
commit 368496733a
2 changed files with 8 additions and 8 deletions

View file

@ -124,9 +124,9 @@ def scrape_results(result_url):
print('FAIL: Could not fetch results' print('FAIL: Could not fetch results'
, '\nCheck if url is valid') , '\nCheck if url is valid')
# extract results using the html parser # extract results using the html parser
soup = BeautifulSoup(result_response.text, features = 'html.parser') soup = BeautifulSoup(result_response.text, features = 'html.parser')
# print(soup) # print(soup)
web_result_raw = soup.find(class_ = 'span4').get_text() web_result_raw = soup.find(class_ = 'span4').get_text()
return web_result_raw return web_result_raw
@ -156,11 +156,10 @@ def build_result_dict(web_result_raw):
result_dict = {} result_dict = {}
for line in mytext.split('\n'): for line in mytext.split('\n'):
fields = line.split(':') fields = line.split(':')
# print(fields) #print(fields)
if len(fields) > 1: # since Mutaton information is empty if len(fields) > 1: # since Mutaton information is empty
dict_entry = dict([(x, y) for x, y in zip(fields[::2], fields[1::2])]) dict_entry = dict([(x, y) for x, y in zip(fields[::2], fields[1::2])])
result_dict.update(dict_entry) result_dict.update(dict_entry)
return result_dict return result_dict
#%% #%%
#======================================================================= #=======================================================================

View file

@ -63,7 +63,8 @@ outfile_format = outdir + '/' + out_filename_format
#%%===================================================================== #%%=====================================================================
def submit_mcsm(): def submit_mcsm():
my_chain = 'A' my_chain = 'A'
my_ligand_id = 'DCS' # FIXME # my_ligand_id = 'DCS' # FIXME
my_ligand_id = 'RMP' # FIXME
my_affinity = 10 my_affinity = 10
print('Result urls and error file (if any) will be written in: ', outdir) print('Result urls and error file (if any) will be written in: ', outdir)
@ -88,6 +89,7 @@ def submit_mcsm():
, 'minutes, but will be longer for more mutations.') , 'minutes, but will be longer for more mutations.')
#%%===================================================================== #%%=====================================================================
def get_results(): def get_results():
output_df = pd.DataFrame() output_df = pd.DataFrame()
url_counter = 1 # HURR DURR COUNT STARTEDS AT ONE1`!1 url_counter = 1 # HURR DURR COUNT STARTEDS AT ONE1`!1
infile_len = os.popen('wc -l < %s' % result_urls).read() # quicker than using Python :-) #FIXME filenme (infile_urls) infile_len = os.popen('wc -l < %s' % result_urls).read() # quicker than using Python :-) #FIXME filenme (infile_urls)
@ -97,7 +99,6 @@ def get_results():
with open(result_urls, 'r') as urlfile: with open(result_urls, 'r') as urlfile:
for line in urlfile: for line in urlfile:
url_line = line.strip() url_line = line.strip()
# call functions # call functions
results_interim = scrape_results(url_line) results_interim = scrape_results(url_line)
result_dict = build_result_dict(results_interim) result_dict = build_result_dict(results_interim)