Sponsored Content
Top Forums Shell Programming and Scripting Filtering lines for column elements based on corresponding counts in another column Post 302604516 by polsum on Monday 5th of March 2012 09:21:23 AM
Old 03-05-2012
Filtering lines for column elements based on corresponding counts in another column

Hi,

I have a file like this
PHP Code:
ACC 2 2 21 aaa 
AC 443 3 22 aaa  
GCT 76 1 33 xxx 
TCG 34 2 33 aaa 
ACGT 33 1 22  ggg 
TTC 99 3 44 wee 
CCA 33 2 33 ggg 
AAC 1 3 55 ddd 
TTG 10 1 22 ddd 
TTGC 98 3 22 ddd 
GCT 23 1 21 sds 
GTC 23 4 32 sds
ACGT 32 2 33 vvv 
CGT 11 2 33 eee 
CCC 87 2 44 eee 
As you can see column5 has repetitive elements. I want to print the lines with highest column2 values for each repetitive element in column5.

If there are more than 1 maximum value in column2, print the line with first occurrence of column5 value with maximum column2 value

So, the desired output
PHP Code:
AC 443 3 22 aaa  
GCT 76 1 33 xxx 
ACGT 33 1 22  ggg 
TTC 99 3 44 wee 
TTGC 98 3 22 ddd 
GCT 23 1 21 sds 
ACGT 32 2 33 vvv 
CCC 87 2 44 eee 
thanks in advanceSmilieSmilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Filtering records of a file based on a value of a column

Hi all, I would like to extract records of a file based on a condition. The file contains 47 fields, and I would like to extract only those records that match a certain value in one of the columns, e.g. COL1 COL2 COL3 ............... COL47 1 XX 45 ... (4 Replies)
Discussion started by: risk_sly
4 Replies

2. Shell Programming and Scripting

Perl: filtering lines based on duplicate values in a column

Hi I have a file like this. I need to eliminate lines with first column having the same value 10 times. 13 18 1 + chromosome 1, 122638287 AGAGTATGGTCGCGGTTG 13 18 1 + chromosome 1, 128904080 AGAGTATGGTCGCGGTTG 13 18 1 - chromosome 14, 13627938 CAACCGCGACCATACTCT 13 18 1 + chromosome 1,... (5 Replies)
Discussion started by: polsum
5 Replies

3. Shell Programming and Scripting

Remove lines based on column value

Hi All, I just need a quick fix here. I need to delete all lines containing "." in the 6th column. Input: 1 1055498 . G T 5.46 . 1 1902377 . C T 7.80 . 1 1031540 . A G 34.01 PASS 1 ... (2 Replies)
Discussion started by: Hkins552
2 Replies

4. Shell Programming and Scripting

Filtering first file columns based on second file column

Hi friends, I have one file like below. (.csv type) SNo,data1,data2 1,1,2 2,2,3 3,3,2 and another file like below. Exclude data1 where Exclude should be treated as column name in file2. I want the output shown below. SNo,data2 1,2 2,3 3,2 Where my data1 column got removed from... (2 Replies)
Discussion started by: ks_reddy
2 Replies

5. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

6. UNIX for Dummies Questions & Answers

Merging lines based on one column

Hi, I have a file which I'd like to merge lines based on duplicates in one column while keeping the info for other columns. Let me simplify it by an example: File ESR1 ANASTROZOLE NA FDA_approved ESR1 CISPLATIN NA FDA_approved ESR1 DANAZOL agonist NA ESR1 EXEMESTANE NA FDA_approved... (3 Replies)
Discussion started by: JJ001
3 Replies

7. UNIX for Beginners Questions & Answers

Selecting lines based on the value in the 3rd column.

Hello, I have a sample data like this: A1 B1 100.00 B1 A1 100.00 A2 B2 90.80 B2 A2 90.80 A3 B3 99.07 B3 A3 99.07 A4 B4 99.00 B4 A4 99.00 A5 B5 97.13 B5 A5 99.53 . . Ax By i By Ax j each two lines are same comparison with opposite order. What I expected is... (3 Replies)
Discussion started by: nengcheng
3 Replies

8. UNIX for Beginners Questions & Answers

Filtering based on column values

Hi there, I am trying to filter a big file with several columns using values on a column with values like (AC=5;AN=10;SF=341,377,517,643,662;VRT=1). I wont to filter the data based on SF= values that are (bigger than 400) ... (25 Replies)
Discussion started by: daashti
25 Replies

9. UNIX for Beginners Questions & Answers

Filtering records of a csv file based on a value of a column

Hi, I tried filtering the records in a csv file using "awk" command listed below. awk -F"~" '$4 ~ /Active/{print }' inputfile > outputfile The output always has all the entries. The same command worked for different users from one of the forum links. content of file I was... (3 Replies)
Discussion started by: sunilmudikonda
3 Replies

10. UNIX for Beginners Questions & Answers

Add column and multiply its result to all elements of another column

Input file is as follows: 1 | 6 2 | 7 3 | 8 4 | 9 5 | 10 Output reuired (sum of the first column $1*$2) 1 | 6 | 90 2 | 7 | 105 3 | 8 | 120 4 |9 | 135 5 |10 | 150 Please enclose sample input, sample output, and code... (5 Replies)
Discussion started by: Sagar Singh
5 Replies
Bio::Seq::SimulatedRead(3pm)				User Contributed Perl Documentation			      Bio::Seq::SimulatedRead(3pm)

NAME
Bio::Seq::SimulatedRead - Read with sequencing errors taken from a reference sequence SYNOPSIS
use Bio::Seq::SimulatedRead; use Bio::PrimarySeq; # Create a reference sequence my $genome = Bio::PrimarySeq->new( -id => 'human_chr2', -seq => 'TAAAAAAACCCCTG', -desc => 'The human genome' ); # A 10-bp error-free read taken from a genome my $read = Bio::Seq::SimulatedRead->new( -reference => $genome , # sequence to generate the read from -id => 'read001', # read ID -start => 3 , # start of the read on the genome forward strand -end => 12 , # end of the read on the genome forward strand -strand => 1 , # genome strand that the read is on ); # Display the sequence of the read print $read->seq." "; # Add a tag or MID to the beginning of the read $read->mid('ACGT'); # Add sequencing errors (error positions are 1-based and relative to the # error-free MID-containing read) my $errors = {}; $errors->{'8'}->{'+'} = 'AAA'; # insertion of AAA after residue 8 $errors->{'1'}->{'%'} = 'G'; # substitution of residue 1 by a G $errors->{'4'}->{'-'} = undef; # deletion of residue 4 $read->errors($errors); # Display the sequence of the read with errors print $read->seq." "; # String representation of where the read came from and its errors print $read->desc." "; DESCRIPTION
This object is a simulated read with sequencing errors. The user can provide a reference sequence to take a read from, the position and orientation of the read on the reference sequence, and the sequencing errors to generate. The sequence of the read is automatically calculated based on this information. By default, the description of the reads contain tracking information and will look like this (Bioperl-style): reference=human_chr2 start=3 end=12 strand=-1 mid=ACGT errors=1%G,4-,8+AAA description="The human genome" or Genbank-style: reference=human_chr2 position=complement(3..12) mid=ACGT errors=1%G,4-,8+AAA description="The human genome" Creating a simulated read follows these steps: 1/ Define the read start(), end(), strand() and qual_levels() if you want quality scores to be generated. Do not change these values once set because the read will not be updated. 2/ Specify the reference sequence that the read should be taken from. Once this is done, you have a fully functional read. Do not use the reference() method again after you have gone to the next step. 3/ Use mid() to input a MID (or tag or barcode) to add to the beginning of the read. You can change the MID until you go to next step. 4/ Give sequencing error specifications using errors() as the last step. You can do that as many times as you like, and the read will be updated. AUTHOR
Florent E Angly <florent . angly @ gmail-dot-com>. Copyright (c) 2011 Florent E Angly. This library is free software; you can redistribute it under the GNU General Public License version 3. new Title : new Function : Create a new simulated read object Usage : my $read = Bio::Seq::SimulatedRead->new( -id => 'read001', -reference => $seq_obj , -errors => $errors , -start => 10 , -end => 135 , -strand => 1 , ); Arguments: -reference => Bio::SeqI, Bio::PrimarySeqI object representing the reference sequence to take the read from. See reference(). -errors => Hashref representing the position of errors in the read See errors(). -mid => String of a MID to prepend to the read. See mid(). -track => Track where the read came from in the read description? See track(). -coord_style => Define what coordinate system to use. See coord_style(). All other methods from Bio::LocatableSeq are available. Returns : new Bio::Seq::SimulatedRead object qual_levels Title : qual_levels Function : Get or set the quality scores to give to the read. By default, if your reference sequence does not have quality scores, no quality scores are generated for the simulated read. The generated quality scores are very basic. If a residue is error-free, it gets the quality score defined for good residues. If the residue has an error (is an addition or a mutation), the residue gets the quality score specified for bad residues. Call the qual_levels() method before using the reference() method. Usage : my $qual_levels = $read->qual_levels( ); Arguments: Array reference containing the quality scores to use for: 1/ good residues (e.g. 30) 2/ bad residues (e.g. 10) Returns : Array reference containing the quality scores to use. reference Title : reference Function : Get or set the reference sequence that the read comes from. Once the reference has been set, you have a functional simulated read which supports all the Bio::LocatableSeq methods. This method must be called after qual_levels() but before mid() or errors(). Usage : my $seq_obj = $read->reference(); Arguments: Bio::SeqI or Bio::PrimarySeqI object Returns : Bio::SeqI or Bio::PrimarySeqI object mid Title : mid Function : Get or set a multiplex identifier (or MID, or tag, or barcode) to add to the read. By default, no MID is used. This method must be called after reference() but before errors(). Usage : my $mid = read->mid(); Arguments: MID sequence string (e.g. 'ACGT') Returns : MID sequence string errors Title : errors Function : Get or set the sequencing errors and update the read. By default, no errors are made. This method must be called after the mid() method. Usage : my $errors = $read->errors(); Arguments: Reference to a hash of the position and nature of sequencing errors. The positions are 1-based relative to the error-free MID-containing read (not relative to the reference sequence). For example: $errors->{34}->{'%'} = 'T' ; # substitution of residue 34 by a T $errors->{23}->{'+'} = 'GG' ; # insertion of GG after residue 23 $errors->{45}->{'-'} = undef; # deletion of residue 45 Substitutions and deletions are for a single residue, but additions can be additions of several residues. An alternative way to specify errors is by using array references instead of scalar for the hash values. This allows to specify redundant mutations. For example, the case presented above would result in the same read sequence as the example below: $errors->{34}->{'%'} = ['C', 'T'] ; # substitution by a C and then a T $errors->{23}->{'+'} = ['G', 'G'] ; # insertion of G and then a G $errors->{45}->{'-'} = [undef, undef]; # deletion of residue, and again Returns : Reference to a hash of the position and nature of sequencing errors. track Title : track Function : Get or set the tracking status in the read description. By default, tracking is on. This method can be called at any time. Usage : my $track = $read->track(); Arguments: 1 for tracking, 0 otherwise Returns : 1 for tracking, 0 otherwise coord_style Title : coord_style Function : When tracking is on, define which 1-based coordinate system to use in the read description: * 'bioperl' uses the start, end and strand keywords (default), similarly to the GFF3 format. Example: start=1 end=10 strand=+1 start=1 end=10 strand=-1 * 'genbank' does only provide the position keyword. Example: position=1..10 position=complement(1..10) Usage : my $coord_style = $read->track(); Arguments: 'bioperl' or 'genbank' Returns : 'bioperl' or 'genbank' perl v5.14.2 2011-11-25 Bio::Seq::SimulatedRead(3pm)
All times are GMT -4. The time now is 10:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy