Sponsored Content
Top Forums Shell Programming and Scripting merge two text files of different size on common index Post 302518736 by LMHmedchem on Sunday 1st of May 2011 03:59:21 PM
Old 05-01-2011
I found a bug in my data where the first two files had a different header name for one header. The header row is now correct, more or less.

There still seems to be an issue in that the last column has three columns of space delimited data in it.
Code:
sumSO2Am                 SUB_ID     SOURCE                                          
0                 10584046   ChemBridge                                      
0                 10580948   ChemBridge                                      
0                 10580812   ChemBridge                                      
0                 10580337   ChemBridge                                      
0                 10579979   ChemBridge                                      
0                 10579233   ChemBridge

The last two, SUB_ID and SOURCE are duplicate cols (already occur at $3,$4). These come from $3, $4 in a2. Each row should end with the sumSO2Am field.

I don't see where that is happening in the command, or I just don't get it. I see how the first 7 fields are being printed, but not the rest of each row. I can post some short test files if that would help.

LMHmedchem
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge files of differrent size with one field common in both files using awk

hi, i am facing a problem in merging two files using awk, the problem is as stated below, file1: A|B|C|D|E|F|G|H|I|1 M|N|O|P|Q|R|S|T|U|2 AA|BB|CC|DD|EE|FF|GG|HH|II|1 .... .... .... file2 : 1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies

2. Shell Programming and Scripting

How to remove common file names from text files

I'm running on freebsd -- with a default shell of csh. I have two files named A and B. Each line of each file contains a file name. How can I write a script that removes all the file names in file B from A. I tried to use perl to create a huge regular expression with "|" separating the file... (2 Replies)
Discussion started by: siegfried
2 Replies

3. UNIX for Dummies Questions & Answers

Writing a loop to merge multiple files by common column

I have 100 data files labelled 250.1.txt through 250.100.txt. The second column of the data files partially match (there is about %90 overlap). Each data file has 4 columns. I want the merge all these text files by the matching values in the second column. In the output, the first column should... (1 Reply)
Discussion started by: evelibertine
1 Replies

4. UNIX for Dummies Questions & Answers

Merge two files with common IDs but unequal number of rows

Hi, I have two files that I would like to merge and think that there should be a solution using awk. The files look something like this: file 1 IDX1 IDY1 IDX2 IDY2 IDX3 IDY3 file 2 IDY1 dataA data1 IDY2 dataB data2 IDY3 dataC data3 Desired output IDX1 IDY1 dataA data1 IDX2 ... (5 Replies)
Discussion started by: katie8856
5 Replies

5. Shell Programming and Scripting

script to merge two files on an index

I have a need to merge two files on the value of an index column. input file 1 id filePath MDL_NUMBER 1 MFCD00008104.mol MFCD00008104 2 MFCD00012849.mol MFCD00012849 3 MFCD00037597.mol MFCD00037597 4 MFCD00064558.mol MFCD00064558 5 MFCD00064559.mol MFCD00064559 input file 2 ... (9 Replies)
Discussion started by: LMHmedchem
9 Replies

6. Shell Programming and Scripting

Merge files based on both common and uncommon rows

Hi, I have two files A (2190 rows) and file B (1100 rows). I want to merge the contents of two files based on common field, also I need the unmatched rows from file A file A: ABC XYZ PQR file B: >LMN|chr1:11000-12456: >ABC|chr15:176578-187678: >PQR|chr3:14567-15866: output... (3 Replies)
Discussion started by: Diya123
3 Replies

7. Shell Programming and Scripting

Find matched patterns in a column of 2 files with different size and merge them

Hi, i have input files like below:- input1 Name Seq_ID NewID Scores MT1 A0QZX3 1.65 277.4 IVO A0QZX3 1.65 244.5 HPO A0QZX3 1.65 240.5 RgP A0Q3PP 5.32 241.0 GX1 LPSZ3S 96.1 216.9 MEL LPSS3X 4.23 204.1 LDD LPSS3X 4.23 100.2 input2 Fac AddName NewID ... (9 Replies)
Discussion started by: redse171
9 Replies

8. Shell Programming and Scripting

Merge multiple files with common header

Hi all, Say i have multiple files x1 x2 x3 x4, all with common header (date, time, year, age),, How can I merge them to one singe file "X" in shell scripting Thanks for your suggestions. (2 Replies)
Discussion started by: msarguru
2 Replies

9. UNIX for Dummies Questions & Answers

Merge selective columns from files based on common key

Hi, I am trying to selectively merge two files based on keys reported in the 1st column. File1: #file1-header1 file1-header2 111 qwe rtz uio 198 asd fgh jkl 165 yxc 789 poi uzt rew 89 lkj File2: #file2-header2 file2-header2 165 ghz nko2 ... (2 Replies)
Discussion started by: dovah
2 Replies

10. Shell Programming and Scripting

Merge multiple tab delimited files with index checking

Hello, I have 40 data files where the first three columns are the same (in theory) and the 4th column is different. Here is an example of three files, file 2: A_f0_r179_pred.txt Id Group Name E0 1 V N(,)'1 0.2904 2 V N(,)'2 0.3180 3 V N(,)'3 0.3277 4 V N(,)'4 0.3675 5 V N(,)'5 0.3456 ... (8 Replies)
Discussion started by: LMHmedchem
8 Replies
Bio::Matrix::Generic(3pm)				User Contributed Perl Documentation				 Bio::Matrix::Generic(3pm)

NAME
Bio::Matrix::Generic - A generic matrix implementation SYNOPSIS
# A matrix has columns and rows my $matrix = Bio::Matrix::Generic->new; $matrix->add_column(1,$column1); $matrix->add_column(2,$column2); my $element = $matrix->entry_by_num(1,2); $matrix->entry_by_num(1,2,$newval); my $entry = $matrix->entry('human', 'mouse'); $matrix->entry('human','mouse', $newval); DESCRIPTION
This is a general purpose matrix object for dealing with row+column data which is typical when enumerating all the pairwise combinations and desiring to get slices of the data. Data can be accessed by column and row names or indexes. Matrix indexes start at 0. 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 - Jason Stajich Email jason-at-bioperl-dot-org APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : my $obj = Bio::Matrix::Generic->new(); Function: Builds a new Bio::Matrix::Generic object Returns : an instance of Bio::Matrix::Generic Args : -values => arrayref of arrayrefs of data initialization -rownames => arrayref of row names -colnames => arrayref of col names -matrix_id => id of the matrix -matrix_name=> name of the matrix -matrix_init_value => default value to initialize empty cells matrix_id Title : matrix_id Usage : my $id = $matrix->matrix_id Function: Get/Set the matrix ID Returns : scalar value Args : [optional] new id value to store matrix_name Title : matrix_name Usage : my $name = $matrix->matrix_name(); Function: Get/Set the matrix name Returns : scalar value Args : [optional] new matrix name value entry Title : entry Usage : my $entry = $matrix->entry($row,$col) Function: Get the value for a specific cell as specified by the row and column names Returns : scalar value or undef if row or col does not exist Args : $rowname - name of the row $colname - column name get_entry Title : get_entry Usage : my $entry = $matrix->get_entry($rowname,$columname) Function: Get the entry for a given row,column pair Returns : scalar Args : $row name $column name entry_by_num Title : entry_by_num Usage : my $entry = $matrix->entry_by_num($rownum,$colnum) Function: Get an entry by row and column numbers instead of by name (rows and columns start at 0) Returns : scalar value or undef if row or column name does not exist Args : $row - row number $col - column number [optional] $newvalue to store at this cell column Title : column Usage : my @col = $matrix->column('ALPHA'); OR $matrix->column('ALPHA', @col); Function: Get/Set a particular column Returns : Array (in array context) or arrayref (in scalar context) of values. For setting will warn if the new column is of a different length from the rest of the columns. Args : name of the column [optional] new column to store here get_column Title : get_column Usage : my @row = $matrix->get_column('ALPHA'); Function: Get a particular column Returns : Array (in array context) or arrayref (in scalar context) of values Args : name of the column column_by_num Title : column_by_num Usage : my @col = $matrix->column_by_num(1); OR $matrix->column_by_num(1,@newcol); Function: Get/Set a column by its number instead of name (cols/rows start at 0) Returns : Array (in array context) or arrayref (in scalar context) of values Args : name of the column [optional] new value to store for a particular column row Title : row Usage : my @row = $matrix->row($rowname); OR $matrix->row($rowname,@rowvalues); Function: Get/Set the row of the matrix Returns : Array (in array context) or arrayref (in scalar context) Args : rowname [optional] new value of row to store get_row Title : get_row Usage : my @row = $matrix->get_row('ALPHA'); Function: Get a particular row Returns : Array (in array context) or arrayref (in scalar context) of values Args : name of the row row_by_num Title : row_by_num Usage : my @row = $matrix->row_by_num($rownum); OR $matrix->row($rownum,@rowvalues); Function: Get/Set the row of the matrix Returns : Array (in array context) or arrayref (in scalar context) Args : rowname [optional] new value of row to store diagonal Title : diagonal Usage : my @diagonal = $matrix->get_diagonal() Function: Get the diagonal of a matrix Returns : Array (in array context) or arrayref (in scalar context) of values which lie along the diagonal Args : none add_row Title : add_row Usage : $matrix->add_row($index,@newrow); Function: Adds a row at particular location in the matrix. If $index < the rowcount will shift all the rows down by the number of new rows. To add a single empty row, simply call $matrix->add_row($index,undef); Returns : the updated number of total rows in the matrix Args : index to store name of the row (header) newrow to add, if this is undef will add a single row with all values set to undef remove_row Title : remove_row Usage : $matrix->remove_row($colnum) Function: remove a row from the matrix shifting all the rows up by one Returns : Updated number of rows in the matrix Args : row index add_column Title : add_column Usage : $matrix->add_column($index,$colname,@newcol); Function: Adds a column at particular location in the matrix. If $index < the colcount will shift all the columns right by the number of new columns. To add a single empty column, simply call $matrix->add_column($index,undef); Returns : the updated number of total columns in the matrix Args : index to store name of the column (header) newcolumn to add, if this is undef will add a single column with all values set to undef remove_column Title : remove_column Usage : $matrix->remove_column($colnum) Function: remove a column from the matrix shifting all the columns to the left by one Returns : Updated number of columns in the matrix Args : column index column_num_for_name Title : column_num_for_name Usage : my $num = $matrix->column_num_for_name($name) Function: Gets the column number for a particular column name Returns : integer Args : string row_num_for_name Title : row_num_for_name Usage : my $num = $matrix->row_num_for_name Function: Gets the row number for a particular row name Returns : integer Args : string column_header Title : column_header Usage : my $name = $matrix->column_header(0) Function: Gets the column header for a particular column number Returns : string Args : integer row_header Title : row_header Usage : my $name = $matrix->row_header(0) Function: Gets the row header for a particular row number Returns : string Args : integer num_rows Title : num_rows Usage : my $rowcount = $matrix->num_rows; Function: Get the number of rows Returns : integer Args : none num_columns Title : num_columns Usage : my $colcount = $matrix->num_columns Function: Get the number of columns Returns : integer Args : none row_names Title : row_names Usage : my @rows = $matrix->row_names Function: The names of all the rows Returns : array in array context, arrayref in scalar context Args : none column_names Title : column_names Usage : my @columns = $matrix->column_names Function: The names of all the columns Returns : array in array context, arrayref in scalar context Args : none private methods Private methods for a Generic Matrix _values Title : _values Usage : $matrix->_values(); Function: get/set for array ref of the matrix containing distance values Returns : an array reference Args : an array reference perl v5.14.2 2012-03-02 Bio::Matrix::Generic(3pm)
All times are GMT -4. The time now is 09:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy