Sponsored Content
Top Forums Shell Programming and Scripting substitution of fields based on header from another file Post 302709735 by kuin on Wednesday 3rd of October 2012 01:38:52 PM
Old 10-03-2012
substitution of fields based on header from another file

I have two files
File1 with position (chromosome:start) and individuals as header, where pos is something like 1:2000 and every individual has a value. I have many columns and rows, here an example (tab separated):

Code:
pos ind1 ind2 ind3 indn...
1:2000 0 0.1 0.1 1
1:2500 0.99 0.2 0.1 0.2
2:1000 0.5 0.1 0.2 0.4
...

File2 with no header, first column is position and then comma separated individuals

Code:
1:2000 ind2,ind3
1:2500 ind1,ind3,indn
2:1000 ind3
...

I would like an output like:

Code:
1:2000 0.1 0.1
1:2500 0.99 0.1 0.2
2:1000 0.5
...

So if individual in header of File1 matches individual in File2 for the same position substitute by its value.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with rename header content based on reference file problem

I got long list of reference file >data_tmp_number_22 >data_tmp_number_12 >data_tmp_number_20 . . Input file: >sample_data_1 Math, 5, USA, tmp SDFEWRWERWERWRWER FSFDSFSDFSDGSDGSD >sample_data_2 Math, 15, UK, tmp FDSFSDFF >sample_data_3 Math, 50, USA, tmp ARQERREQR . . Desired... (7 Replies)
Discussion started by: perl_beginner
7 Replies

2. UNIX for Dummies Questions & Answers

Changing file content based on file header

Hi, I have several text files each containing some data as shown below: File1.txt >DataHeader Data... Data... File2.txt >DataHeader Data... Data... etc. What I want is to change the 'DataHeader' based on the file name. So the output should look like: File1.txt >File1 ... (1 Reply)
Discussion started by: Fahmida
1 Replies

3. Shell Programming and Scripting

Remove the file content based on the Header of the file

Hi All, I want to remove the content based on the header information . Please find the example below. File1.txt Name|Last|First|Location|DepId|Depname|DepLoc naga|rr|tion|hyd|1|wer|opr Nava|ra|tin|gen|2|wera|opra I have to search for the DepId and remove the data from the... (5 Replies)
Discussion started by: i150371485
5 Replies

4. Shell Programming and Scripting

File comparing and appending based on fields

I want to compare 2 files, locus_file.txt is a very large file and attr.txt is a small file. I want to match the first 2 columns of the first file to the second column of attr.txt and print the attributes together. locus_file.txt:large file LOC_Os02g47020, LOC_Os03g57840,0.88725114... (3 Replies)
Discussion started by: Sanchari
3 Replies

5. Shell Programming and Scripting

Join fields in a same file based on condition

I have an input file like this... All iI want to do is If the lines are identical except for the last field i want to merge them into single line input_file I feel something is nothing I feel something is everything apple mango banana apple mango grapes I want to get output like this:... (3 Replies)
Discussion started by: raj_k
3 Replies

6. Shell Programming and Scripting

Make copy of text file with columns removed (based on header)

Hello, I have some tab delimited text files with a three header rows. The headers look like, (sorry the tabs look so messy). index group Name input input input input input input input input input input input... (9 Replies)
Discussion started by: LMHmedchem
9 Replies

7. Shell Programming and Scripting

awk sort based on difference of fields and print all fields

Hi I have a file as below <field1> <field2> <field3> ... <field_num1> <field_num2> Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields. I tried this and it doesn't sort on the difference field .. Appreciate your help. cat... (9 Replies)
Discussion started by: newstart
9 Replies

8. Shell Programming and Scripting

Split a file based on encountering header

I need to split a file based on headers found Input file file1 content: ADD john mickey DROP matt sam output of file F1 john mickey output of file F2 matt sam (5 Replies)
Discussion started by: Diddy
5 Replies

9. Shell Programming and Scripting

Find columns in a file based on header and print to new file

Hello, I have to fish out some specific columns from a file based on the header value. I have the list of columns I need in a different file. I thought I could read in the list of headers I need, # file with header names of required columns in required order headers_file=$2 # read contents... (11 Replies)
Discussion started by: LMHmedchem
11 Replies

10. UNIX for Beginners Questions & Answers

Splitting the file based on two fields - Fixed length file

Hi , I am having a scenario where I need to split the file based on two field values. The file is a fixed length file. ex: AA0998703000000000000190510095350019500010005101980301 K 0998703000000000000190510095351019500020005101480 ... (4 Replies)
Discussion started by: saj
4 Replies
Bio::Map::CytoMarker(3pm)				User Contributed Perl Documentation				 Bio::Map::CytoMarker(3pm)

NAME
Bio::Map::CytoMarker - An object representing a marker. SYNOPSIS
$o_usat = Bio::Map::CytoMarker->new(-name=>'Chad Super Marker 2', -position => $pos); DESCRIPTION
This object handles markers with a positon in a cytogenetic map known. This marker will have a name and a position. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Heikki Lehvaslaiho Email heikki-at-bioperl-dot-org CONTRIBUTORS
Chad Matsalla bioinformatics1@dieselwurks.com Lincoln Stein lstein@cshl.org Jason Stajich jason@bioperl.org Sendu Bala bix@sendu.me.uk APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ Bio::Map::MarkerI methods get_position_object Title : get_position_class Usage : my $position = $marker->get_position_object(); Function: To get an object of the default Position class for this Marker. Subclasses should redefine this method. The Position returned needs to be a L<Bio::Map::PositionI> with -element set to self. Returns : L<Bio::Map::PositionI> Args : none for an 'empty' PositionI object, optionally Bio::Map::MapI and value string to set the Position's -map and -value attributes. Comparison methods The numeric values for cutogeneic loctions go from the p tip of chromosome 1, down to the q tip and similarly throgh consecutive chromosomes, through X and end the the q tip of X. See Bio::Map::CytoPosition::cytorange for more details. New methods get_chr Title : get_chr Usage : my $mychr = $marker->get_chr(); Function: Read only method for the chromosome string of the location. A shortcut to $marker->position->chr(). Returns : chromosome value Args : [optional] new chromosome value perl v5.14.2 2012-03-02 Bio::Map::CytoMarker(3pm)
All times are GMT -4. The time now is 10:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy