Sponsored Content
Operating Systems Linux Comparing specific columns between two files Post 302956312 by Syeda Sumayya on Tuesday 29th of September 2015 01:38:42 AM
Old 09-29-2015
Comparing specific columns between two files

Dear All,

I have two files. File-A having 5 columns and File-B having 2 columns.
I want to match 4th column of file-A with both columns of file-B and print all contents of file-A + the matching lines of file-B as output.

file-A
Code:
30.00   12      gi|49483390|ref|YP_040614.1|    DIP-29721N|refseq:NP_683750|uniprot:Q8R418      2e-08
30.00   13      gi|49484704|ref|YP_041928.1|    DIP-33449N|uniprot:Q8WZ42       3e-09
30.00   16      gi|49483425|ref|YP_040649.1|    DIP-23879N|refseq:NP_650366|uniprot:Q9VFJ3      4e-06
30.00   17      gi|49484107|ref|YP_041331.1|    DIP-46805N|uniprot:P70388       1e-06
30.00   21      gi|49482259|ref|YP_039483.1|    DIP-25107N|refseq:NP_495440     2e-15
30.00   22      gi|49482976|ref|YP_040200.1|    DIP-22713N|refseq:NP_524108     1e-06
30.00   26      gi|49483184|ref|YP_040408.1|    DIP-17056N|refseq:NP_651605     1e-09
30.00   31      gi|49484099|ref|YP_041323.1|    DIP-29200N|refseq:NP_005436|uniprot:Q9UQE7      6e-12

flle-B
Code:
DIP-10000N|refseq:NP_417192|uniprotkb:P30131    DIP-31848N|uniprotkb:P0A9B2
DIP-10000N|refseq:NP_417192|uniprotkb:P30131    DIP-36429N|uniprotkb:P0AAM7
DIP-10001N|refseq:NP_418748|uniprotkb:P39377    DIP-10001N|refseq:NP_418748|uniprotkb:P39377
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-10003N|refseq:NP_290325|uniprotkb:P29209
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-10149N|refseq:NP_417877|uniprotkb:P06993
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-10397N|refseq:NP_416719|uniprotkb:P06996
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-10467N|refseq:NP_415423|uniprotkb:P09373
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-10557N|refseq:NP_416344|uniprotkb:P23865
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-10573N|refseq:NP_414736|uniprotkb:P16659
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-10783N|refseq:NP_417800|uniprotkb:P02359
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-11097N|refseq:NP_290066|uniprotkb:P28242
DIP-10003N|refseq:NP_290325|uniprotkb:P29209    DIP-11354N|refseq:NP_415140|uniprotkb:P39177

Is it possible? I'd be highly thankful if someone can help me.

Last edited by Syeda Sumayya; 09-29-2015 at 03:18 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Comparing Columns of two FIles

Dear all, I have two files in UNIX File1 and File2 as below: File1: 1,1234,.,67.897,,0 1,4134,.,87.97,,4 0,1564,.,97.8,,1 File2: 2,8798,.,67.897,,0 2,8879,.,77.97,,4 0,1564,.,97.8,,1 I want to do the following: (1) Make sure that both the files have equal number of columns and if... (1 Reply)
Discussion started by: ggopal
1 Replies

2. Shell Programming and Scripting

Comparing Columns of two FIles

Dear all, I have two files in UNIX File1 and File2 as below: File1: 1,1234,.,67.897,,0 1,4134,.,87.97,,4 0,1564,.,97.8,,1 File2: 2,8798,.,67.897,,0 2,8879,.,77.97,,4 0,1564,.,97.8,,1 I want to do the following: (1) Make sure that both the files have equal number of columns and if... (4 Replies)
Discussion started by: ggopal
4 Replies

3. Shell Programming and Scripting

comparing the columns in two files

I have two files file1 and file 2 both are having multiple coloumns.i want to select only two columns. i used following code to get the desired columns,with ',' as delimiter cut -d ',' -f 1,2 file1 | sort > file1.new cut -d ',' -f 1,2 file2 | sort > file2.new I want to get the coloums... (1 Reply)
Discussion started by: bab123
1 Replies

4. Shell Programming and Scripting

comparing 2 columns from 2 files

Hey, I have 2 files that have a name and then a number: File 1: dog 21 dog 24 cat 33 cat 27 dog 76 cat 65 File 2: dog 109 dog 248 cat 323 cat 207 cat 66 (2 Replies)
Discussion started by: dcfargo
2 Replies

5. UNIX for Dummies Questions & Answers

Comparing 2 columns from 2 files

Hi, I have two files with the same number of columns. Basically I want to print the 2 columns that match between the two files. File1 looks like this: dr12 12 6 abn dr14 12 7 abn File2 looks something like this: dr12 12 8 abn dr12 14 7 abn So basically if the first... (1 Reply)
Discussion started by: kylle345
1 Replies

6. UNIX for Dummies Questions & Answers

Comparing columns in two files

Hi, I have two files. File1.txt has 2 columns and looks like: 458739 122345 4456 122657 34200 122600 File2.txt has many columns with column 1 the same as column2 of File1.txt, but with lot more rows: 122786 abcdefg user1@email 122778 uuhjeufh user2@email... (1 Reply)
Discussion started by: ursaan
1 Replies

7. Shell Programming and Scripting

comparing two columns from two different files

Hello, I have two files as 1.txt and 2.txt with number as columns. 1.txt 0 53.7988 1 -30.0859 2 20.1632 3 14.2135 4 14.6366 5 -37.6258 . . . 31608 -8.57333 31609 -2.58554 31610 -24.2857 2.txt (1 Reply)
Discussion started by: AKD
1 Replies

8. Shell Programming and Scripting

AWK: Comparing two columns from two different files

Hi - I have two files as follows: File 1: chr5 118464905 118465027 ENST00000514151 utr5 0 + chr5 118464903 118465118 ENST00000504031 utr5 0 + chr5 118468826 118469180 ENST00000504031 utr5 0 + chr5 118469920 118470084 ... (14 Replies)
Discussion started by: polsum
14 Replies

9. Shell Programming and Scripting

Comparing two columns from two different files

Hi, I have a single-column file1 having records like: 00AB01/11 43TG22/00 78RC09/34 ...... ...... and a second file , file 2 having two columns like 78RC09/34 1 45FD11/11 2 00AB01/11 3 43TG22/00 4 ...... ...... (8 Replies)
Discussion started by: amarn
8 Replies

10. UNIX for Advanced & Expert Users

Need help in comparing multiple columns from two files.

Hi all, I have two files as below. I need to compare field 2 of file 1 against field 1 of file 2 and field 5 of file 1 against filed 2 of file 2. If both matches , then create a result file 1 with first file data and if not matches , then create file with first fie data. Please help me in... (12 Replies)
Discussion started by: sivarajb
12 Replies
Bio::SeqFeature::Lite(3pm)				User Contributed Perl Documentation				Bio::SeqFeature::Lite(3pm)

NAME
Bio::SeqFeature::Lite - Lightweight Bio::SeqFeatureI class SYNOPSIS
# create a simple feature with no internal structure $f = Bio::SeqFeature::Lite->new(-start => 1000, -stop => 2000, -type => 'transcript', -name => 'alpha-1 antitrypsin', -desc => 'an enzyme inhibitor', ); # create a feature composed of multiple segments, all of type "similarity" $f = Bio::SeqFeature::Lite->new(-segments => [[1000,1100],[1500,1550],[1800,2000]], -name => 'ABC-3', -type => 'gapped_alignment', -subtype => 'similarity'); # build up a gene exon by exon $e1 = Bio::SeqFeature::Lite->new(-start=>1,-stop=>100,-type=>'exon'); $e2 = Bio::SeqFeature::Lite->new(-start=>150,-stop=>200,-type=>'exon'); $e3 = Bio::SeqFeature::Lite->new(-start=>300,-stop=>500,-type=>'exon'); $f = Bio::SeqFeature::Lite->new(-segments=>[$e1,$e2,$e3],-type=>'gene'); DESCRIPTION
This is a simple Bio::SeqFeatureI-compliant object that is compatible with Bio::Graphics::Panel. With it you can create lightweight feature objects for drawing. All methods are as described in Bio::SeqFeatureI with the following additions: The new() Constructor $feature = Bio::SeqFeature::Lite->new(@args); This method creates a new feature object. You can create a simple feature that contains no subfeatures, or a hierarchically nested object. Arguments are as follows: -seq_id the reference sequence -start the start position of the feature -end the stop position of the feature -stop an alias for end -name the feature name (returned by seqname()) -type the feature type (returned by primary_tag()) -primary_tag the same as -type -source the source tag -score the feature score (for GFF compatibility) -desc a description of the feature -segments a list of subfeatures (see below) -subtype the type to use when creating subfeatures -strand the strand of the feature (one of -1, 0 or +1) -phase the phase of the feature (0..2) -seq a dna or protein sequence string to attach to feature -id an alias for -name -seqname an alias for -name -display_id an alias for -name -display_name an alias for -name (do you get the idea the API has changed?) -primary_id unique database ID -url a URL to link to when rendered with Bio::Graphics -attributes a hashref of tag value attributes, in which the key is the tag and the value is an array reference of values -factory a reference to a feature factory, used for compatibility with more obscure parts of Bio::DB::GFF The subfeatures passed in -segments may be an array of Bio::SeqFeature::Lite objects, or an array of [$start,$stop] pairs. Each pair should be a two-element array reference. In the latter case, the feature type passed in -subtype will be used when creating the subfeatures. If no feature type is passed, then it defaults to "feature". Non-SeqFeatureI methods A number of new methods are provided for compatibility with Ace::Sequence, which has a slightly different API from SeqFeatureI: url() Get/set the URL that the graphical rendering of this feature will link to. add_segment(@segments) Add one or more segments (a subfeature). Segments can either be Feature objects, or [start,stop] arrays, as in the -segments argument to new(). The feature endpoints are automatically adjusted. segments() An alias for sub_SeqFeature(). get_SeqFeatures() Alias for sub_SeqFeature() get_all_SeqFeatures() Alias for sub_SeqFeature() merged_segments() Another alias for sub_SeqFeature(). stop() An alias for end(). name() An alias for seqname(). exons() An alias for sub_SeqFeature() (you don't want to know why!) display_name Title : display_name Usage : $id = $obj->display_name or $obj->display_name($newid); Function: Gets or sets the display id, also known as the common name of the Seq object. The semantics of this is that it is the most likely string to be used as an identifier of the sequence, and likely to have "human" readability. The id is equivalent to the LOCUS field of the GenBank/EMBL databanks and the ID field of the Swissprot/sptrembl database. In fasta format, the >(S+) is presumed to be the id, though some people overload the id to embed other information. Bioperl does not use any embedded information in the ID field, and people are encouraged to use other mechanisms (accession field for example, or extending the sequence object) to solve this. Notice that $seq->id() maps to this function, mainly for legacy/convenience issues. Returns : A string Args : None or a new id accession_number Title : accession_number Usage : $unique_biological_key = $obj->accession_number; Function: Returns the unique biological id for a sequence, commonly called the accession_number. For sequences from established databases, the implementors should try to use the correct accession number. Notice that primary_id() provides the unique id for the implemetation, allowing multiple objects to have the same accession number in a particular implementation. For sequences with no accession number, this method should return "unknown". Returns : A string Args : None alphabet Title : alphabet Usage : if( $obj->alphabet eq 'dna' ) { /Do Something/ } Function: Returns the type of sequence being one of 'dna', 'rna' or 'protein'. This is case sensitive. This is not called <type> because this would cause upgrade problems from the 0.5 and earlier Seq objects. Returns : a string either 'dna','rna','protein'. NB - the object must make a call of the type - if there is no type specified it has to guess. Args : none Status : Virtual desc Title : desc Usage : $seqobj->desc($string) or $seqobj->desc() Function: Sets or gets the description of the sequence Example : Returns : The description Args : The description or none location Title : location Usage : my $location = $seqfeature->location() Function: returns a location object suitable for identifying location of feature on sequence or parent feature Returns : Bio::LocationI object Args : none location_string Title : location_string Usage : my $string = $seqfeature->location_string() Function: Returns a location string in a format recognized by gbrowse Returns : a string Args : none This is a convenience function used by the generic genome browser. It returns the location of the feature and its subfeatures in the compact form "start1..end1,start2..end2,...". Use $seqfeature->location()->toFTString() to obtain a standard GenBank/EMBL location representation. clone Title : clone Usage : my $feature = $seqfeature->clone Function: Create a deep copy of the feature Returns : A copy of the feature Args : none refseq Title : refseq Usage : $ref = $s->refseq([$newseq] [,$newseqclass]) Function: get/set reference sequence Returns : current reference sequence Args : new reference sequence and class (optional) Status : Public This method will get or set the reference sequence. Called with no arguments, it returns the current reference sequence. Called with any Bio::SeqFeatureI object that provides the seq_id(), start(), end() and strand() methods. The method will generate an exception if you attempt to set the reference sequence to a sequence that has a different seq_id from the current feature. SEE ALSO
Bio::Graphics::Feature AUTHOR
Lincoln Stein <lstein@cshl.edu>. Copyright (c) 2006 Cold Spring Harbor Laboratory This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty. perl v5.14.2 2012-03-02 Bio::SeqFeature::Lite(3pm)
All times are GMT -4. The time now is 11:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy