1.使用python lcr.py得到:
design nlcr lcr
1a1x.A 0 0
1a2p.A 0 0
1a32.A 0 0
1a73.A 0 0
1a8l.A 1 12
1a90.A 3 52
2.这里展示的文件是经过pandas排序的文件,我接下来的做法是不排序,去掉"index",通过shell语言(paste file1 file2)将链长追加在第4列,手动添加索引为"design nlcr lcr len"
补充链长可通过.fasta文件得到:
cat file | awk -F "" '/^[A-Z]/{print NF}' | wc -l
3.将添加索引后的文件通过python语言,假设要处理的文件在当前路径下
import pandas as pd
file2 = pd.read_csv('file1', sep='\t')
#因为我准备的是文本文件,所以要按照文本文件的读写方式来
file3 = file2.sort_values(by='design', ascending=True)
#这里将读入的文件按照某一列的索引排序
file3.to_csv('file4', sep='\t', index=False)
#这里将排序过后的文件写入新文件
4.将得到的file4去掉索引行
1a1x.A 0 0 108
1a2p.A 0 0 110
1a32.A 0 0 88
1a73.A 0 0 163
1a8l.A 1 12 226
1a90.A 3 52 108
5.我用的是awk命令:第3列除以第4列;
用paste命令将结果追加在file4的第5列;
将之前的natural结果追加到file4的第6列;
用此时的第5列减去第6列,得到差值;
awk '{printf "%.4f\n",$3/$4}' file4
1a1x.A 0 0 108 0.0000
1a2p.A 0 0 110 0.0000
1a32.A 0 0 88 0.0000
1a73.A 0 0 163 0.0000
1a8l.A 1 12 226 0.0531
1a90.A 3 52 108 0.4815
6.用以上得到的差值统计分布,这里我用的C语言:
# include <stdio.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>
# define N 30
# define NX 1120//2000
# define NBIN 100
int main(void)
{
int i, j, k, m, num=0;
double t1;
double d0=-1.0,d1=1.5,dbin=0.025,dist[NBIN];
char Istring[50];
FILE *fp;
for(m=0;m<NBIN;m++)
{
dist[m]=0;
}
num=0;
fp=fopen("baseline_natural1","r");
for(i=1;i<=NX;i++)
{
fscanf(fp,"%lf",&t1);
m= (1 + t1)/dbin;
dist[m]+=1;
num++;
}
fclose(fp);
fp=fopen("baseline_natural1_distr","w");
for(int m1=0;m1<NBIN;m1++)
{
fprintf(fp,"%f %g\n",d0+(m1+0.5)*dbin,dist[m1]/num);
}
fclose(fp);
return 0;
}
7.可视化方面我是通过gnuplot画的图:
set term postscript enhanced color solid
set output ‘Cath_distr.eps’
#set key top left
#set nokey
#set xr [0:3.2]
#set yr [0:40]
set xlabel “P_{design}-P_{natural}” font “Times-Roman,24”
set ylabel “P” font “Times-Roman,24”
#set label “GA88:T=0.82” font “Times-Roman,16” at 0.2,10
#set xtics nomirror
#set ytics nomirror
set mxtics 2
set mytics 2
set bmargin 4
set size square
plot"n0_DesNat1_distr" u 1:2 w lp lt 1 pt 7 ps 0.5 lc rgb “red”,
“n1_DesNat1_distr” u 1:2 w lp lt 3 pt 7 ps 0.5 lc rgb “blue”