Sponsored Content
Top Forums Shell Programming and Scripting using perl to calculate frequency and multiply Post 302303239 by cdfd123 on Thursday 2nd of April 2009 07:50:26 AM
Old 04-02-2009
using perl to calculate frequency and multiply

Suppose u have two input files FILE A and FILE B

FILE A


AACD
ABBD
ACBC


FILE B

s/ A B C D E
A 1 -2 3 4 2
B 3 2 -1 2 1
C 2 3 1 2 3
D 3 4 -3 2 2
E 1 3 4 2 3

So in FILE A we have calculated frequency at 1st position i.e.
A will be 1
then frequency at 2nd position A is 0.3
B is 0.3 ....C is 0.3
again frequency at 3rd position for C is 0.62
for B is 0.3 ...so on.......


Then at first position is frequency of A multiplied with (second FILE B)
A B C D E
1*1 1*-2 1*3 1*4 1*2


Similarily at 2nd position is frequency of A (0.3) multiplied with second file (A*A) + frequency of B(0.3) multiplied with second file (B*A) + frequency of C(0.3)multiplied with second file (C*A) then again frequency of A (0.3) multiplied with second file (A*B) + frequency of B(0.3) multiplied with second file (B*B) + frequency of C(0.3)multiplied with second file (C*B)...and similarily calculated upto C, D,E

that is
A B C D E
2nd position 0.3*1+ 0.3 *-2 ...
..... 0.3*0.3+ + 0.3*2
..... 0.3*0.2 + 0.3*3

Therefore final output will be like
pos A B C D E
Ist 1 -2 3 4 2
2nd 1.8 0.9 ............
3rd .......so on...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can use the perl or other command line to calculate the length of the character?

For example, if I have the file whose content are: >HWI-EAS382_30FC7AAXX:7:1:927:1368 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA >HWI-EAS382_30FC7AAXX:7:1:924:1373 ACGAACTTTAAAGCACCTCTTGGCTCGTATGCCGTC I want my output calculate the total length of nucleotide. So my output should look like this:... (1 Reply)
Discussion started by: patrick chia
1 Replies

2. Shell Programming and Scripting

All I want to do is Multiply...

All I want to do is find 5!. read num num={1..5} while do f= done echo f Error Msg. line 5: ${1..5} bad substitution line 6: integer expression expected Line 5 is the num=... Line 6 is the "while" statement I am new at this, and I am really, really trying. Please... (14 Replies)
Discussion started by: Ccccc
14 Replies

3. UNIX for Dummies Questions & Answers

How to calculate frequency distributions?

Hello, I'm trying to get lists of the frequency distributions for each of two variables (vars C and N in the examples). I'd like the distribution for each variable to range from the min of the two variables to the max of the two variables. I can work out the max value beforehand by ordering the... (2 Replies)
Discussion started by: auburn
2 Replies

4. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

5. Programming

perl - calculate the number of lines from particular files

Hi, plz see the below code. here my aim is to calculate the number of lines in unprocessedData.out if this file contains 40 lines then lastly $linenum should print 40.(except blank lines) i have tried below code but it giving me the output only one. can anyone help me how to do ? ... (9 Replies)
Discussion started by: pspriyanka
9 Replies

6. Shell Programming and Scripting

Perl- Finding average "frequency" of occurrence of duplicate lines

Hello, I am working with a perl script that tries to find the average "frequency" in which lines are duplicated. So far I've only managed to find the way to count how many times the lines are repeated, the code is as follows: perl -ae' my $filename= $ENV{'i'}; open (FILE, "$filename") or... (10 Replies)
Discussion started by: acsg
10 Replies

7. Shell Programming and Scripting

Calculate average from CSV file using PERL script

Hi All I have this csv file and I need to calculate the average of FPS. FPS:27.7420, Interval:1314184238772 FPS:25.9798, Interval:1314184242646 FPS:27.4772, Interval:1314184246311 FPS:26.1623, Interval:1314184250159 FPS:26.4515, Interval:1314184253972 FPS:31.5896, Interval:1314184257163... (24 Replies)
Discussion started by: sayachop
24 Replies

8. Shell Programming and Scripting

Letter Frequency Decryption Program in Perl

Hello, :/ (0 Replies)
Discussion started by: jvr42
0 Replies

9. Shell Programming and Scripting

Calculate time difference between pst and pdt dates in perl

Hi, how to calculate the time difference between PST date and PDT date in perl scripting. date1: Mon Dec 31 16:00:01 PST 2015 date2: Tue Mar 19 06:09:30 PDT 2013 and also difference between PST-PST and PDT-PDT need difference in months or days (months prefereble). (3 Replies)
Discussion started by: praveen265
3 Replies

10. Shell Programming and Scripting

Perl script to calculate failure ratio

Hello geeks, Find below a Perl script am writing to calculate some failure rate in our GPRS network, am just starting to use perl for scripting. #!/usr/bin/perl #Script written to calculate the following: #PDP activation failure rate for every 15 minutes interval #Number of Active PDP... (1 Reply)
Discussion started by: infinitydon
1 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 12:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy