从删除数据文件选定行 [英] deleting selected lines from data file

查看:90
本文介绍了从删除数据文件选定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是从我先前的职位延续题为从常规的前pression选择数字。

This question is continuation from my earlier post titled "selecting digits from regular expression".

下面是示例数据张贴在先前的职位。

Below is the sample data as posted in the earlier post.

          DONOR         ACCEPTORH      ACCEPTOR           
    atom#  res@atom   atom#  res@atom atom#  res@atom %occupied  distance       angle        
  |  4726   59@O12 |  1487    19@H12  1486    19@O12 |  85.66  2.819 ( 0.18)  21.85 (12.11)        
  |  1499   19@O15 |  1730    22@H12  1729    22@O12 |  83.15  3.190 ( 0.31)  22.36 (12.73)        
  |  1216   16@O22 |  1460    19@H22  1459    19@O22 |  75.74  2.757 ( 0.14)  24.55 (13.66)        
  |  4232   53@O25 |  4143    52@H24  4142    52@O24 |  74.35  2.916 ( 0.25)  28.27 (13.26)        
  |  3683   46@O16 |  4163    52@H13  4162    52@O13 |  73.78  2.963 ( 0.29)  23.65 (14.14)        
  |  4162   52@O13 |  4079    51@H12  4078    51@O12 |  73.68  2.841 ( 0.19)  21.25 (11.87)        
  |  3764   47@O16 |  3825    48@H26  3824    48@O26 |  70.52  2.973 ( 0.28)  26.88 (13.14)        
  .
  .
  The lines goes few thousands.

我累了Fredirk的code和它工作正常选择的线路。好了,现在我想这个想法延伸到我的实际问题。

I tired Fredirk's code and it works fine for selecting the lines. Well, now I would like to extend this idea to my real problem.

在$ 3我的数据文件重新present有如下安排号分子(第三场)和$ 6(6场):

The $3 (3rd field) and $6 (6th field) in my data file represent "number-molecule" which has arrangement as below:

   1    2   3   4   5   6   7       8

   9    10  11  12  13  14  15      16
  17    18  19  20  21  22  23      24
  25    26  27  28  29  30  31      32
  33    34  35  36  37  38  39      40
  41    42  43  44  45  46  47      48
  49    50  51  52  53  54  55      56

  57    58  59  60  61  62  63      64 

从上面的数字做任何对实际重新在数据文件中的每一行的第3和第6场presents对。

Any pairs made from above numbers actually represents pairs in the 3rd and 6th field of each line in the data file.

我要的是只选择由设置在上述排序的最外层线路编号进行的对。

What I want is to select the pairs made only by numbers which arranged at the outer most lines of the above ordering.

 In short, ANY PAIRS made by only the numbers  (1 2 3 4 5 6 7 8   57 58 59 60 61 62 63 64   1 9 17 25 33 41 49 57   8 16 24 32 40 48 56 64) are need to be deleted.

我不知道如何编写AWK code回路选择那些对和删除线,立竿见影。

I have no idea how to write loop in awk code to select those pairs and delete the lines straight away.

我想说非常感谢在前进。

I wish to say many thanks in advance.

推荐答案

使用一个数组来保存的一组数字。它定义在BEGIN块

Use an array to hold the set of numbers. Define it in the BEGIN block

BEGIN {
  i=0
  for (n=1; n<=8; n++) set[i++] = n
  for (n=57; n<=64; n++) set[i++] = n
  for (n=9; n<=49; n+=8) {set[i++] = n; set[i++] = n+7}
}

然后,检查$ 90和$ 6一起在(或不在)是集:

Then, check that $3 and $6 are both in (or not in) the set:

($3 in set) && ($6 in set) {next}

这篇关于从删除数据文件选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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