Sponsored Content
Full Discussion: Output calculations
Top Forums Shell Programming and Scripting Output calculations Post 302933104 by cmccabe on Tuesday 27th of January 2015 03:26:49 PM
Old 01-27-2015
The input file is attached. If I run the code below:

Code:
 awk '{if(len==0){last=$4;total=$6;len=1;getline}if($4!=last){printf("%s\t%f\n", last, total/len);last=$4;total=$6;len=1}else{total+=$6;len+=1}}END{printf("%s\t%f\n", last, total/len)}' output.bam.hist.txt > average.txt

a file called average.txt results that combines all the baita that match (chr....) and calculates the average # of reads.

The first three lines of average.txt:
Code:
chr12:112884064-112884217 158.2092
chr12:112888106-112888331 220.5333
chr12:112890983-112891206 228.287

The text is the bait followed by the average # of reads, in the input file each bait is outputted over and over again in different positions and thw script combines the baits that match and calculates the #'s of each.

Is it possible to output the length of the bait, average # of reads, and the # calculated ...x coverage (3 of reads * 150/length)? Thank you Smilie.
Code:
Bait                                Length Reads     Coverage
chr12:112884064-112884217 153 158.20915 155x (158*150)/153

the formula is not needed, I was just trying to show how the coverage is calculated.

Last edited by rbatte1; 01-28-2015 at 08:18 AM.. Reason: Added CODE tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Float calculations

As expr is used for integer calculations, which command is used for float calculations. (1 Reply)
Discussion started by: sharmavr
1 Replies

2. UNIX for Dummies Questions & Answers

Time Calculations

I'm trying to have a loop print out statistics every X number of seconds. How can I add a specific number of seconds to a time variable and make a comparison? Thanks ahead of time. For example: startTime = `date +%H%M%S` currentTime = $startTime executeTime = startTime + X # X is equal... (5 Replies)
Discussion started by: Nysif Steve
5 Replies

3. Shell Programming and Scripting

ksh, calculations using bc

