Calculate difference in comma separated coordinates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Calculate difference in comma separated coordinates
# 1  
Old 04-12-2016
Calculate difference in comma separated coordinates

Dear All,
I would like some help to process the following file

Code:
ID	n_exons	start	end
Zfp85-rs1	4	67747799,67751609,67752387,67755062,	67749722,67751705,67752514,67755134,
Taf9b	7	106206873,106209706,106216126,106218096,106218309,106218895,106219578,	106208657,106209817,106216196,106218231,106218446,106218977,106219842,
Zfp458	4	67254917,67259560,67260116,67269030,	67258144,67259656,67260243,67269068,
Zfp941	3	140809676,140818587,140822034,	140813314,140818714,140822178,

-first column is the gene name
-second is the number of exons
-third is the exons start cordinates comma separeted
-fourth is the exon end cordinates comma separated

I would like the following output
-first column gene name
-second column number of exons
-third column length

length should be the sum of the difference between the n cordinate in the fourth column with the n cordinate in the third column, example for gene name Zfp941

Code:
1st exon end	140813314
1st exon start	140809676
diff	3638
	
2nd exon end	140818714
2nd exon start	140818587
diff	127
	
3th exon end	140822178
3th exon start	140822034
diff	144
	
length	3909

Any help? The file is really big, almost 40000 row, like the number of genes in our genome,
Many Thanks,
Paolo
# 2  
Old 04-12-2016
That doesn't seem too difficult a problem. Any attempts/ideas/thoughts from your side?

Last edited by RudiC; 04-12-2016 at 09:53 AM..
# 3  
Old 04-12-2016
Thank you for your fine help,
Cheers!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to extract fields from a CSV i.e comma separated where some of the fields having comma as value?

can anyone help me!!!! How to I parse the CSV file file name : abc.csv (csv file) The above file containing data like abv,sfs,,hju,',',jkk wff,fst,,rgr,',',rgr ere,edf,erg,',',rgr,rgr I have a requirement like i have to extract different field and assign them into different... (4 Replies)
Discussion started by: J.Jena
4 Replies

2. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies

3. Shell Programming and Scripting

Need comma separated output

Hi, I am having the file with server names & its corresponding process, i need your help how to convert into comma separated output between server & app #cat apps.txt Server1 oracle was Server2 http webadmin Server3 tsm db2 My requirement is like below. Server1,oracle/was... (5 Replies)
Discussion started by: ksgnathan
5 Replies

4. UNIX for Dummies Questions & Answers

[solved] Comma separated values to space separated

Hi, I have a large number of files which are written as csv (comma-separated values). Does anyone know of simple sed/awk command do achieve this? Thanks! ---------- Post updated at 10:59 AM ---------- Previous update was at 10:54 AM ---------- Guess I asked this too soon. Found the... (0 Replies)
Discussion started by: lost.identity
0 Replies

5. Shell Programming and Scripting

Need Help - comma inside double quote in comma separated csv,

Hello there, I have a comma separated csv , and all the text field is wrapped by double quote. Issue is some text field contain comma as well inside double quote. so it is difficult to process. Input in the csv file is , 1,234,"abc,12,gh","GH234TY",34 I need output like below,... (8 Replies)
Discussion started by: Uttam Maji
8 Replies

6. Shell Programming and Scripting

Comma separated file

Hi all, I have the following files types: FileA: 100, 23, 33, FileB: 22, 45, 78, and i want to make File C: 100,22 23,45 33,78 any nice suggestions for making it easy. (3 Replies)
Discussion started by: hen1610
3 Replies

7. Shell Programming and Scripting

Finding difference in two comma separated files in UINX

Dear All, I have requirement like this: I have 2 camma seperated files file1: 1,aaa,bbb,ccc, 2,bbb,ccc,ddd, 3,ccc,ddd,eee, file2: 1,aaa,bbb,ccc, 2,bbb,ddd,ddd, 3,ccc,ddd,eee, my requirement is I should get message in the out put like: There is a difference in 3 rd filed in... (2 Replies)
Discussion started by: mymoto
2 Replies

8. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

9. Shell Programming and Scripting

Need comma separated processing

I have a file like this OUTLN OPEN Y SCOTT OPEN N USER4 OPEN Y DBSNMP EXPIRED & LOCKED N ... (4 Replies)
Discussion started by: ilugopal
4 Replies
Login or Register to Ask a Question