Sponsored Content
Top Forums UNIX for Dummies Questions & Answers count different characters from one column Post 302610665 by Corona688 on Wednesday 21st of March 2012 02:33:44 PM
Old 03-21-2012
Code:
$ cat data

1023 A A 56 0 ccggCcccCC
1024 T T 86 0 aaAAaAAaAa
1025 G G 125 0 tttTTttT

$ awk '{
        $5=$6;         # Set field 5 to the contents of field 6
        $6=length($5); # Set field 6 to the length of field 5
        NF=6; # Chop off everything after field 6

        # Count the different characters
        for(N=1; N<=length($5); N++) C[substr($5,N,1)]++;
        # Add each different character as a new column, and clear
        # all values in C
        for(X in C) { $(NF+1)=X"="C[X]; delete C[X] }
        print # Print every line
}' data

1023 A A 56 ccggCcccCC 10 C=3 c=5 g=2
1024 T T 86 aaAAaAAaAa 10 A=5 a=5
1025 G G 125 tttTTttT 8 T=3 t=5

$

This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

count characters in specific records

I have a text file which represents a http flow like this: HTTP/1.1 200 OK Date: Fri, 23 Jan 2009 17:16:24 GMT Server: Apache Last-Modified: Fri, 23 Jan 2009 17:08:03 GMT Accept-Ranges: bytes Cache-Control: max-age=540 Expires: Fri, 23 Jan 2009 17:21:31 GMT Vary: Accept-Encoding ... (1 Reply)
Discussion started by: littleboyblu
1 Replies

2. Shell Programming and Scripting

awk count characters, sum, and divide by another column

Hi All, I am another biologist attempting to parse a large txt file containing several million lines like: tucosnp 56762 T Y 228 228 60 23 .CcCcc,,..c.c,cc,,.C... What I need to do is get the frequency of periods (.) plus commas (,) in column 9, and populate this number into another... (1 Reply)
Discussion started by: peromhc
1 Replies

3. UNIX for Dummies Questions & Answers

Count the characters in a string

Hi all, I like to know how to get the count of each character in a given word. Using the commands i can easily get the output. How do it without using the commands ( in shell programming or any programming) if you give outline of the program ( pseudo code ) i used the following commands ... (3 Replies)
Discussion started by: itkamaraj
3 Replies

4. Shell Programming and Scripting

Count number of characters in particular column

Hi i have data like abchd 124 ldskc aattggcc each separated by tab space i want to count number of characters in 4th column and print it in new column with tabspace for every line can anyone help me how to do it. Thanks. (3 Replies)
Discussion started by: bhargavpbk88
3 Replies

5. Shell Programming and Scripting

Count specific characters at specific column positions

Hi all, I need help. I have an input text file (input.txt) like this: 21 GTGCAACACCGTCTTGAGAGG 50 21 GACCGAGACAGAATGAAAATC 73 21 CGGGTCTGTAGTAGCAAACGC 108 21 CGAAAAATGAACCCCTTTATC 220 21 CGTGATCCTGTTGAAGGGTCG 259 Now I need to count A/T/G/C numbers at each character location in column... (2 Replies)
Discussion started by: thienxho
2 Replies

6. Shell Programming and Scripting

Remove the first character from the fourth column only if the column has four characters

I have a file as follows ATOM 5181 N AMET K 406 12.440 6.552 25.691 0.50 7.37 N ATOM 5182 CA AMET K 406 13.685 5.798 25.578 0.50 5.87 C ATOM 5183 C AMET K 406 14.045 5.179 26.909 0.50 5.07 C ATOM 5184 O MET K... (14 Replies)
Discussion started by: hasanabdulla
14 Replies

7. Shell Programming and Scripting

Count characters after a line

Hi All! I would like to solve a problem but I have no clue of how do it!I will be grateful if someone could help me! I have a file like this: > genes | transcript ...sequence.... >ENSMUSG00000006638|ENSMUST00000006814 GGGAAATGGAATACCCCTACACAACCAAGATGCTGAGTTCCTCCCTGAGCCCGCAAAACG... (2 Replies)
Discussion started by: giuliangiuseppe
2 Replies

8. Shell Programming and Scripting

Read first column and count lines in second column using awk

Hello all, I would like to ask your help here: I've a huge file that has 2 columns. A part of it is: sorted.txt: kss23 rml.67lkj kss23 zhh.6gf kss23 nhd.09.fdd kss23 hp.767.88.89 fl67 nmdsfs.56.df.67 fl67 kk.fgf.98.56.n fl67 bgdgdfg.hjj.879.d fl66 kl..hfh.76.ghg fl66... (5 Replies)
Discussion started by: Padavan
5 Replies

9. Shell Programming and Scripting

Column 2 string count in Column 3

My I/p is Col1|Col2|Col3 2116209997932|POSIX INC|POSIX 2116209997933|POSIX INC|POSIX 2116210089479|POSIX INC|POSIX 2116210180502|POSIX INC|POSIX 2116210512279|POSIX INC|Aero 2116210516838|POSIX INC|POSIX 2116210534342|POSIX INC|postal 2116210534345|POSIX INC|postal ... (6 Replies)
Discussion started by: nikhil jain
6 Replies

10. Shell Programming and Scripting

Count consecutive characters

Need to count consecutive characters in a string and give the output as below i/p=aaaabbcaa o/p=a4b2c1a2 (10 Replies)
Discussion started by: prasanna2166
10 Replies
.::SWF::TextField(3pm)					User Contributed Perl Documentation				    .::SWF::TextField(3pm)

NAME
SWF::TextField - SWF TextField class SYNOPSIS
use SWF::TextField; $textfield = new SWF::TextField([$flags]); DESCRIPTION
Unlike SWF::Text objects, TextFields cannot be rotated, scaled non-proportionally, or skewed. However, TextFields can be used as form entries and they can use browser-defined fonts. NOTES
: TextField is implemented into Flash since Flash3. Most of features for TextFields are available since Flash4. Simple HTML-tags in TextField are possible since Flash5. METHODS
new SWF::TextField([$flags]); Creates a TextField object whose behaviour is dictated by "flags" (see also SWF::Constants): SWFTEXTFIELD_NOEDIT: Non-editable Textfiled SWFTEXTFIELD_PASSWORD: Obscure user input with astricts. SWFTEXTFIELD_DRAWBOX: Draw a border around TextField SWFTEXTFIELD_MULTILINE: TextFiels may contain multiple lines SWFTEXTFIELD_WORDWRAP: Warp text when text reaches TextField border SWFTEXTFIELD_NOSELECT: TextField is not selected when user clicks on it SWFTEXTFIELD_ALIGN_LEFT: Align text to the left SWFTEXTFIELD_ALIGN_RIGHT: Align text to the right SWFTEXTFIELD_ALIGN_CENTER: Align text to the center SWFTEXTFIELD_ALIGN_JUSTIFY: Justify text SWFTEXTFIELD_HTML: Add HTML markup string SWFTEXTFIELD_HASLENGTH: SWFTEXTFIELD_USEFONT: Want to embed font SWFTEXTFIELD_AUTOSIZE: Flags may be combined with the bitwise OR operation. For example: my $t = new SWF::TextField(SWFTEXTFIELD_MULTILINE | SWFTEXTFIELD_WORDWRAP); $textfield->addString($string) $textfield->addUTF8String($UTF8string) Add $string to TextField. Text is appended to the existing text. $textfield->align($alignment) $textfield->setAlignment($alignment) Set the alignment of the text in the textfield. Possible values are SWFTEXTFIELD_ALIGN_LEFT SWFTEXTFIELD_ALIGN_RIGHT SWFTEXTFIELD_ALIGN_CENTER SWFTEXTFIELD_ALIGN_JUSTIFY By default a SWF::TextField ist left aligned. $textfield->setBounds($width, $height) Sets the width and height of the textfield. $textfield->setColor($red, $green, $blue [, $alpha]) Set the color of the text. An 8 bit value for each parameter. You can use the hex or decimal notation. Even mixed. $tf->setColor(0xcc,0,0x33); $tf->setColor(204,0,51,255); $textfield->setFont($font) Sets an SWF::Font object -$font- to be used in the TextField. $textfield->setPadding($padding) Set TextField padding. $textfield->setHeight($height) Set the height of font in your textfield. $textfield->setIndentation($indentation) Set the indentation of the first line of a paragraph. $textfield->setLeftMargin($left) Sets the left margin of the textfield. $textfield->setRightMargin($right) Sets the right margin of the textfield. $textfield->setMargins($left, $right) Sets left and right margins of $textfield. $textfield->setLineSpacing($linespacing) Sets the space between lines. $textfield->setName($name) $textfield->setVariableName($name) Assigns a name to the TextField which could be used to reference the TextField within ActionScript. $textfield->addChars($string) $textfield->addUTF8Chars($UTF8string) Adds characters to a font that will be available within a textfield. $textfield->setFlags($flags) Set TextField behaviour by "flags" (see above new SWF::TextField) For example: $textfield->setFlags(SWFTEXTFIELD_PASSWORD); $textfield->setLength($length) Sets limit for user input size to $length. $textfield->setFieldHeight($height) Sets height limit for visible part of text field. If $height is set to 0, the height is calculated by used font, see setHeight() method. AUTHOR
Soheil Seyfaie (soheil at users.sourceforge.net). SEE ALSO
SWF, SWF::Action, SWF::Button, SWF::Constants, SWF::DisplayItem, SWF::Font, SWF::Movie, SWF::MovieCip, SWF::Text perl v5.14.2 2011-10-26 .::SWF::TextField(3pm)
All times are GMT -4. The time now is 09:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy