system_path = system['path'] print('Analyzing', system_path) try: if system['UNITEDATOM_DICT']: #continue print('United atom simulation') except: pass output_name = "" trj_name = system['path'] + system['TRJ'][0][0] tpr_name = system['path'] + system['TPR'][0][0] trj_url = download_link(system['DOI'], system['TRJ'][0][0]) tpr_url = download_link(system['DOI'], system['TPR'][0][0]) socket.setdefaulttimeout(15) download_failed = False # make a function like this if (not os.path.isfile(tpr_name)): try: url_size = urllib.request.urlopen(tpr_url).length response = urllib.request.urlretrieve(tpr_url, tpr_name) except ContentTooShortError: download_failed = True print("Content too short error.")
filepath = subdir + os.sep + filename1 if filepath.endswith("README.yaml"): READMEfilepathSimulation = subdir + '/README.yaml' with open(READMEfilepathSimulation) as yaml_file_sim: #print('toimii') readme = yaml.load(yaml_file_sim, Loader=yaml.FullLoader) indexingPath = "/".join(filepath.split("/")[4:8]) print(indexingPath) DATAdir = '../../../../tst/FlipFlop/' + indexingPath + '/' #change directory when code works properly!!! doi = readme['DOI'] trj=readme['TRJ'][0][0] tpr=readme['TPR'][0][0] trj_name = subdir + '/' + trj tpr_name = subdir + '/' + tpr trj_url = download_link(doi, trj) tpr_url = download_link(doi, tpr) EQtime=float(readme['TIMELEFTOUT'])*1000 #Download tpr and xtc files to a tmp directory in dir wrk defined in readme file / or should these be put into the same directory as README.yaml ??? if (not os.path.isfile(tpr_name)): response = urllib.request.urlretrieve(tpr_url, tpr_name) if (not os.path.isfile(trj_name)): response = urllib.request.urlretrieve(trj_url, trj_name) xtcwhole=subdir + '/whole.xtc' if (not os.path.isfile(xtcwhole)): os.system('echo System | gmx trjconv -f ' + trj_name + ' -s ' + tpr_name + ' -o ' + xtcwhole + ' -pbc mol -b ' + str(EQtime)) u = mda.Universe(tpr_name,xtcwhole)
outfilename = path + 'apl.json' if os.path.isfile(outfilename): continue print('Analyzing: ', system['path']) for molecule in system['COMPOSITION']: if molecule in lipids_dict: Nlipid += np.sum(system['COMPOSITION'][molecule]['COUNT']) doi = system.get('DOI') trj = system.get('TRJ') tpr = system.get('TPR') trj_name = path + system.get('TRJ')[0][0] tpr_name = path + system.get('TPR')[0][0] trj_url = download_link(doi, trj[0][0]) tpr_url = download_link(doi, tpr[0][0]) #print(trj_name,tpr_name) if (not os.path.isfile(tpr_name)): response = urllib.request.urlretrieve(tpr_url, tpr_name) if (not os.path.isfile(trj_name)): response = urllib.request.urlretrieve(trj_url, trj_name) try: u = MDAnalysis.Universe(tpr_name, trj_name) except: conf = path + '/conf.gro' print("Generating conf.gro because MDAnalysis cannot read tpr version") os.system('echo System | gmx trjconv -s ' + tpr_name + ' -f ' +
# ### Check status links wrong_links = 0 software_sim = software_dict[sim['SOFTWARE'].upper()] for key_sim, value_sim in sim.items(): #print("key_sim = {0} => value_sim = {1}".format(key_sim, value_sim)) try: entry_type = software_sim[key_sim]['TYPE'] extension_type = software_sim[key_sim]['EXTENSION'] #print("entry_type = {0}".format(entry_type)) if "file" in entry_type and "txt" not in extension_type: for file_provided in value_sim: #print("File={0}".format(file_provided[0])) file_url = download_link(DOI, file_provided[0]) if file_url == "": wrong_links += 1 continue try: if key_sim == 'INI': continue response = urllib.request.urlopen(file_url) #print("Status of the DOI link: {0}".format(response.msg)) except HTTPError as e: print("\nkey={0} => file={1}".format(key_sim, file_provided[0])) print(file_url) print('The server couldn\'t fulfill the request.') print('Error code: ', e.code) wrong_links += 1 except URLError as e: