Visit Our UNIX and Linux User Community


Code for count the frequency of interacting pairs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Code for count the frequency of interacting pairs
# 1  
Old 02-20-2013
Code for count the frequency of interacting pairs

Hi all,

I am trying to analyze my data, and I will need your experience.

I have some files with the below format:

Code:
  res1 = TYR res2 = ASN 
  res1 = ASP res2 = SER
  res1 = TYR res2 = ASN
  res1 = THR res2 = LYS 
  res1 = THR res2 = TYR

etc (many lines)

I am trying to find the frequency of the above interacting pairs.
The list of this residues are (lets say aminoacids.in):

Code:
  ALA
  ARG
  ASN
  ASP
  CYS
  GLN
  GLU
  GLY
  HIS
  ILE
  LEU
  LYS
  MET
  PHE
  PRO
  SER
  THR
  TRP
  TYR
  VAL

So, the output file will be sth like this (example):

Code:
  TYR – ASN = 50 times
  THR – TYR = 39 times

Etc…

Any ideas??
Thank you in advance J
# 2  
Old 02-20-2013
Blank

I am completely blank on this..

Please provide some more details. Smilie
This User Gave Thanks to pamu For This Post:
# 3  
Old 02-20-2013
You could start with:
Code:
awk '{a[$3 " - " $6]++}END{ for (i in a) print i, "=", a[i]}'

This User Gave Thanks to user8 For This Post:
# 4  
Old 02-20-2013
The third and the sixth columns have a three letter code for the aminoacids. I have more than 1000 lines of these pairs, and I am trying to calculate how many times these pairs are seen in the file.
In my example, the first and the third line are the same so the result is:
res1 = TYR res2 = ASN : 2 times I hope I helped you Smilie

---------- Post updated at 03:06 PM ---------- Previous update was at 03:02 PM ----------

I must learn to use awk!!! Thank you user8 and pamu Smilie

user8 thank you so much, it works Smilie

Previous Thread | Next Thread
Test Your Knowledge in Computers #611
Difficulty: Easy
You can enter the Python interpreter by simply typing python on the command line (assume Python is installed).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Frequency Count of chunked data

Dear all, I have an AWK script which provides frequency of words. However I am interested in getting the frequency of chunked data. This means that I have already produced valid chunks of running text, with each chunk on a line. What I need is a script to count the frequencies of each string. A... (4 Replies)
Discussion started by: gimley
4 Replies

2. Shell Programming and Scripting

Count frequency of unique values in specific column

Hi, I have tab-deliminated data similar to the following: dot is-big 2 dot is-round 3 dot is-gray 4 cat is-big 3 hot in-summer 5 I want to count the frequency of each individual "unique" value in the 1st column. Thus, the desired output would be as follows: dot 3 cat 1 hot 1 is... (5 Replies)
Discussion started by: owwow14
5 Replies

3. Shell Programming and Scripting

frequency count using shell

Hello everyone, please consider the following lines of a matrix 59 32 59 32 59 32 59 32 59 32 59 32 59 32 60 32 60 33 60 33 60 33 60 33 60 33 60 33 60 33 60 33 60 33 (7 Replies)
Discussion started by: xshang
7 Replies

4. Shell Programming and Scripting

count frequency of words in a file

I need to write a shell script "cmn" that, given an integer k, print the k most common words in descending order of frequency. Example Usage: user@ubuntu:/$ cmn 4 < example.txt :b: (3 Replies)
Discussion started by: mohit_iitk
3 Replies

5. UNIX for Dummies Questions & Answers

awk code to process column pairs and find those with more than 1 set of possible values

Hi, I have a very wide dataset with pairs of columns starting from column 7 onwards (see example below). 0 123456 -1 0 0 -9 0 0 1 2 2 2 1 1 1 1 2 2... 0 123457 -1 0 0 -9 1 2 1 1 2 2 0 0 0 0 2 2... 0 123458 -1 0 0 -9 0 0 1 2 2 2 1 1 2 2 1 2... 0 123459 -1 0 0 -9 1 2 0 0 2 2 1 1 1 2 1 1...... (2 Replies)
Discussion started by: kasan0
2 Replies

6. Shell Programming and Scripting

Code for making image pairs for BOS

Hi guys, Those who work with Background Oriented Schlieren (BOS) might wonder how to create image pairs suitable for a PIV image processing software. Here is the code : #!/bin/bash # This is a program to read *.jpg files and save them in pairs for postprocessing nfiles=`ls -1 bild*... (0 Replies)
Discussion started by: chirag.joshi
0 Replies

7. Shell Programming and Scripting

Help with checking reference data frequency count

reference data GHTAS QER CC N input data NNWQERPROEGHTASTTTGHTASNCC Desired output GHTAS 2 QER 1 CC 1 N 3 (2 Replies)
Discussion started by: perl_beginner
2 Replies

8. Shell Programming and Scripting

Code for giving the frequency of numbers appearing in rows

I have a data file that has 6 columns and I have sorted the 3rd column so that all rows are sorted according to the 3rd column (from lowest to highest number). An example is shown below: 7563 273 1 -15.81100000 25.37250000 -19.27320000 8149 294 1 -17.90540000 ... (3 Replies)
Discussion started by: ananyob
3 Replies

9. Shell Programming and Scripting

Interacting with two BASH shells

Hi. I'm working with two BASH shells in order to perform two tasks. For simplicity, suppose that at Shell #1 I'm executing this program: sleep 100 whose PID is 263. Meanwhile Shell #2 is waiting for its termination to follow with a second one. I tried with: wait 263 # Script for second... (4 Replies)
Discussion started by: hresquivelo
4 Replies

10. Shell Programming and Scripting

Count field frequency in a '|' delimited file

I have a large file with fields delimited by '|', and I want to run some analysis on it. What I want to do is count how many times each field is populated, or list the frequency of population for each field. I am in a Sun OS environment. Thanks, - CB (3 Replies)
Discussion started by: ChicagoBlues
3 Replies

Featured Tech Videos