| 1 |
package dna; |
| 2 |
import java.util.Arrays; |
| 3 |
|
| 4 |
|
| 5 |
public class MotifMulti extends Motif { |
| 6 |
|
| 7 |
public MotifMulti(String name_, Motif...args){ |
| 8 |
super(name_, args[0].length, args[0].center); |
| 9 |
commonLetters=Arrays.toString(args); |
| 10 |
sub=args; |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
@Override |
| 15 |
public boolean matchesExactly(byte[] source, int a){ |
| 16 |
for(int i=0; i<sub.length; i++){ |
| 17 |
Motif m=sub[i]; |
| 18 |
if(m.matchesExactly(source, a)){ |
| 19 |
return true; |
| 20 |
} |
| 21 |
} |
| 22 |
return false; |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
@Override |
| 27 |
public boolean matchesExtended(byte[] source, int a){ |
| 28 |
for(int i=0; i<sub.length; i++){ |
| 29 |
Motif m=sub[i]; |
| 30 |
if(m.matchesExtended(source, a)){ |
| 31 |
return true; |
| 32 |
} |
| 33 |
} |
| 34 |
return false; |
| 35 |
} |
| 36 |
|
| 37 |
@Override |
| 38 |
public float normalize(double strength){ |
| 39 |
return (float)strength; |
| 40 |
|
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
@Override |
| 45 |
public float matchStrength(byte[] source, int a){ |
| 46 |
float max=0; |
| 47 |
for(int i=0; i<sub.length; i++){ |
| 48 |
Motif m=sub[i]; |
| 49 |
float temp=m.matchStrength(source, a); |
| 50 |
temp=m.normalize(temp); |
| 51 |
max=max(max, temp); |
| 52 |
} |
| 53 |
return max; |
| 54 |
} |
| 55 |
|
| 56 |
@Override |
| 57 |
public int numBases() { |
| 58 |
return sub[0].numBases(); |
| 59 |
} |
| 60 |
|
| 61 |
public final Motif[] sub; |
| 62 |
|
| 63 |
} |