File tree Expand file tree Collapse file tree
main/java/org/biojava/nbio/core/alignment/matrices
test/java/org/biojava/nbio/core/alignment/matrices Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626
2727public interface AAIndexProvider {
2828
29- public SubstitutionMatrix <AminoAcidCompound > getMatrix (String matrixName );
29+ /**
30+ * Gets a substitution matrix by its name. The matrices are defined in
31+ {@code}src/main/resources/matrices/AAINDEX.txt{@code}
32+ * @param matrixName
33+ * @return The @{code}SubstitutionMatrix{@code} or null if not exists
34+ */
35+ SubstitutionMatrix <AminoAcidCompound > getMatrix (String matrixName );
3036}
Original file line number Diff line number Diff line change @@ -42,9 +42,7 @@ public class DefaultAAIndexProvider implements AAIndexProvider {
4242
4343 public DefaultAAIndexProvider (){
4444
45-
4645 InputStream inStream = getInputStreamToAAindexFile ();
47-
4846 AAIndexFileParser parser = new AAIndexFileParser ();
4947
5048 try {
@@ -54,14 +52,11 @@ public DefaultAAIndexProvider(){
5452 }
5553
5654 matrices = parser .getMatrices ();
57-
5855 }
5956
6057 @ Override
6158 public SubstitutionMatrix <AminoAcidCompound > getMatrix (String matrixName ) {
62-
6359 return matrices .get (matrixName );
64-
6560 }
6661
6762 public InputStream getInputStreamToAAindexFile (){
Original file line number Diff line number Diff line change 1+ package org .biojava .nbio .core .alignment .matrices ;
2+
3+ import org .biojava .nbio .core .alignment .template .SubstitutionMatrix ;
4+ import org .biojava .nbio .core .sequence .compound .AminoAcidCompound ;
5+ import org .biojava .nbio .core .sequence .compound .AminoAcidCompoundSet ;
6+ import org .biojava .nbio .core .sequence .compound .NucleotideCompound ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ import static org .junit .jupiter .api .Assertions .*;
10+
11+ class DefaultAAIndexProviderTest {
12+
13+ private static final String BENS940102 = "BENS940102" ;
14+
15+ DefaultAAIndexProvider provider = new DefaultAAIndexProvider ();
16+ @ Test
17+ void newAAIndexProviderReturnsNullIfNotExists (){
18+ assertNull (provider .getMatrix ("unknown" ));
19+ }
20+
21+ @ Test
22+ void aaIndexProviderGetByName (){
23+ SubstitutionMatrix <AminoAcidCompound > matrix = provider .getMatrix (BENS940102 );
24+ assertNotNull (matrix );
25+ assertEquals (BENS940102 , matrix .getName ());
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments