Sponsored Content
Operating Systems Linux Problem with my loop and awk script Post 302921774 by vuvuzelo on Monday 20th of October 2014 09:00:00 AM
Old 10-20-2014
Thanks to everyone who helped me out in the past with this problem, but I seem to have found another error - not in the script kindly provided but in hindsight I should've thought this through better. My apologies to all for re-opening this thread, please let me know if I need to open a nee thread?

I did not think that my regions of interest might not be in one block, but actually broken up, an example is shown below:

Code:
Sample	Chr	bp	p	value
id1	chr1	26073240	0.000000	1
id1	chr1	26073242	0.000000	1
id1	chr1	26075748	0.000000	1
id1	chr1	26075769	0.000000	1
id1	chr1	26075787	0.000000	1
id1	chr1	26079982	0.000000	1
id1	chr1	26080019	0.000000	1
id1	chr1	26080052	0.000000	1
id1	chr1	26085161	0.000000	1
id1	chr1	26085191	0.000000	1
id1	chr1	26090437	0.000000	1
id1	chr1	26098259	0.000000	1
id1	chr1	26204597	0.000000	1
id1	chr1	26204623	0.000000	1
id1	chr1	26204770	0.000000	1
id1	chr1	26207499	0.000000	1
id1	chr1	26207507	0.000000	1
id1	chr1	26207550	0.000000	1
id1	chr1	26209126	0.000000	1
id1	chr1	26209180	0.000000	1
id1	chr1	26210208	0.000000	1
id1	chr1	26210236	0.000000	1
id1	chr1	26210298	0.000000	1
id1	chr1	26210308	0.000000	1
id1	chr1	26210309	0.000000	1
id1	chr1	26210311	0.000000	1

The previous script gave me the following output:

Code:
id1	chr1	26073240 26210311 1.37071

However, on line 12 (excl headers) there is a massive gap, how can I change my script to reflect the following:

Code:
id1	chr1	26073240  26098259  0.25019
id1	chr1	26204597  26210311  0.05714

I have made numerous attempts, but dork here cannot figure it out. Any help would be greatly assisted.

Thanks a million

vuvuzelo
Moderator's Comments:
Mod Comment You start a CODE tag with [CODE] and end a CODE tag with[/CODE].

Last edited by Don Cragun; 10-20-2014 at 02:57 PM.. Reason: Fix CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script loop problem

I am writing a shell script that simulates the `wc -w` command without actually using wc itself. My problem is that the script will only read the first line of the file and just keep looping through it. I have tried both while and for loops and got the same result. Can anyone help? ... (1 Reply)
Discussion started by: MaxMouse
1 Replies

2. Shell Programming and Scripting

awk and loop problem

Good morning, Sir's i would like to ask for help regarding to my awk and loop problem, a script that will check my files a and b then if it will see there was a time below 3am it will echo the file that contains below 3am file, for this example it will redirect the file a to an output. $ cat a... (3 Replies)
Discussion started by: invinzin21
3 Replies

3. Shell Programming and Scripting

problem in while loop in a script

i have a script that will read each line and then grep a particular pattern and do some_stuff. Below the script while read j do q1=0 q1=`$j | grep 'INFO - LPBatch:' | wc -l` if then $j | tr -s " " | cut -d " " -f8,42,43 >> nav1.txt fi q2=0 q2=`$j | grep 'INFO - Number of Intervals... (12 Replies)
Discussion started by: ali560045
12 Replies

4. Shell Programming and Scripting

Problem with while loop in shell script

Hi All, How to read a file upto last line(End Of Line) I wrote below program: cat R2_20060719.610.txt | while read LINE do echo "$LINE" done above code reading all lines from a file and skipping last line...... is there anything wrong in my code. Please help me out from this... (20 Replies)
Discussion started by: rkrgarlapati
20 Replies

5. Shell Programming and Scripting

while loop problem in c shell script

Hi all, i write a script c shell set i = 1 while ( $i <= $#array ) echo "$array" @ i++ end i want to set it to i = i +2 in that statement . Can anybody help me? ---------- Post updated at 02:46 PM ---------- Previous update was at 02:35 PM ---------- anybody not how to solve it??? (2 Replies)
Discussion started by: proghack
2 Replies

6. UNIX for Dummies Questions & Answers

simple script with while loop getting problem

Hello forum memebers. can you correct the simple while program. #! /bin/ksh count=10 while do echo $count count='expr$count-1' done I think it will print 10 to 1 numbers but it running for indefinite times. (2 Replies)
Discussion started by: rajkumar_g
2 Replies

7. Shell Programming and Scripting

Problem passing a search pattern to AWK inside a script loop

Learning, stumbling! My progress in shell scripting is slow. Now I have this doubt: I have the following file (users.txt): AU0909,on AU0309,off AU0209,on AU0109,off And this file (userson.txt) AU0909 AU0209 AU0109 AU0309 I just want to set those users on userson.txt to "off" in... (14 Replies)
Discussion started by: quinestor
14 Replies

8. Shell Programming and Scripting

Problem Using If & For loop in AWK Command

I am parsing file for the fields using awk command, first i check 26th field for two characters using substr function if it matches then using for loop on array i search 184th field for 4 chars if it matches then i print the required fields but on execution i get the error, please help...... (5 Replies)
Discussion started by: siramitsharma
5 Replies

9. Shell Programming and Scripting

PERL script loop problem

I have written the below PERL script to reprocess messages from a failure queue. It basically browses all the messages in the failure queue to individual files in a directory and then scans those files to determine the originating queue. The script will then move each message in turn from the... (0 Replies)
Discussion started by: chris01010
0 Replies

10. UNIX for Dummies Questions & Answers

Awk: problem for loop through variable

Hi, input: AAA|1 my script (the function is just an example): gawk 'BEGIN{FS=OFS="|"} function repeat(str, n, rep, i){ for(i=1; i<=n; i++) rep=rep str return rep } { variable_1=repeat($1,$2) variable_2=repeat($1,$2+1) variable_3=repeat($1,$2+3) ... (5 Replies)
Discussion started by: beca123456
5 Replies
IDS2NGRAM(1)						User Contributed Perl Documentation					      IDS2NGRAM(1)

NAME
ids2ngram - generate n-gram data file from ids file SYNOPSIS
ids2ngram [option]... ids_file... DESCRIPTION
ids2ngram generates idngram file, which is a sorted [id1,..,idN,freq] array, from binary id stream files. Here, the id stream files are always generated by mmseg or slmseg. Basically, it finds all occurrence of n-words tuples (i.e. the tuple of (id1,..,idN)), and sorts these tuples by the lexicographic order of the ids make up the tuples, then write them to specified output file. INPUT
The input file is presented as a binary id stream, which looks like: [id0,...,idX] OPTIONS
All the following options are mandatory. -n,--NMax N Generates N-gram result. ids2ngram does only support uni-gram, bi-gram, and trigram, so any number not in the range of 1..3 is not valid. -s,--swap swap-file Specify the temporary intermediate file. -o, --out output-file Specify the result idngram file, e.g. the array of [id1, ..., idN, freq] -p, --para N Specify the maximum n-gram items per paragraph. ids2ngram writes to the temporary file on a per-paragraph basis. Every time it writes a paragraph out, it frees the corresponding memory allocated for it. When your computer system permits, a higher N is suggested. This can speed up the processing speed because of less I/O. EXAMPLE
Following example will use three input idstream file idsfile[1,2,3] to generate the idngram file all.id3gram. Each para (internal map size or hash size) would be 1024000, using swap file for temp result. All temp para result would eventually be merged to got the final result. ids2ngram -n 3 -s /tmp/swap -o all.id3gram -p 1024000 idsfile1 idsfile2 idsfile3 AUTHOR
Originally written by Phill.Zhang <phill.zhang@sun.com>. Currently maintained by Kov.Chai <tchaikov@gmail.com>. SEE ALSO
mmseg(1), slmseg(1), slmbuild (1). perl v5.14.2 2012-06-09 IDS2NGRAM(1)
All times are GMT -4. The time now is 06:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy