Ok so lets say I have two files that are tab delimited. The file1 has 20 columns, the first column is the gene. I have a file2 who's first column is also Gene(albeit in a different order), but the second column of file2 is a value that is not in the file1. Is there a faster way to add the file2 second column to the 21st column of file1 then reading in both as arrays and matching the Gene column, then printing out the variables that I have split respective columns into?
A command line command would be preferable because the files layout are always changing.. and thus a script must be continuously altered based on splitting...
here is an example script
#!/usr/bin/perl -w
use strict;
open(FILE,"$ARGV[0]");
my @input=<FILE>;
close(FILE);
foreach my $line(@input){
chomp $line;
my @batch=();
(my $gene, my $VAA, my $ CCDS ,my $chrposMut, my $o_acc, my $o_pos
+, my $o_aa1, my $o_aa2)= split(/\t/,$line);
(my $chrpos,my $Mut)=split(/\./,$chrposMut);
my ($chr,$position)=split(/\:/,$chrpos);
my $vAA=$o_aa1 . $o_pos . $o_aa2;
$vAA=~s/\s//g;
@batch=`perl -ne 'print if /$position/' Gene_Asign.txt`; # put the
+ text file here that contains the gene name as well as something that
+ can be used to identify the correct row when comparing it with the p
+olyphen outfile
foreach my $Line(@batch)
{
chomp $Line;
# (my $snp, my $str, my $gene, my $v4, my $v5, my $CCDS)=split(
+/\t/,$Line);
#print $Line ."\n";
my($Sample,$v2)= split(/\s/,$Line);
#if($AA=~m/$vAA/){
print $Sample . "\t" . $line . "\n";
# print $gene . "\t" . $vAA . "\t" . $CCDS. "\t" . $line . "\n"
+;
# }
}
}