using perl for matching one file with another file and print into new line

One file is
fileA
0.0246*0.0068*0.0013*0.0023*0.0182*0.0028*0.0019*0.4750*0.0028*0.0812*0.0123*0.0018*0.0039*0.0020*0.0028*0.0047*0.0139*0.3330*0.0017*0.00720.4789
0.0234*0.0062*0.0013*0.0023*0.0214*0.0027*0.0021*0.2783*0.0029*0.2001*0.0141*0.0017*0.0037*0.0021*0.0030*0.0045*0.0124*0.4077*0.0019*0.0081
0.5228
0.0156*0.0045*0.0044*0.0075*0.0132*0.0037*0.0109*0.1374*0.0091*0.0489*0.5817*0.0082*0.0038*0.0765*0.0141*0.0081*0.0110*0.0288*0.0034*0.0092*0.5426

Second file is file B
I85V
L95I
I103M

So using perl, i want to get the output
I=0.4750 V=0.0017
L=0.2001 I=0.0214
I=0.1374 M=0.5817

So so for symbols having A=1,C=2,D=3,E=4,F=5,G=6,H=7,I=8.K=9,L=10,M=11,N=12,P=13,Q=14,R=15,S=16,T=17,V=18,W=19,Y=20

writing perl using Switch command..
can u further how can i do it...

#!/usr/bin/perl -w

use Switch;

print "PLEASE ENTER THE FILENAME OF THE FILE:=";
chomp($prot_psap=<STDIN>);

open(PROTFILE,$prot_psap) or die "unable to open the file";
@prot=<PROTFILE>;
close PROTFILE;
foreach $line (@prot) {

#$line ="s/*//g";
if ($line =~ s/^>//g) {
next;
}
else {
$sequence = $line;
}
$sequence  =~ s/\*/ /g;

@prota=split('',$sequence);
print @prota;
}

print "PLEASE ENTER THE FILENAME OF THE FILE:=";
chomp($mutation_file=<STDIN>);

open(MUTFILE,$mutation_file) or die "unable to open the file";
@mut=<MUTFILE>;
close MUTFILE;

foreach $line (@mut) {
if ($line =~ s/^>//g) {
next;
}
else {
$mutation = $line;
#$i=0;
}
$mutation  =~ s/[^A-Z]/ /g;


@muta=  split('',$mutation);

print @muta,"\n";
}
my %hash=(A,1,C,2,D,3,E,4,F,5,G,6,H,7,I,8,K,9,L,10,M,11,N,12,P,13,Q,14,R,15,S,16,T,17,V,18,W,19,Y,20);
open $fh,"<","a.spl";
my %hash1;
while(<$fh>){
	my @tmp=split(/\*/,$_);
	for(my $i=0;$i<=$#tmp;$i++){
		$hash1{$.}->{$i+1}=$tmp[$i];
	}
}
close $fh;
open $fh,"<","a.txt";
while(<$fh>){
	my @tmp=split("",$_);
	map {print $_,"=",$hash1{$.}->{$hash{$_}},"," if $_=~/[A-Z]/} @tmp;
	print "\n";
}
1 Like

Maybe summer cherry understood the relationship between the two files and your output, but I don't.

Thanks summercherry

Simple thing is i have one file
which is having numbers separated by *
22*23*78*72*88

and another second file contains
A222D

Whatever....