Sponsored Content
Full Discussion: Awk-Group count of field
Top Forums Shell Programming and Scripting Awk-Group count of field Post 302278286 by patrick chia on Monday 19th of January 2009 11:36:18 PM
Old 01-20-2009
How to use the programming in UNIX to count the total G+C and the GC%?What command li

Seems like can use awk and perl command. But I don't have the idea to write the command line. Thanks for all of your advise.
For example, if I have the file whose content are:
Sample 1. ATAGCAGAGGGAGTGAAGAGGTGGTGGGAGGGAGCT
Sample 2. ACTTTTATTTGAATGTAATATTTGGGACAATTATTC
Sample 3. AAATCATGGTGGGTTTATTGATGGTTAGAAAGTTCC
All the sample above, got 36 nucleotide.

I want my output to count the G + C and GC %. So my output should look like this:
Sample 1: G+C = 21 GC%= 58.33%
Sample 2: G+C = 8 GC%=22.22%
Sample 3: G+C = 13 GC%=36.11%

Thanks and appreciate of your answer.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Grep group by and count

Hi, I have several files with same filename pattern. I want to calculate count of individual files using grep/egrep. Let me be more descriptive In directory E1 i have files like ab_20091201_12:24 ab_20091201_03:24 cd_20091201_04:16 cd_20091203_08:34 ef_20091201_06:12 ef_20091201 Now i want... (3 Replies)
Discussion started by: shounakboss
3 Replies

2. Shell Programming and Scripting

Count number of occurences of a character in a field defined by the character in another field

Hello, I have a text file with n lines in the following format (9 column fields): Example: contig00012 149606 G C 49 68 60 18 c$cccccacccccccccc^c I need to count the number of lower-case and upper-case occurences in column 9, respectively, of the... (3 Replies)
Discussion started by: s052866
3 Replies

3. Shell Programming and Scripting

how to parse with awk (using different fields), then group by a field?

When parsing multiple fields in a file using AWK, how do you group by one of the fields and parse by delimiters? to clarify If a file had tom | 223-2222-4444 , randofield ivan | 123-2422-4444 , random filed ... | and , are the delimiters ... How would you group by the social security... (4 Replies)
Discussion started by: Josef_Stalin
4 Replies

4. Shell Programming and Scripting

awk Group By and count string occurrences

Hi Gurus, I'm scratching my head over and over and couldn't find the the right way to compose this AWK properly - PLEASE HELP :confused: Input: c,d,e,CLICK a,b,c,CLICK a,b,c,CONV c,d,e,CLICK a,b,c,CLICK a,b,c,CLICK a,b,c,CONV b,c,d,CLICK c,d,e,CLICK c,d,e,CLICK b,c,d,CONV... (6 Replies)
Discussion started by: Royi
6 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Awk: count occurrence of each character for every field

Hi, let's say an input looks like: A|C|C|D A|C|I|E A|B|I|C A|T|I|B as the title of the thread explains, I am trying to get something like: 1|A=4 2|C=2|B=1|T=1 3|I=3|C=1 4|D=1|E=1|C=1|B=1 i.e. a count of every character in each field (first column of output) independently, sorted... (4 Replies)
Discussion started by: beca123456
4 Replies

6. Shell Programming and Scripting

awk to count condition in field

I am trying to confirm the counts from another code and tried the below awk, but the syntax is incorrect. Basically, outputting the counts of each condition in $8. Thank you :) awk '$8==/TYPE=snp/ /TYPE=ins/ /TYPE=del/ {count++} END{print count}'... (6 Replies)
Discussion started by: cmccabe
6 Replies

7. Shell Programming and Scripting

awk joining multiple lines based on field count

Hi Folks, I have a file with fields as follows which has last field in multiple lines. I would like to combine a line which has three fields with single field line for as shown in expected output. Please help. INPUT hname01 windows appnamec1eda_p1, ... (5 Replies)
Discussion started by: shunya
5 Replies

8. Shell Programming and Scripting

awk to remove lines where field count is greather than 1 in two fields

I am trying to remove all the lines and spaces where the count in $4 or $5 is greater than 1 (more than 1 letter). The file and the output are tab-delimited. Thank you :). file X 5811530 . G C NLGN4X 17 10544696 . GA G MYH3 9 96439004 . C ... (1 Reply)
Discussion started by: cmccabe
1 Replies

9. Shell Programming and Scripting

awk to adjust text and count based on value in field

The below awk executes as is and produces the current output. It isvery close but what Ican not seem to do is add the -exon..., the ... portion comes from $1 and the _exon is static and will never change. If there is + sign in $4 then the ... is in acending order or sequential. If there is a - in... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. UNIX for Beginners Questions & Answers

Awk: count unique elements in a field and sum their occurence across the entire file

Hi, Sure it's an easy one, but it drives me insane. input ("|" separated): 1|A,B,C,A 2|A,D,D 3|A,B,B I would like to count the occurence of each capital letters in $2 across the entire file, knowing that duplicates in each record count as 1. I am trying to get this output... (5 Replies)
Discussion started by: beca123456
5 Replies
READ(5) 							File Formats Manual							   READ(5)

NAME
read, write - transfer data from and to a file SYNOPSIS
Tread tag[2] fid[2] offset[8] count[2] Rread tag[2] fid[2] count[2] pad[1] data[count] Twrite tag[2] fid[2] offset[8] count[2] pad[1] data[count] Rwrite tag[2] fid[2] count[2] DESCRIPTION
The read request asks for count bytes of data from the file identified by fid, which must be opened for reading, starting offset bytes after the beginning of the file. Count must be less than or equal to MAXFDATA (8192, defined in <fcall.h>). The bytes are returned with the read reply message. The count field in the reply indicates the number of bytes returned. This may be less than the requested amount. If the offset field is greater than the number of bytes in the file, a count of zero will be returned. For directories, read returns an integral number of direc- tory entries exactly as in stat (see stat(5)), one for each member of the directory. The read request message must have offset and count zero modulo DIRLEN. The write request asks that count bytes of data be recorded in the file identified by fid, which must be opened for writing, starting off- set bytes after the beginning of the file. If the file has been opened append only, the data will be placed at the end of the file regard- less of offset. Directories may not be written. The write reply records the number of bytes actually written. It is usually an error if this is not the same as requested. ENTRY POINTS
Read and write messages are generated by the corresponding calls. Because of the MAXFDATA limit, more than one message may be produced by a single call. READ(5)
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy