Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 59 additions & 11 deletions run.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,36 @@

print('\nChecking for inputs features files in path ' + args.input_feats + '\n')

# for rna_id in list_rna_ids:

# print('\n', rna_id+':')

# if Path(args.input_feats + '/' + rna_id).is_file():
# print('RNA sequence \u2713')
# with open(args.input_feats + '/' + rna_id) as f:
# temp_1 = pd.read_csv(f, comment='#', delim_whitespace=True, header=None, skiprows=[0]).values
# seq_ref = ''.join([j.upper() for j in temp_1[0, 0]])
# else: raise ValueError('RNA sequence file does not exists in path ' + args.input_feats + '/' + rna_id + '\n')

# # if args.single_seq == 1:
# if Path(args.input_feats + '/' + rna_id + '_dp.ps').is_file(): print('base pair probability \u2713')
# else:
# print('base pair probability \u2717')
# print('base pair probability file does not exists in path ' + args.input_feats + '/' + rna_id + '_dp.ps')
# print('Generating RNAfold base-pair probability')
# process1 = subprocess.Popen(["RNAfold", "-p", "-i", args.input_feats + '/' + rna_id], stdout=subprocess.PIPE); time.sleep(2)
# process2 = subprocess.Popen(["mv", rna_id + "_dp.ps", args.input_feats + '/'], stdout=subprocess.PIPE)
# process2 = subprocess.Popen(["mv", rna_id + "_ss.ps", args.input_feats + '/'], stdout=subprocess.PIPE)
# if Path(args.input_feats + '/' + rna_id + '_dp.ps').is_file(): print('base pair probability \u2713')

# if args.single_seq != 1:
# if Path(args.input_feats + '/' + rna_id + '.pssm').is_file(): print('PSSM features \u2713')
# else: raise ValueError('PSSM file does not exists in path ' + args.input_feats + '/' + rna_id + '.pssm\n')

# if Path(args.input_feats + '/' + rna_id + '.dca').is_file(): print('DCA features \u2713')
# else: raise ValueError('DCA file does not exists in path ' + args.input_feats + '/' + rna_id + '.dca\n')
# time.sleep(0.1)
# print()
for rna_id in list_rna_ids:

print('\n', rna_id+':')
Expand All @@ -59,26 +89,44 @@
else: raise ValueError('RNA sequence file does not exists in path ' + args.input_feats + '/' + rna_id + '\n')

# if args.single_seq == 1:
if Path(args.input_feats + '/' + rna_id + '_dp.ps').is_file(): print('base pair probability \u2713')
if Path(args.input_feats + '/' + rna_id + '_dp.ps').is_file():
print('base pair probability \u2713')
else:
print('base pair probability \u2717')
print('base pair probability file does not exists in path ' + args.input_feats + '/' + rna_id + '_dp.ps')
print('Generating RNAfold base-pair probability')
process1 = subprocess.Popen(["RNAfold", "-p", "-i", args.input_feats + '/' + rna_id], stdout=subprocess.PIPE); time.sleep(0.5)
process2 = subprocess.Popen(["mv", rna_id + "_dp.ps", args.input_feats + '/'], stdout=subprocess.PIPE)
process2 = subprocess.Popen(["mv", rna_id + "_ss.ps", args.input_feats + '/'], stdout=subprocess.PIPE)
if Path(args.input_feats + '/' + rna_id + '_dp.ps').is_file(): print('base pair probability \u2713')
try:

subprocess.run(["RNAfold", "-p", "-i", args.input_feats + '/' + rna_id],
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)


subprocess.run(["mv", rna_id + "_dp.ps", args.input_feats + '/'], check=True)
subprocess.run(["mv", rna_id + "_ss.ps", args.input_feats + '/'], check=True)

if Path(args.input_feats + '/' + rna_id + '_dp.ps').is_file():
print('base pair probability \u2713')
else:
print('base pair probability \u2717 - file not found after generation')

except subprocess.CalledProcessError as e:
print(f'Error running RNAfold: {e}')
except Exception as e:
print(f'Unexpected error: {e}')

if args.single_seq != 1:
if Path(args.input_feats + '/' + rna_id + '.pssm').is_file(): print('PSSM features \u2713')
else: raise ValueError('PSSM file does not exists in path ' + args.input_feats + '/' + rna_id + '.pssm\n')

if Path(args.input_feats + '/' + rna_id + '.dca').is_file(): print('DCA features \u2713')
else: raise ValueError('DCA file does not exists in path ' + args.input_feats + '/' + rna_id + '.dca\n')
if Path(args.input_feats + '/' + rna_id + '.pssm').is_file():
print('PSSM features \u2713')
else:
raise ValueError('PSSM file does not exists in path ' + args.input_feats + '/' + rna_id + '.pssm\n')

if Path(args.input_feats + '/' + rna_id + '.dca').is_file():
print('DCA features \u2713')
else:
raise ValueError('DCA file does not exists in path ' + args.input_feats + '/' + rna_id + '.dca\n')
time.sleep(0.1)
print()


os.environ["CUDA_VISIBLE_DEVICES"]= str(args.gpu)
os.environ['KMP_WARNINGS'] = 'off'

Expand Down