我有几个.pdb文件需要处理才能从中检索现成的值。我已经制作了一个bash脚本来尝试将所有命令组合在一起。
我对这个脚本的具体问题是两个:
我尝试在Ubuntu的命令行上通过键入/输入./myscript.bash在bash中运行它并且它没有将所需文件输出到该文件夹时,我的脚本冻结了。我的脚本中可能导致冻结的错误是什么?
在最后的命令中,
grep 'model*' $file >> $file"-confscore".txt
#command to keep only the 1-5 lines from each dir I want to keep that contain this full format " model1 -5.00 0.21+-0.05 19.9+-1.8 404 0.003 " then >> combinedcscore.txt
#Then reformat it to just "$dir model1 -5.00" >> newcombcscore.txt
我不知道如何用bash编写这个命令。您在开头看到的grep会将包含任何model *文本的行打印到名为$ file ___。txt的文件中。我需要以特定格式使用它,我将其包含在grep下面的#' d行中。我正在考虑使用:
for files in $dirs; do
awk -F':' ' { print $dir model* firstvalueidk? }' >> newcombcscore.txt
我对awk的使用是否正确?
以下是完整的参考脚本:
#! /usr/bin/env bash
#Step 0 - Set up variables & navigate to app. directory
set GETLOCATION = "~/Desktop/DCompartment/RolandoHT_Scripts/Perl_Scripts"
set GETNAME = "get_right_pdb_format.pl"
set SSLOCATION = "~/Desktop/DCompartment/RolandoHT_Scripts/Perl_Scripts"
set SSNAME = "get_ss_dssp_itasser.pl"
set PROTALOCATION = "~/Desktop/protAlign-master/"
set dirs = ~/Videos/Proteins/*
#Step 1 - Process PDB for readily available values
for dir in $dirs; do
rm `cscore|model*.pdb|seq.fasta`
done
for dir in $dirs; do
for file in *.pdb; do
perl $GETLOCATION/$GETNAME $file
dssp -i $file"-fix" -o $file.dssp
perl $SSLOCATION/$SSNAME $file.dssp $file"-out"
done
for file in $dirs/*.dssp; do
grep 'ACCESSIBLE SURFACE OF PROTEIN' $file >> $file"-SASA".txt
done
for file in $dirs/*.txt; do
echo "$file `cat $file`" >> $dir-combinedSASAs.txt
done
done
#Step 2 - Set up tool
for dir in $dirs; do
./$PROTALOCATION/initialize.sh
source $PROTALOCATION/bin/activate
done
#Step 3 - Start analyzing files
for dir in $dirs; do
for file in *.pdb; do
./$PROTALOCATION/program_name.py $dir $dir/native.pdb $dir-SPAR
done
done
for file in $dirs/data; do
set filerep = native-*.txt
grep 'TM-score' $filerep >> combinedreports.txt
awk 'FNR%2' combinedreports.txt > newcombinedrep.txt
done
for dir in $dirs; do
for file in cscore; do
grep 'model*' $file >> $file"-confscore".txt
#command to keep only the 1-5 lines from each dir I want to keep that contain this full format " model1 -5.00 0.21+-0.05 19.9+-1.8 404 0.003 " then >> combinedcscore.txt
#Then reformat it to just "$dir model1 -5.00" >> newcombcscore.txt
done
done
答案 0 :(得分:1)
我认为你的脚本是冻结的,因为所有变量都是空的,而grep
之类的命令在STDIN上被阻塞了!我很快清理了你的脚本,并添加了一些我认为你可能需要的代码(前缀为" GLR"注释)。研究这个,它应该让你更接近。
#!/bin/bash
# Step 0 - Set up variables & navigate to app. directory
GETLOCATION=~/Desktop/DCompartment/RolandoHT_Scripts/Perl_Scripts
GETNAME=get_right_pdb_format.pl
SSLOCATION=~/Desktop/DCompartment/RolandoHT_Scripts/Perl_Scripts
SSNAME=get_ss_dssp_itasser.pl
PROTALOCATION=~/Desktop/protAlign-master
dirs=~/Videos/Proteins/*
# GLR: uncomment the next line for debugging
#set -x
#Step 1 - Process PDB for readily available values
for dir in $dirs; do
# GLR: Assume you want to change directory here?
pushd $dir
rm `cscore|model*.pdb|seq.fasta`
# GLR: back to original directory
popd
done
for dir in $dirs; do
# GLR: Assume you want to change directory here?
pushd $dir
for file in *.pdb; do
perl $GETLOCATION/$GETNAME $file
dssp -i ${file}-fix -o $file.dssp
perl $SSLOCATION/$SSNAME $file.dssp ${file}-out
done
for file in $dirs/*.dssp; do
grep 'ACCESSIBLE SURFACE OF PROTEIN' $file >> ${file}-SASA.txt
done
for file in $dirs/*.txt; do
echo "$file `cat $file`" >> $dir-combinedSASAs.txt
done
# GLR: back to original directory
popd
done
#Step 2 - Set up tool
for dir in $dirs; do
# GLR: Assume you want to change directory here?
pushd $dir
./$PROTALOCATION/initialize.sh
. $PROTALOCATION/bin/activate
# GLR: back to original directory
popd
done
#Step 3 - Start analyzing files
for dir in $dirs; do
# GLR: Assume you want to change directory here?
pushd $dir
for file in *.pdb; do
./$PROTALOCATION/program_name.py $dir $dir/native.pdb $dir-SPAR
done
# GLR: back to original directory
popd
done
# GLR: this won't do what you want
#for file in $dirs/data; do
for dir in $dirs; do
# GLR: Assume you want to change directory here?
pushd $dir/data
#;filerep=native-*.txt
#;grep 'TM-score' $filerep >> combinedreports.txt
grep 'TM-score' native-*.txt >> combinedreports.txt
awk 'FNR%2' combinedreports.txt > newcombinedrep.txt
# GLR: back to original directory
popd
done
for dir in $dirs; do
# GLR: Assume you want to change directory here?
pushd $dir
for file in cscore; do
grep 'model*' $file >> ${file}-confscore.txt
# command to keep only the 1-5 lines from each dir I want to keep
# that contain this full format
# " model1 -5.00 0.21+-0.05 19.9+-1.8 404 0.003 "
# then >> combinedcscore.txt
# Then reformat it to just "$dir model1 -5.00" >> newcombcscore.txt
done
# GLR: back to original directory
popd
done
exit 0