如何计算在AWK的序列的残基的总数量? [英] How to count the total number of residues in a sequence with awk?

查看:152
本文介绍了如何计算在AWK的序列的残基的总数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含蛋白质序列的文本文件。我想获得每个序列中残基的总数。我怎样才能做到这一点使用awk?

 > 1GS9
PYCPAAVIAPVV
> 1LE2
DFEFAKWKN
> 1NFN
ADAPPDS

所需的输出

  1GS9  -  12
1LE2 - 9
1NFN - 7


解决方案

自动读取每个奇数行{...} 和蛋白质偶数行与函数getline

 的awk'{
    函数getline PROT;
    printf的%s的内容 - %d \\ n,substr($ 0,2),长度(PROT)
}'INFILE

输出:

  1GS9  -  12
1LE2 - 9
1NFN - 7

I have a text file that contains protein sequences. I would like to get the total number of residues in each sequence. How can I do this with awk?

>1GS9
PYCPAAVIAPVV
>1LE2
DFEFAKWKN
>1NFN
ADAPPDS

Desired output

1GS9 - 12
1LE2 - 9
1NFN - 7

解决方案

Read every odd line automatically with { ... } and proteins in even lines with getline:

awk ' {
    getline prot;
    printf "%s - %d\n", substr( $0, 2 ), length( prot ) 
}' infile

Output:

1GS9 - 12
1LE2 - 9
1NFN - 7

这篇关于如何计算在AWK的序列的残基的总数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