hi all, was wondering if there is another way to do calculations in ksh scripts other than using bc ?? i am using a script to calculate average response time and my script errors out after running for a bit. e.g code i am using : averageTime=$(print "$totalTime / $numberOfEntries" |... (2 Replies)
Discussion started by: cesarNZ
2 Replies

4. UNIX for Dummies Questions & Answers

Date Calculations

I need to be able to use the current date and calculate 7 days ago to be stored in another variable to be passed to a file in my Unix shell script. I need the date in the following format: date '+%m/%d/%Y' or 05/16/2006 How do I calculate date minus 7 days or 1 week ago? (8 Replies)
Discussion started by: mitschcg
8 Replies

5. Shell Programming and Scripting

calculations in bash

HI i have following problem, i need to use split command to split files each should be cca 700 lines but i dont know how to inplement it in the scripts becasuse each time the origin file will be various size , any body got any idea cheers (2 Replies)
Discussion started by: kvok
2 Replies

6. UNIX for Dummies Questions & Answers

help with doing calculations on data

Dear All, I have a long list like this: 337 375 364 389 443 578 1001 20100 . . . . etc I would like to substract each value from the first entry which in this case is 337 and report it in a separate column. So the expected output looks like 337 0 (10 Replies)
Discussion started by: pawannoel
10 Replies

7. UNIX for Dummies Questions & Answers

Doing calculations with bc on one field

Hello, I have to turn: Apple Inc.:325,64:329,57 into Apple Inc.:325,64:329,57:3,93 3,93=329,57-325,64. My code: cat beurs.txt | sed 's/\(*\):\(*\),*\(*\):\(*\),\(*\)/\4\.\5-\2\.\3/' beurs.txt | bc| tr '.' ',' | sed 's/^-*,/0,/' > winstmarges.txt; paste -d: beurs.txt winstmarges.txt; rm... (5 Replies)
Discussion started by: ikke008
5 Replies

8. Shell Programming and Scripting

Problem with calculations

grep Quality abc.txt | awk -F"=" '{print $2}' o/p is given as 70/70 49/70 I want in the below format (percentage format) 100% 70% help me!!!!:confused::confused::confused: ---------- Post updated at 09:59 AM ---------- Previous update was at 09:57 AM ---------- Cell 01 -... (3 Replies)
Discussion started by: nikhil jain
3 Replies

9. Shell Programming and Scripting

Number calculations

I'm writing a script that will read all the fields of a text file into an array(if they are numeric), while at the same time computing the minimum and maximum values from the file. After that I want to output the average of all the numbers in the array. The first problem I'm having is that many... (10 Replies)
Discussion started by: ksmarine1980
10 Replies

10. UNIX for Beginners Questions & Answers

Loop doing calculations

Hello. I'm writing an awk script that looks at a .csv file and calculates the weighted grade for each student based on the scores and categories in the file. I am able to get the script to run the only issue however is that the same score for each student is the same. I'm self-teaching myself the... (1 Reply)
Discussion started by: Eric7giants
1 Replies
MPSCNNPoolingAverageGradient(3) 			 MetalPerformanceShaders.framework			   MPSCNNPoolingAverageGradient(3)

NAME
MPSCNNPoolingAverageGradient SYNOPSIS
#import <MPSCNNPooling.h> Inherits MPSCNNPoolingGradient. Instance Methods (nonnull instancetype) - initWithDevice:kernelWidth:kernelHeight:strideInPixelsX:strideInPixelsY: (nullable instancetype) - initWithCoder:device: Properties NSUInteger zeroPadSizeX NSUInteger zeroPadSizeY Additional Inherited Members Detailed Description This depends on Metal.framework Specifies the filter for computing the gradient of the average pooling filter. The operation backpropagates a gradient vector using chain rule. Average pooling forward pass is defined as: out(x) = sum_{dx in Window(x)} in(s*x+dx) / N(x), where the pooling window definition 'Window(x)' follows MPSCNNPooling specification, 'N(x)' is effective pooling window size in pixels as specified in MPSCNNPoolingAverage, 's' is the pixel stride and in() is the source input image. Hence the partial derivative of the output value wrt. to the input value needed in the gradient backpropagation in MPSCNNPoolingGradient is: d out(x)/d in(y) = sum_{dx in Window(x)} delta_{s*x+dx, y} / N(x), where delta_{x,y} is the Kronecker delta symbol for which delta_{x,y} = { 1, when x == y { 0, otherwise. In practice this means that the gradient value for the destination image at pixel 'x' is the sum over these contributions coming from all pooling windows that contribute to the average pooling computation in the forward pass, multiplied by the input gradient value in the source area of the corresponding pooling window. Note: As average pooling is a linear operation of its inputs, the gradient does not depend at all on the original input values, but the original input image size is needed so that we know the limits where the input values seize to exist to inhibit accumulation of gradient values for those pixels. Therefore, as secondary input, any correctly sized image will produce correct results for the gradient backpropagation and hence it is recommended to use a temporary image of correct size (see MPSTemporaryImage) for the secondary source image parameter. Method Documentation - (nullable instancetype) initWithCoder: (NSCoder *__nonnull) aDecoder(nonnull id< MTLDevice >) device NSSecureCoding compatability See MPSKernel::initWithCoder. Parameters: aDecoder The NSCoder subclass with your serialized MPSCNNPoolingAverageGradient device The MTLDevice on which to make the MPSCNNPoolingAverageGradient Returns: A new MPSCNNPoolingAverageGradient object, or nil if failure. Reimplemented from MPSCNNPoolingGradient. - (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device(NSUInteger) kernelWidth(NSUInteger) kernelHeight(NSUInteger) strideInPixelsX(NSUInteger) strideInPixelsY Initialize a gradient average pooling filter Parameters: device The device the filter will run on kernelWidth The width of the kernel. Can be an odd or even value. kernelHeight The height of the kernel. Can be an odd or even value. strideInPixelsX The input stride (upsampling factor) in the x dimension. strideInPixelsY The input stride (upsampling factor) in the y dimension. Returns: A valid MPSCNNPoolingGradient object or nil, if failure. Reimplemented from MPSCNNPoolingGradient. Property Documentation - zeroPadSizeX [read], [write], [nonatomic], [assign] How much zero padding to apply to both left and right borders of the input image for average pooling, when using See also: edgeMode MPSImageEdgeModeClamp. For edgeMode MPSImageEdgeModeZero this property is ignored and the area outside the image is interpreted to contain zeros. The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image and its padding region, but the effect is that the normalization factor of the average computation is computed also for the zeros in the padding region. - zeroPadSizeY [read], [write], [nonatomic], [assign] How much zero padding to apply to both top and bottom borders of the input image for average pooling, when using See also: edgeMode MPSImageEdgeModeClamp. For edgeMode MPSImageEdgeModeZero this property is ignored and the area outside the image is interpreted to contain zeros. The zero padding size is used to shrink the pooling window to fit inside the area bound by the source image and its padding region, but the effect is that the normalization factor of the average computation is computed also for the zeros in the padding region. Author Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code. Version MetalPerformanceShaders-100 Thu Feb 8 2018 MPSCNNPoolingAverageGradient(3)
All times are GMT -4. The time now is 02:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy