У меня есть несколько текстовых файлов в качестве результата вычисления, из которого я хочу извлечь данные:
(Примечание. Поскольку некоторые из файлов довольно искажены, я поместил копии в свой Dropbox. URL-адрес https://www.dropbox.com/sh/h774f8jzjb5l0wx/AAAqhvHsmPAhK_svdQG2Ou9Ha?dl=0)
=======================================================================
PSOVina version 2.0
Giotto H. K. Tai & Shirley W. I. Siu
Computational Biology and Bioinformatics Lab
University of Macau
Visit http://cbbio.cis.umac.mo for more information.
PSOVina was developed based on the framework of AutoDock Vina.
For more information about Vina, please visit http://vina.scripps.edu.
=======================================================================
Output will be 14-7_out.pdbqt
Reading input ... done.
Setting up the scoring function ... done.
Analyzing the binding site ... done.
Using random seed: 768314908
Performing search ... done.
Refining results ... done.
mode | affinity | dist from best mode
| (kcal/mol) | rmsd l.b.| rmsd u.b.
-----+------------+----------+----------
1 -9.960902669 0.000 0.000
2 -8.979504781 1.651 2.137
3 -8.942611364 3.051 6.898
4 -8.915523010 2.146 2.875
5 -8.736508831 2.908 7.449
6 -8.663387139 2.188 2.863
7 -8.410739711 5.118 7.281
8 -8.389146347 2.728 3.873
9 -8.296798909 2.416 3.846
10 -8.168454106 3.809 8.143
11 -8.127990818 3.712 8.109
12 -8.127103774 3.084 4.097
13 -7.979090739 3.798 4.959
14 -7.941872682 4.590 8.294
15 -7.900766215 3.300 8.204
16 -7.881485228 2.953 4.224
17 -7.837826485 3.005 4.125
18 -7.815909505 4.390 8.782
19 -7.722540286 5.695 9.851
20 -7.720346742 3.362 4.593
Writing output ... done.
Это работает:
import numpy as np
print('${d}')
data = np.genfromtxt("14-7.log", usecols=(1), skip_header=27,
skip_footer=1, encoding=None)
print(data)
np.savetxt('14-7.dG', data, fmt='%12.9f', header='14-7')
print(data)
, что дает:
runfile('/home/comp/Apps/Python/PsoVina/DeltaGTable_V_s.py',
wdir='/home/comp/Apps/Python/PsoVina', current_namespace=True)
${d}
[-9.96090267 -8.97950478 -8.94261136 -8.91552301 -8.73650883 -8.66338714
-8.41073971 -8.38914635 -8.29679891 -8.16845411 -8.12799082 -8.12710377
-7.97909074 -7.94187268 -7.90076621 -7.88148523 -7.83782648 -7.8159095
-7.72254029 -7.72034674]
[-9.96090267 -8.97950478 -8.94261136 -8.91552301 -8.73650883 -8.66338714
-8.41073971 -8.38914635 -8.29679891 -8.16845411 -8.12799082 -8.12710377
-7.97909074 -7.94187268 -7.90076621 -7.88148523 -7.83782648 -7.8159095
-7.72254029 -7.72034674]
Примечание; операторы печати предназначены для быстрой проверки иливыходные данные:
# 14-7
-9.960902669
-8.979504781
-8.942611364
-8.915523010
-8.736508831
-8.663387139
-8.410739711
-8.389146347
-8.296798909
-8.168454106
-8.127990818
-8.127103774
-7.979090739
-7.941872682
-7.900766215
-7.881485228
-7.837826485
-7.815909505
-7.722540286
-7.720346742
Кроме того, этот скрипт bash работает:
#!/bin/bash
# Run.dG.list_1
while IFS= read -r d
do
echo "${d}.log"
done <ligand.list
, который возвращает три имени файла журнала:
14-7.log
15-7.log
18-7.log
Но, еслиЯ запускаю этот скрипт bash:
#!/bin/bash
# Run.dG.list_1
while IFS= read -r d
do
echo "${d}.log"
python3 DeltaGTable_V_sl.py
done <ligand.list
, где DeltaGTable_V_sl.py:
import numpy as np
print('${d}')
data = np.genfromtxt('${d}.log', usecols=(1), skip_header=27,
skip_footer=1, encoding=None)
print(data)
np.savetxt('${d}.dG', data, fmt='%12.9f', header='${d}')
print(data.dG)
Я получаю:
(base) comp@AbNormal:~/Apps/Python/PsoVina$ sh ./Run.dG.list_1.sh
14-7.log
python3: can't open file 'DeltaGTable_V_sl.py': [Errno 2] No such file
or directory
15-7.log
python3: can't open file 'DeltaGTable_V_sl.py': [Errno 2] No such file
or directory
18-7.log
python3: can't open file 'DeltaGTable_V_sl.py': [Errno 2] No such file
or directory
C-VX3.log
python3: can't open file 'DeltaGTable_V_sl.py': [Errno 2] No such file
or directory
Итак, может показаться, что журналметки файлов находятся в рабочей области, но «$ {d} .log» не распознается как genfromtxt как fname. Хотя я гуглил каждую комбинацию терминов, о которых могу думать, я явно что-то упускаю.
КакУ меня есть потенциально сотни файлов для обработки, я был бы признателен за указание на решение проблемы.
Tспасибо заранее.