Matches and mismatches in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Matches and mismatches in perl
# 1  
Old 01-22-2008
MySQL Matches and mismatches in perl

When we give an input sequence , the program should match with the pattern and give the matches and mismatches in the output.

i will give you 2 small examples. if you cant get it pls let me know.
i will try to give a clear idea.

example 1:

$a=APPLE; # let it be a pattern
$b=<STDIN>; # input sequence

suppose my input sequence ($b) is : MYAPPLES
Then the input ($b) will match with $a only from 3rd letter to 7th letter.( i.e APPLE)
i want to get out put as below:

The matching region is - - APPLE- (i.e mismatches should be shown as hiphen)

If the pattern is "MYAPPLE" and the input is "APPLEMY"

Then the output should be:

- -APPLE- -

i.e the first 2 hiphens represent gaps and last 2 hiphens represent mismatches.


Example2:
$a="agaaaagavvgglggy" # a pattern signature
$b=<STDIN>;

let the input seq is "ttttttttttagaaaagavtttggyttttttt";

here the input matches with $a only with the letters in bold : ttttttttttagaaaagavtttggyttttttt

i want to know what we can do to give input showing both matches and mismatches in the input.(mismatches in the seq should be shown as a hiphen)
That means the output should be like this:
The given sequence matches with the pattern at - - - - - - - - - - agaaaagav- - -ggy - - - - - -
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To get the exact mismatches from two csv files

Hello Guys, I am pretty new to unix shell scripting where in i need to compare two files which are comma separated files. So here i go with the file contents cty_id,grade_val,g_val_2,g_val_3 001,10,20,30 002,,,40 003,100,,10 grade_val,g_val_2,cty_id 10,20,001 41,,002 100,1,003... (4 Replies)
Discussion started by: Master_Mind
4 Replies

2. Shell Programming and Scripting

Using awk to output matches and mismatches between two files to one file

In the tab-delimited files, I am trying to match $1,$2,$3,$4,$5 in fiel1 with $1,$2,$3,$4,$5 in fiel2 and create and output file that lists what matches and what was not found (or doesn't match). However the awk below seems to skip the first line and does not produce the desired output. I think... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

Using awk to output matches between two files to one file and mismatches to two others

I am trying to output the matches between $1 of file1 to $3 of file2 into a new file match. I am also wanting to output the mismatches between those same 2 files and fields to two separate new files called missing from file1 and missing from file2. The input files are tab-delimited, but the... (9 Replies)
Discussion started by: cmccabe
9 Replies

4. Shell Programming and Scripting

Displaying the first field if the second field matches the pattern using Perl

Hi, I am trying with the below Perl command to print the first field when the second field matches the given pattern: perl -lane 'open F, "< myfile"; for $i (<F>) {chomp $i; if ($F =~ /patt$/) {my $f = (split(" ", $i)); print "$f";}} close F' dummy_file I know I can achieve the same with the... (7 Replies)
Discussion started by: royalibrahim
7 Replies

5. Shell Programming and Scripting

Perl: Counting matches

Hi, A perl newbie here so pretty sure it's something simple. Trying to figure out how to count matches with perl pattern matching. The following script opens a text data file and finds lines containing "PORT:" and I'd like to count how many of these are found. Any ideas? open(LOG,"<... (3 Replies)
Discussion started by: hdefjunkie
3 Replies

6. UNIX for Advanced & Expert Users

format mismatches

Hi I am spooling the table values in file in unix ,but the problem is date format in table 'dd/mm/yyyy' ,when strong into file 'dd-mon-yyyy'.I want the same format to loaded into files also.Any idea. $ORACLE_HOME/bin/sqlplus -S "$db"<<! | tee -a >$INFA_HOME/server/infa_shared/CTRL.log ... (1 Reply)
Discussion started by: akil
1 Replies

7. Shell Programming and Scripting

Printing between 2 matches with Perl

Can we please modify this perl one-liner to print lines between pattern1 and pattern2 in a file? Currently it prints lines till pattern2. (4 Replies)
Discussion started by: anand_bh
4 Replies

8. Shell Programming and Scripting

Perl line count if it matches a pattern

#!/usr/bin/perl use Shell; open THEFILE, "C:\galileo_integration.txt" || die "Couldnt open the file!"; @wholeThing = <THEFILE>; close THEFILE; foreach $line (@wholeThing){ if ($line =~ m/\\0$/){ @nextThing = $line; if ($line =~ s/\\0/\\LATEST/g){ @otherThing =... (2 Replies)
Discussion started by: nmattam
2 Replies

9. Shell Programming and Scripting

Compare two strings, and print lines containing mismatches

pls help me on this... and im really sorry because i really don't know where to start here... FILE1 ABC DEF 10 2 DEF GHI 11 3 GHI JKL 12 5 JKL MNO 13 7 MNO PQR 14 5 requirements: 1. The third string should only be 10 or 12 2. The fourth string should only be 2 or 3 3. Prinnt... (1 Reply)
Discussion started by: kingpeejay
1 Replies

10. Shell Programming and Scripting

how to get the pos() of 2 str matches in one loop in perl

Hello all i have this simple loop that gets me every time the match of "<#" in my string something like that : my $str ="gggg<#nnnnn#>kkkk<#ssss#>llllll"; while($str =~m/<#/g){ print pos($str); } but now i like to get another pos in the same loop iteration , i will like to get the... (1 Reply)
Discussion started by: umen
1 Replies
Login or Register to Ask a Question