2022_0715处理蛋白后续文件得到LCR(低复杂度区域)的相关数据(代码能力不是很好,所以穿插了多种语言)

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”

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值