![JAR search and dependency download from the Maven repository](/logo.png)
org.github.evenjn.align.alphabet.TupleAlignmentAlphabetSimpleBuilder Maven / Gradle / Ivy
package org.github.evenjn.align.alphabet;
import java.util.function.Consumer;
import java.util.function.Function;
import org.github.evenjn.align.graph.NotAlignableException;
import org.github.evenjn.knit.BasicAutoHook;
import org.github.evenjn.knit.KnittingCursable;
import org.github.evenjn.knit.ProgressManager;
import org.github.evenjn.yarn.AutoHook;
import org.github.evenjn.yarn.Cursable;
import org.github.evenjn.yarn.Di;
import org.github.evenjn.yarn.Hook;
import org.github.evenjn.yarn.Progress;
import org.github.evenjn.yarn.ProgressSpawner;
import org.github.evenjn.yarn.Tuple;
public class TupleAlignmentAlphabetSimpleBuilder
implements
TupleAlignmentAlphabetBuilder {
private int min_below;
private int max_below;
public TupleAlignmentAlphabetSimpleBuilder( ) {
}
@Override
public void setMinMax( int min, int max ) {
this.min_below = min;
this.max_below = max;
}
public void setPrinters(
Function> logger,
Function a_printer,
Function b_printer ) {
}
public TupleAlignmentAlphabet build(
Cursable, Tuple>> data,
ProgressSpawner progress_spawner ) {
KnittingCursable, Tuple>> kd =
KnittingCursable.wrap( data );
try ( AutoHook hook = new BasicAutoHook( ) ) {
TupleAlignmentAlphabet result =
new TupleAlignmentAlphabet( );
Progress spawn = ProgressManager.safeSpawn( hook, progress_spawner,
"TupleAlignmentAlphabetSimpleBuilder::build" );
spawn.info( "Computing dataset size." );
spawn.target( kd.size( ) );
spawn.info( "Collecting alphabet elements." );
for ( Di, Tuple> datum : kd.pull( hook )
.once( ) ) {
spawn.step( 1 );
try {
Iterable> localAlphabet =
TupleAlignmentAlphabetBuilderTools.localAlphabet(
min_below, max_below, datum.front( ), datum.back( ) );
for ( TupleAlignmentAlphabetPair pp : localAlphabet ) {
result.add( pp );
}
}
catch ( NotAlignableException e ) {
// simply ignore them.
}
}
return result;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy