Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Help getting a code in awk - Want to know how much of the data is covered by entries Post 303037835 by Flebman on Wednesday 14th of August 2019 12:07:10 PM
Old 08-14-2019
Help getting a code in awk - Want to know how much of the data is covered by entries

Here is my data structure.
Code:
# id1    id2    len   start    end
# 9     16792   5475   4181     4232
# 11    16792   2317   1086     1137
# 11    32879   2317      8       60
# 11    32858   2317     10       52
# 11    30670   2317     17       63
# 14    12645    532      3       67
# 14    12645    532    158      222
# 14    11879    532      3      223
# 18    23847    644     64      285
# 18    30160    644     98      285
# 18    30160    644    345      477
# 18    30160    644    516      644

I want to get the coverage of id1 based on its length (column len) considering all entries start and end values. The problem is that the multiple entries can have juxtapose values so considering the values in all entries would overrate the coverage. Also considering the smallest start value and biggest end value doesn't account for all since it can have gaps where not all length is represented.

My expected result should be something like this
Code:
 9 --- 50 / 5475  = 0.009
11 --- 106 / 2317 = 0.046
14 --- 220 / 532  = 0.414
18 --- 481 / 644  = 0.75


Last edited by Scrutinizer; 08-14-2019 at 02:02 PM.. Reason: code tags
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

awk code to ignore the first occurence unknown number of rows in a data column

Hello experts, Shown below is the 2 column sample data(there are many data columns in actual input file), Key, Data A, 1 A, 2 A, 2 A, 3 A, 1 A, 1 A, 1 I need the below output. Key, Data A, 2 A, 2 A, 3 A, 1 A, 1 A, 1 (2 Replies)
Discussion started by: ks_reddy
2 Replies
uuencode(n)						   encode/decoding a binary file					       uuencode(n)

NAME
uuencode - encode/decoding a binary file SYNOPSIS
package require Tcl 8 package require uuencode ?1.0.1? ::uuencode::encode string ::uuencode::decode string ::uuencode::uuencode ?-name string? ?-mode octal? (-file filename | ?--? string) ::uuencode::uudecode (-file filename | ?--? string) DESCRIPTION
This package provides a Tcl-only implementation of the uuencode(1) and uudecode(1) commands. This encoding packs binary data into printable ASCII characters. ::uuencode::encode string returns the uuencoded data. This will encode all the data passed in even if this is longer than the uuencode maximum line length. If the number of input bytes is not a multiple of 3 then additional 0 bytes are added to pad the string. ::uuencode::decode string Decodes the given encoded data. This will return any padding characters as well and it is the callers responsibility to deal with handling the actual length of the encoded data. (see uuencode). ::uuencode::uuencode ?-name string? ?-mode octal? (-file filename | ?--? string) ::uuencode::uudecode (-file filename | ?--? string) UUDecode a file or block of data. A file may contain more than one embedded file so the result is a list where each element is a three element list of filename, mode value and data. OPTIONS
-filename name Cause the uuencode or uudecode commands to read their data from the named file rather that taking a string parameter. -name string The uuencoded data header line contains the suggested file name to be used when unpacking the data. Use this option to change this from the default of "data.dat". -mode octal The uuencoded data header line contains a suggested permissions bit pattern expressed as an octal string. To change the default of 0644 you can set this option. For instance, 0755 would be suitable for an executable. See chmod(1). EXAMPLES
% set d [uuencode::encode "Hello World!"] 2&5L;&@5V]R;&0A % uuencode::uudecode $d Hello World! % set d [uuencode::uuencode -name hello.txt "Hello World"] begin 644 hello.txt +2&5L;&@5V]R;&0` ` end % uuencode::uudecode $d {hello.txt 644 {Hello World}} KEYWORDS
encoding, uuencode base64 1.0.1 uuencode(n)
All times are GMT -4. The time now is 10:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy