Sponsored Content
Top Forums UNIX for Dummies Questions & Answers help with doing calculations on data Post 302506633 by ctsgnb on Monday 21st of March 2011 12:27:03 PM
Old 03-21-2011
I missunderstood your needs : i was substracting entries $3[n]-$3[n+1] but ok i understand you want $3[0]-$3[n] instead so ...

Like this ?

Code:
# awk '{match($0,/[0-9-]+/);x=2*$3/(RLENGTH+1);print $1,$2,$3,x,(NR==1)?0:337-x}' tst
common.levure5-6-7-8_SNP_SNP_annotated.gff file_1 1348 337 0
common.levure5-6-8_SNP_SNP_annotated.gff file_2 1167 389 -52
common.levure5-6-7_SNP_SNP_annotated.gff file_3 1125 375 -38
common.levure5-7-8_SNP_SNP_annotated.gff file_4 1104 368 -31
common.levure6-7-8_SNP_SNP_annotated.gff file_5 1083 361 -24
common.levure5-6_SNP_SNP_annotated.gff file_6 952 476 -139
common.levure5-8_SNP_SNP_annotated.gff file_7 896 448 -111
common.levure5-7_SNP_SNP_annotated.gff file_8 886 443 -106
common.levure6-8_SNP_SNP_annotated.gff file_9 872 436 -99
common.levure7-8_SNP_SNP_annotated.gff file_10 862 431 -94
common.levure6-7_SNP_SNP_annotated.gff file_11 846 423 -86

If you want to avoid hardcoding the 337 :

Code:
 awk '{match($1,/[0-9-]+/);x=2*$3/(RLENGTH+1);print $0,x,(NR==1)?0:r-x}NR<2{r=x}' tst


Last edited by ctsgnb; 03-21-2011 at 02:16 PM..
This User Gave Thanks to ctsgnb For This Post:
 

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. 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

4. 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

5. 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

6. 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

7. 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

8. Shell Programming and Scripting

Output calculations

Attached are the is original output (zipped file) and a custom file using the awk code below in which the average reads per bait are calculated (average.txt) awk '{if(len==0){last=$4;total=$6;len=1;getline}if($4!=last){printf("%s\t%f\n", last,... (7 Replies)
Discussion started by: cmccabe
7 Replies

9. Shell Programming and Scripting

Linux - Calculations between multiple rows of data

Morning All, I am needing assistance with a calculation process, which performs calculations on a group of records. Here is a breakdown of my requirement: Col1 = Always same value. Col2 = Grouping Column, and will have the same value for 5/6/7 records for example. Col3 = Date Col4 =... (3 Replies)
Discussion started by: RichZR
3 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
Bio::Graphics::Glyph::hybrid_plot(3pm)			User Contributed Perl Documentation		    Bio::Graphics::Glyph::hybrid_plot(3pm)

NAME
Bio::Graphics::Glyph::hybrid_plot - An xyplot plot drawing dual graph using data from two wiggle files per track SYNOPSIS
See <Bio::Graphics::Panel> <Bio::Graphics::Glyph> and <Bio::Graphics::Glyph::wiggle_xyplot>. DESCRIPTION
Note that for full functionality this glyph requires Bio::Graphics::Glyph::generic (generic glyph is used for drawing individual matches for small RNA alignments at a high zoom level, specified by semantic zooming in GBrowse conf file) Unlike the regular xyplot, this glyph draws two overlapping graphs using value data in Bio::Graphics::Wiggle file format: track type=wiggle_0 name="Experiment" description="snRNA seq data" visibility=pack viewLimits=-2:2 color=255,0,0 altColor=0,0,255 windowingFunction=mean smoothingWindow=16 2L 400 500 0.5 2L 501 600 0.5 2L 601 700 0.4 2L 701 800 0.1 2L 800 900 0.1 ##gff-version 3 2L Sample_rnaseq rnaseq_wiggle 41 3009 . . . ID=Samlpe_2L;Name=Sample;Note=YourNoteHere;wigfileA=/datadir/track_001.2L.wig;wigfileB=/datadir/track_002.2L.wig The "wigfileA" and "wigfileB" attributes give a relative or absolute pathname to Bio::Graphics::Wiggle format files for two concurrent sets of data. Basically, these wigfiles contain the data on signal intensity (counts) for sequences aligned with genomic regions. In wigfileA these data are additive, so for each sequence region the signal is calculated as a sum of signals from overlapping matches (signal). In wigfileB the signal represents the maximum value among all sequences (signal quality) aligned with the current region so the user can see the difference between accumulated signal from overlapping multiple matches (which may likely be just a noise from products of degradation) and high-quality signal from unique sequences. It is essential that wigfile entries in gff file do not have score, because score used to differentiate between data for dual graph and data for matches (individual features visible at higher magnification). After an update to wiggle_xyplot code colors for dual plot are now hard-coded (blue for signal and orange for signal quality). Alpha channel is also handled by wiggle_xyplot code now. OPTIONS In addition to some of the wiggle_xyplot glyph options, the following options are recognized: Name Value Description ---- ----- ----------- wigfileA path name Path to a Bio::Graphics::Wiggle file for accumulated vales in 10-base bins wigfileB path name Path to a Bio::Graphics::Wiggle file for max values in 10-base bins fasta path name Path to fasta file to enable BigWig drawing u_method method name Use method of [method name] to identify individual features (like alignment matches) to show at high zoom level. By default it is set to 'match' BUGS
Please report them. SEE ALSO
Bio::Graphics::Panel, Bio::Graphics::Glyph, Bio::Graphics::Glyph::arrow, Bio::Graphics::Glyph::cds, Bio::Graphics::Glyph::crossbox, Bio::Graphics::Glyph::diamond, Bio::Graphics::Glyph::dna, Bio::Graphics::Glyph::dot, Bio::Graphics::Glyph::ellipse, Bio::Graphics::Glyph::extending_arrow, Bio::Graphics::Glyph::generic, Bio::Graphics::Glyph::graded_segments, Bio::Graphics::Glyph::heterogeneous_segments, Bio::Graphics::Glyph::line, Bio::Graphics::Glyph::pinsertion, Bio::Graphics::Glyph::primers, Bio::Graphics::Glyph::rndrect, Bio::Graphics::Glyph::segments, Bio::Graphics::Glyph::ruler_arrow, Bio::Graphics::Glyph::toomany, Bio::Graphics::Glyph::transcript, Bio::Graphics::Glyph::transcript2, Bio::Graphics::Glyph::translation, Bio::Graphics::Glyph::allele_tower, Bio::DB::GFF, Bio::SeqI, Bio::SeqFeatureI, Bio::Das, GD AUTHOR
Peter Ruzanov <pruzanov@oicr.on.ca>. Copyright (c) 2008 Ontario Institute for Cancer Research This package and its accompanying libraries is free software; you can redistribute it and/or modify it under the terms of the GPL (either version 1, or at your option, any later version) or the Artistic License 2.0. Refer to LICENSE for the full license text. In addition, please see DISCLAIMER.txt for disclaimers of warranty. perl v5.14.2 2012-02-20 Bio::Graphics::Glyph::hybrid_plot(3pm)
All times are GMT -4. The time now is 01:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy