import java.io.File;
import java.io.FileInputStream;
+import java.io.InputStream;
+import org.forester.io.parsers.FastaParser;
import org.forester.io.parsers.GeneralMsaParser;
import org.forester.msa.Msa;
import org.forester.msa.MsaMethods;
System.exit( 0 );
}
Msa msa = null;
- msa = GeneralMsaParser.parse( new FileInputStream( in ) );
+ final InputStream is = new FileInputStream( in );
+ if ( FastaParser.isLikelyFasta( in ) ) {
+ msa = FastaParser.parseMsa( is );
+ }
+ else {
+ msa = GeneralMsaParser.parse( is );
+ }
if ( cla.isOptionSet( FROM_OPTION ) ) {
singleCalc( in, from, to, msa );
}
}
private static void printHelp() {
- ForesterUtil.printProgramInformation( PRG_NAME, PRG_DESC, PRG_VERSION, PRG_DATE, E_MAIL, WWW, ForesterUtil.getForesterLibraryInformation() );
+ ForesterUtil.printProgramInformation( PRG_NAME,
+ PRG_DESC,
+ PRG_VERSION,
+ PRG_DATE,
+ E_MAIL,
+ WWW,
+ ForesterUtil.getForesterLibraryInformation() );
System.out.println( "Usage:" );
System.out.println();
System.out.println( PRG_NAME + " <options> <msa input file>" );
step = 1;
}
final double id_ratios[] = new double[ msa.getLength() ];
- for( int i = 0; i <= msa.getLength() - 1; ++i ) {
+ for( int i = 0; i <= ( msa.getLength() - 1 ); ++i ) {
id_ratios[ i ] = MsaMethods.calculateIdentityRatio( msa, i );
}
String min_pos = "";
String max_pos = "";
double min = 1;
double max = 0;
- for( int i = 0; i <= msa.getLength() - 1; i += step ) {
- int to = i + window - 1;
+ for( int i = 0; i <= ( msa.getLength() - 1 ); i += step ) {
+ int to = ( i + window ) - 1;
if ( to > ( msa.getLength() - 1 ) ) {
to = msa.getLength() - 1;
}