Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to average value if they have the same annotation names? Post 302923517 by yuejian on Monday 3rd of November 2014 11:35:39 AM
Old 11-03-2014
How to average value if they have the same annotation names?

Hi I have a file like this
input_file
Code:
CR387793 -0.8
CR387793 -5.5
CR387794 -5.3
CR387795 -0.9
AR388755 -3.0
AR388755 3.8
AR388755 4.5

Each line has annotation name and its correlated value. The annotation name and the value are seperated by a space. I want to average the value if the lines have the same annotation names in the output file. In this case, there are 2 lines have CR387793 annotataion and 3 lines have AR388755 annotation in the input file, so the average value of CR387793 should be -3.15 and the average value of AR388755 should be 2.65, all the other annotation has only one unique value so it will be kept in the output file. So I am expecting the output file is like this below
output_file
Code:
CR387793 -3.15
CR387794 -5.3
CR387795 -0.9
AR388755 2.65

I have thousands of lines in my input file to be processed like the example, how can I achieve this by the Unix command. Thank you very much!

Last edited by yuejian; 11-03-2014 at 02:32 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

average value

If I have a file like this, could anyone please guide me how to find the average value in each metrix. The file has got about 130,000 metrixs. Grid-ref= 142, 235 178 182 203 240 273 295 289 293 283 262 201 176 167 187 187 246 260 282 299 312 293 276 230 191 169 ... (2 Replies)
Discussion started by: su_in99
2 Replies

2. Shell Programming and Scripting

how to average in awk

Hi, I have the data like this $1 $2 1 12 2 13 3 14 4 12 5 12 6 12 7 13 8 14 9 12 10 12 i want to compute average of $1 and $2 every 5th line (1-5 and 6-10) Please help me with awk Thank you (4 Replies)
Discussion started by: saint2006
4 Replies

3. Shell Programming and Scripting

Average in awk

Hi I am looking for an awk script which can compute average of all the fields every 5th line. The file looks: A B C D E F G H I J K L M 1 18 13 14 12 14 13 11 12 12 15 15 15 2 17 17 13 13 13 12 12 11 12 14 15 14 3 16 16 12 12 12 11 11 12 11 16 14 13 4 15 15 11 11 11 12 11 12 11... (6 Replies)
Discussion started by: saint2006
6 Replies

4. Programming

calculate average

I have a file which is 2 3 4 5 6 6 so i am writing program in C to calculate mean.. #include<stdio.h> #include<string.h> #include <math.h> double CALL mean(int n , double x) main (int argc, char **argv) { char Buf,SEQ; int i; double result = 0; FILE *fp; (3 Replies)
Discussion started by: cdfd123
3 Replies

5. Shell Programming and Scripting

Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies

6. UNIX for Dummies Questions & Answers

Help with load average?

how load average is calculated and what exactly is it difference between cpu% and load average (9 Replies)
Discussion started by: robo
9 Replies

7. UNIX for Dummies Questions & Answers

Find the average based on similar names in the first column

I have a table, say this: name1 num1 num2 num3 num4 name2 num5 num6 num7 num8 name3 num1 num3 num4 num9 name2 num8 num9 num1 num2 name2 num4 num5 num6 num4 name4 num4 num5 num7 num8 name5 num1 num3 num9 num7 name5 num6 num8 num3 num4 I want a code that will sort my data according... (4 Replies)
Discussion started by: FelipeAd
4 Replies

8. Shell Programming and Scripting

Exclude certain file names while selectingData files coming in different names in a file name called

Data files coming in different names in a file name called process.txt. 1. shipments_yyyymmdd.gz 2 Order_yyyymmdd.gz 3. Invoice_yyyymmdd.gz 4. globalorder_yyyymmdd.gz The process needs to discard all the below files and only process two of the 4 file names available ... (1 Reply)
Discussion started by: dsravanam
1 Replies

9. UNIX for Beginners Questions & Answers

Snps annotation

I have the following Snps data CHROM POS ID chr7 78599583 rs987435 chr15 33395779 rs987436 chr1 189807684 rs987437 chr20 33907909 rs987438 chr12 75664046 rs987439 and the following gene data genename name chrom strand txstart txend... (8 Replies)
Discussion started by: marwah
8 Replies

10. UNIX for Beginners Questions & Answers

Help with average calculation.

i have a file with 2 columns. i want to calculate the average of column 1 based on the values of column 2. here's how the file looks like. i want to calculate the sums of numbers corresponding to 1 and then calculate the average. same for numbers corresponding to zero. any help with a code would... (1 Reply)
Discussion started by: onerokeyz
1 Replies
Perl::Critic::Annotation(3)				User Contributed Perl Documentation			       Perl::Critic::Annotation(3)

NAME
Perl::Critic::Annotation - A "## no critic" annotation in a document. SYNOPSIS
use Perl::Critic::Annotation; $annotation = Perl::Critic::Annotation->new( -element => $no_critic_ppi_element ); $bool = $annotation->disables_line( $number ); $bool = $annotation->disables_policy( $policy_object ); $bool = $annotation->disables_all_policies(); ($start, $end) = $annotation->effective_range(); @disabled_policy_names = $annotation->disabled_policies(); DESCRIPTION
"Perl::Critic::Annotation" represents a single "## no critic" annotation in a <PPI:Document>. The Annotation takes care of parsing the annotation and keeps track of which lines and Policies it affects. It is intended to encapsulate the details of the no-critic annotations, and to provide a way for Policy objects to interact with the annotations (via a Perl::Critic::Document). INTERFACE SUPPORT
This is considered to be a non-public class. Its interface is subject to change without notice. CLASS METHODS
create_annotations( -doc => $doc ) Given a Perl::Critic::Document, finds all the "## no critic" annotations and constructs a new "Perl::Critic::Annotation" for each one and returns them. The order of the returned objects is not defined. It is generally expected that clients will use this interface rather than calling the "Perl::Critic::Annotation" constructor directly. CONSTRUCTOR
"new( -element => $ppi_annotation_element )" Returns a reference to a new Annotation object. The -element argument is required and should be a "PPI::Token::Comment" that conforms to the "## no critic" syntax. METHODS
"disables_line( $line )" Returns true if this Annotation disables $line for any (or all) Policies. "disables_policy( $policy_object )" "disables_policy( $policy_name )" Returns true if this Annotation disables $polciy_object or $policy_name at any (or all) lines. "disables_all_policies()" Returns true if this Annotation disables all Policies at any (or all) lines. If this method returns true, "disabled_policies" will return an empty list. "effective_range()" Returns a two-element list, representing the first and last line numbers where this Annotation has effect. "disabled_policies()" Returns a list of the names of the Policies that are affected by this Annotation. If this list is empty, then it means that all Policies are affected by this Annotation, and "disables_all_policies()" should return true. "element()" Returns the PPI::Element where this annotation started. This is typically an instance of PPI::Token::Comment. AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.16.3 2014-06-09 Perl::Critic::Annotation(3)
All times are GMT -4. The time now is 02:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy