Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Calculate e raise to the power in awk | UNIX Post 303041156 by genome on Friday 15th of November 2019 04:26:53 PM
Old 11-15-2019
Calculate e raise to the power in awk | UNIX

Input data:

Quote:
SNP MAF
10:60523:T:G 0.013
10:62010:C:T 0.01125
10:69083:C:T 0.3581
10:73537:G:A 0.005268
I'd like to calculate using value in second column. The value needs to be created using a formula, that employs exp (that is e raise to the power).

Code:
awk '{

if(FNR==1){ 
##if first line than print as is and add third column
print $0,"weight"
}

else{
if($2<=0.01){
##if MAF less than 0.01 

print $0, exp((1-$2)*25)/(1+exp((1-$2)*25))
}
else{
print $0, exp((0.5-$2)*0.5)/(1+exp((0.5-$2)*0.5))
} } }'   merged_allCHRs_headers  > merged_allCHRs_weights

I get output
Quote:
SNP MAF weight
10:60523:T:G 0.013 0.560576
10:62010:C:T 0.01125 0.560792
10:69083:C:T 0.3581 0.51773
10:73537:G:A 0.005268 1
I'd like ascertain what I'm doing is right.


Thanks
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to calculate with awk

Hi, I have below awk statement and I need to convert the second field ( substr($0,8,6))from minutes to hours with 2 decimail place. How can I achieve this? /usr/bin/awk '{print substr($0,23,4),substr($0,8,6)}' /tmp/MANAGER_LIST.$$ >> /tmp/NEWMANAGER_LIST.$$ Thanks for any help! (4 Replies)
Discussion started by: whatisthis
4 Replies

2. Shell Programming and Scripting

how can i calculate a file using awk

hi all Am new to scripting... So,i have a file named file1 its contents are as follows: joy 55 66 77 ruby 77 88 99 saloni 88 44 33 I would require a script which will calculate its percentage,its total and the average with awk script Many thanks in advance.. Please reply me at... (4 Replies)
Discussion started by: whizkidash
4 Replies

3. Shell Programming and Scripting

raise an alarm in Unix

Hi members, I am working in WebSphere in Unix environment. we are working with 500 odd servers and most of the times processes got down. Can i have any shell script through whih some popup with alarm get raised whenever some server get down. kindly help.. Thanks Rishi (1 Reply)
Discussion started by: rishi.madan
1 Replies

4. Shell Programming and Scripting

Calculate P Value -Awk

Is there any awk command to calculate P Value ?(Probability) Is it possib;e to calculate P va;ue for this data for ex? 7.891284 8.148193 7.749575 7.958188 7.887702 7.714877 8.141548 7.51845 8.27736 7.929853 7.92456 8.249126 7.989113 8.012573 8.351206 (2 Replies)
Discussion started by: stateperl
2 Replies

5. Shell Programming and Scripting

Calculate Average AWK

I want to calculate the average line by line of some files with several lines on them, the files are identical, just want to average the 3rd columns of those files.:wall: Example file: File 1 001 0.046 0.667267 001 0.047 0.672028 001 0.048 0.656025 001 0.049 ... (2 Replies)
Discussion started by: AriasFco
2 Replies

6. UNIX for Advanced & Expert Users

Unix user with root power problem in to login in putty

Hello, I created a user in my AIX 5.3 system and i modified /etc/passwd file in and assigned this user the uid=0 like root user. The problem is that when this user log into the system through putty it asks for root password instead of the user password. As a result of this, if i reset the... (4 Replies)
Discussion started by: omonoiatis9
4 Replies

7. UNIX for Dummies Questions & Answers

[Solved] To the power of using awk

Hi Guys, I got stuck to a a point where I need to find the value for (4 to the power of -2 upto 8 places after decimal .... 4^(-2) ; the result I need is upto 8 places after decimal. How is that possible? Thanks a lot!! (2 Replies)
Discussion started by: Indra2011
2 Replies
Bio::AlignIO::maf(3pm)					User Contributed Perl Documentation				    Bio::AlignIO::maf(3pm)

NAME
Bio::AlignIO::maf - Multiple Alignment Format sequence input stream SYNOPSIS
Do not use this module directly. Use it via the Bio::AlignIO class. use Bio::AlignIO; my $alignio = Bio::AlignIO->new(-fh => *STDIN, -format => 'maf'); while(my $aln = $alignio->next_aln()){ my $match_line = $aln->match_line; print $aln, " "; print $aln->length, " "; print $aln->num_residues, " "; print $aln->is_flush, " "; print $aln->num_sequences, " "; $aln->splice_by_seq_pos(1); print $aln->consensus_string(60), " "; print $aln->get_seq_by_pos(1)->seq, " "; print $aln->match_line(), " "; print " "; } DESCRIPTION
This class constructs Bio::SimpleAlign objects from an MAF-format multiple alignment file. Writing in MAF format is currently unimplemented. Spec of MAF format is here: http://genome.ucsc.edu/FAQ/FAQformat FEEDBACK
Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHORS - Allen Day Email: allenday@ucla.edu APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : my $alignio = Bio::AlignIO->new(-format => 'maf' -file => '>file', -idlength => 10, -idlinebreak => 1); Function: Initialize a new L<Bio::AlignIO::maf> reader Returns : L<Bio::AlignIO> object Args : next_aln Title : next_aln Usage : $aln = $stream->next_aln() Function: returns the next alignment in the stream. Throws an exception if trying to read in PHYLIP sequential format. Returns : L<Bio::SimpleAlign> object Args : perl v5.14.2 2012-03-02 Bio::AlignIO::maf(3pm)
All times are GMT -4. The time now is 09:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy