Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a question about Mathematica's SimilarityRules defining (for e.g. SequenceAlignment function). So help centre clearly stands for

SimilarityRules -> {{a_, a_} -> 1, {a_, b_} -> -1}, giving a score of +1 for any pair of identical elements, and a score of -1 for any mismatch, deletion or insertion.

Ok, I get it, but what if I want to give different score for mismatch, and different for indeles? I tried:

SimilarityRules -> {{a_, a_} -> 3, {{a_, b_} && {{a_!=""} && {b_ != ""}}} -> -8} 

and many other combination of {}, && positions, but it doesn't seem to help. Any suggestions, is it just a typo I'm doing, or it's rather a silly idea to define it like this?

share|improve this question
1  
You could add a test case (with desired output) to make the question more comprehensive. –  Yves Klett Jul 30 '13 at 8:59
add comment

1 Answer

up vote 3 down vote accepted

Have a look at /;

For instance: SimilarityRules -> {{a_, a_} -> 3, {a_ /; a != "", b_ /; b != ""} -> -8}

share|improve this answer
    
ditto the request for an example. I cant cook up anything where this produces a different result from the default. –  george2079 Jul 30 '13 at 13:52
    
! EXACTLY. Thank you so, so much, that's what I needed, Condition (/;) thing, I've never used it in Mathematica before –  Strumillo Jul 30 '13 at 14:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.