Skip to content

Commit

Permalink
move setState to TaxaCharacterMatrix<T> #512
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed Jul 31, 2024
1 parent 76fed0a commit 17da944
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ default SequenceType dataType() {
* @param position the site position in the 2nd dimension.
* @param state the state in integer
*/
void setState(int taxon, int position, int state);
void setState(int taxon, int position, Integer state);

/**
* @param taxon the name of the taxon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ public ContinuousCharacterData(Taxa taxa, Double[][] continuousCharacterData) {
this.continuousCharacterData = continuousCharacterData;
}

@Override
public Double getState(String taxonName, int column) {
return continuousCharacterData[taxa.indexOfTaxon(taxonName)][column];
}

@Override
public void setState(int taxon, int position, Double state) {
continuousCharacterData[taxon][position] = state;
}

public Double getState(int taxonIndex, int column) {
return continuousCharacterData[taxonIndex][column];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public String getFileType() {


@Override
public void setState(int taxon, int position, int state) {
public void setState(int taxon, int position, Integer state) {
throw new UnsupportedOperationException("Unsupported for FastaAlignment !");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public SimpleAlignment(int nchar, Alignment source) {
* @param position the site position in the 2nd dimension of {@link #alignment}.
* @param state the state in integer
*/
public void setState(int taxon, int position, int state) {
public void setState(int taxon, int position, Integer state) {
if (sequenceType == null)
throw new IllegalArgumentException("Please define SequenceType, not numStates !");
// TODO how to distinguish imported alignment and simulated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public interface TaxaCharacterMatrix<T> extends NChar, HasTaxa, MultiDimensional
*/
T getState(String taxon, int characterColumn);

/**
* Set int states.
* @param taxon the index of taxon in the 1st dimension.
* @param position the site position in the 2nd dimension.
* @param state the state in integer
*/
void setState(int taxon, int position, T state);

/**
* @return the class of this character (e.g. Double for continuous characters, Integer for discrete characters)
*/
Expand Down

0 comments on commit 17da944

Please sign in to comment.