Shell_Sh_Code_Example

本文介绍了一个Shell脚本,用于自动化Modeller的工作流程。脚本通过检查Python版本并选择适当的运行方式,确保了Modeller相关脚本的正确执行。包括从构建配置文件到比较和对齐蛋白质结构等步骤,全程使用Python或modpy.sh脚本进行操作。
部署运行你感兴趣的模型镜像
#这个是Shell脚本,不是Python命令行文件
#!/bin/sh
# Run scripts with Python (and modpy.sh if needed) if possible, rather
# than the modXXX script (which only works correctly if Python 2.3 is installed)
modpy="../../bin/modpy.sh"
# If modpy.sh doesn't exist, assume we have Python set up correctly already
# (e.g. Mac or RPM install, or PYTHONPATH and LD_LIBRARY_PATH set):
if test "${PYTHON}x" != "x"; then
  pyint="${PYTHON}"
else
  pyint="python"
fi
if test ! -f ${modpy}; then
  modpy="${pyint}"
else
  modpy="${modpy} ${pyint}"
fi
# Only use Modeller through Python if 1) an import succeeds, 2) the 'modeller'
# module imported is really Modeller (not a spurious modeller.py in the path
# somewhere) and 3) the version matches that these examples were built with
run_version=`${modpy} - 2>/dev/null <<END
import sys
from modeller import *
v = info.version_info
if isinstance(v, tuple):
    v = ".".join([str(i) for i in v])
sys.stdout.write(v + '\n')
END
`
build_version="9.11"

#-- Rewrite By JunH
workPath="../ModellerWorkFolder/TvLDH"
PDBID="TvLDH"
PYFULLPATH="/home/protein/JunHWorkSpace/SimpleModeller"

if [ $# != 2 ]
then
  echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  echo "!!         输入参数不正确         !!"
  echo "!!      导出失败,未生成文件      !!"
  echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
  exit 1
fi

workPath=$1
PDBID=$2

# run_script build_profile
if test "${run_version}" = "${build_version}"; then
  cmd="${modpy} $PYFULLPATH/build_profile.py $PYFULLPATH $workPath $PDBID.ali > $workPath/temp/build_profile.log"
else
  cmd="mod9.11 $PYFULLPATH/build_profile.py"
fi
echo "$cmd"
# 运行Cmd
eval "$cmd"

# translate workPath + '/temp/build_profile.prf' File
# 去除文件$workPath/temp/build_profile.prf的第1-7行后保存在$workPath/temp/build_profile.prf.copy
sed '1,7d' $workPath/temp/build_profile.prf > $workPath/temp/build_profile.prf.copy

# 选取文件$workPath/temp/build_profile.prf.copy中第12个域值中最小的值
minilize=`awk 'BEGIN { a = 1 } { if ($12 < a) a = $12; } END { print a }' $workPath/temp/build_profile.prf.copy`
# 选取文件$workPath/temp/build_profile.prf.copy中所有最小的值
ProteinPDBIDList=`awk '{ if ($12 == '$minilize') print $2 }' $workPath/temp/build_profile.prf.copy`

# format ProteinPDBIDList
# 将$ProteinPDBIDList中所有的"  "变成" "
pPDBIDList=`echo $ProteinPDBIDList | sed 's/ / /g'`

#run_script compare
if test "${run_version}" = "${build_version}"; then
  cmd="${modpy} $PYFULLPATH/compare.py $PYFULLPATH $workPath $pPDBIDList > $workPath/temp/compare.log"
else
  cmd="mod9.11 $PYFULLPATH/compare.py"
fi
echo "$cmd"
eval "$cmd"

# translate workPath + '/temp/family.mat' File
# remove the first count line
sed '1,1d' $workPath/temp/family.mat > $workPath/temp/family.mat.copy

# search minilize score
minScore=1000
# while循环读取$workPath/temp/family.mat.copy每一行
while read line
do
  # 将line用" "分割后选取第2个域给atScore
   atScore=`echo $line | cut -d" " -f2`
   # 将atScore的第2个到最后一个字符截取后赋给score
   score=`echo $atScore | cut -c2-`
   # 比较score中的数值是否比minScore中的小如果是叫将socre赋给minScore
   if (echo ${score} ${minScore} | awk '!($1<$2){exit 1}') then
        tpdbID=`echo $line | cut -d" " -f1`
 minScore=$score
   fi
done < $workPath/temp/family.mat.copy

# 将tpdbID的第1个到第4个字符截取后赋给pdbCode
pdbCode=`echo $tpdbID | cut -c-4`
# 将tpdbID的第5个到最后一个字符截取后赋给pdbChain
pdbChain=`echo $tpdbID | cut -c5-`

#run_script align2d
if test "${run_version}" = "${build_version}"; then
  cmd="${modpy} $PYFULLPATH/align2d.py $PYFULLPATH $workPath $PDBID $pdbCode $pdbChain > $workPath/temp/align2d.log"
else
  cmd="mod9.11 $PYFULLPATH/align2d.py"
fi
echo "$cmd"
eval "$cmd"

#run_script model-single
if test "${run_version}" = "${build_version}"; then
  cmd="${modpy} $PYFULLPATH/model-single.py $workPath $PDBID $tpdbID > $workPath/temp/model-single.log"
else
  cmd="mod9.11 $PYFULLPATH/model-single.py"
fi
echo "$cmd"
eval "$cmd"

mv "$PDBID.B99990001.pdb" "$workPath/$PDBID.pdb"
rm -f $PDBID*


您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

The `setenv_qos222.sh` script is typically a shell script used to set up the environment for running specific applications or tools, particularly in software development or system configuration contexts. This type of script usually sets environment variables such as `PATH`, `LD_LIBRARY_PATH`, or other custom variables required by the software to function correctly. Such scripts are commonly found in projects that require specific configurations or dependencies to be loaded before execution. The exact functionality of `setenv_qos222.sh` would depend on its contents, but generally, it may perform tasks like: - Setting environment variables necessary for QoS (Quality of Service) tools or frameworks. - Configuring paths to libraries, executables, or resource files. - Activating specific runtime settings for testing or deployment environments. To understand and use this script, follow these steps: 1. **Inspect the Script**: Use a text editor or command like `cat setenv_qos222.sh` to view its contents. 2. **Check Permissions**: Ensure the script is executable with `chmod +x setenv_qos222.sh`. 3. **Run the Script**: Execute it using `source setenv_qos222.sh` to apply changes to the current shell session, or `./setenv_qos222.sh` if it's designed to run directly. Understanding the exact purpose and behavior of the script requires examining its code and the context in which it is used. ### Example of inspecting and sourcing the script ```bash # View the contents of the script cat setenv_qos222.sh # Make the script executable (if not already) chmod +x setenv_qos222.sh # Source the script to apply environment settings source setenv_qos222.sh ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jun-H

你的鼓励是我创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值