Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2013
    Posts
    3

    Question Query in awk/bash

    Hi,
    I have two files:

    11.txt showing two patterns:

    ATOM 1 N SER A 1 35.092 83.194 140.076 1.00 0.00 N
    ATOM 2 CA SER A 1 35.216 83.725 138.725 1.00 0.00 C
    TER
    ENDMDL
    ATOM 1 N SER A 1 35.683 81.326 139.778 1.00 0.00 N
    ATOM 2 CA SER A 1 35.422 82.736 139.929 1.00 0.00 C
    TER
    ENDMDL

    File: c.txt

    Number of groups: 40 3.95
    Group: 0 Branches: 1
    0 001
    Centre: 001 Nodes: 1
    Group: 1 Branches: 1
    0 002
    Centre: 002 Nodes: 1
    Group: 2 Branches: 6
    0 009
    1 004
    2 008
    3 007
    4 005
    5 006
    Centre: 006 Nodes: 6
    ENDMDL is coming many times in 11.txt. I wish to retreive that pattern corresponds to the value of Id. It means, if I give input of 004 (Id) from group 2, then it should output the fourth repeat from 11. txt ending with ENDMDL.

    Id004.txt

    Group2: Id 004
    ATOM 1 N SER A 1 35.092 83.194 140.076 1.00 0.00 N
    ATOM 2 CA SER A 1 35.216 83.725 138.725 1.00 0.00 C
    TER
    ENDMDL
    So, corresponding to value of Id from c.txt, I want to retreive the repeat at the number from 11.txt.

    Please guide, how, corresponding to value of Id from c.txt, I can retreive the repeat at the number from 11.txt.
    Also, I wish to retreive these patterns in individual files based on their Id, group, centre. For example:
    group0.txt contains all patterns with Id
    group1.txt contains all patterns with Id
    group2.txt contains all patterns with Id
    One file containing patterns with corresponding to centre ID
    Id001.txt
    Id002.txt
    Id009.txt
    ............
    ............

    Thanks

  2. #2
    Join Date
    Feb 2006
    Posts
    172
    In your example, For Id-004, Read from file(c.txt) line(1 004) how did you match it to these lines from file(11.txt):
    Code:
    ATOM 1 N SER A 1 35.092 83.194 140.076 1.00 0.00 N 
    ATOM 2 CA SER A 1 35.216 83.725 138.725 1.00 0.00 C 
    TER
    ENDMDL

    To get this file(Id004.txt):
    Code:
    Group2: Id 004
    ATOM 1 N SER A 1 35.092 83.194 140.076 1.00 0.00 N 
    ATOM 2 CA SER A 1 35.216 83.725 138.725 1.00 0.00 C 
    TER
    ENDMDL

  3. #3
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,004
    You could probably simplify the process by first converting 11.txt to a file that contains one line per group.
    Code:
    i=0
    while read line1
    do
       read line2
       read ter
       read endmdl
       i=`eval $i + 1`
       echo $i $line1 $line2 $ter $endmdl
    done
    With all the data on one line, it is only a matter of selecting the line that corresponds to Id.

  4. #4
    Join Date
    Jan 2013
    Posts
    3
    Thanks a lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •