rendered paste bodyimport java.io.*;
public class smithwaterman
{
private static void help()
{
System.out.println("Usage:\nEither\nsmithwaterman Patternfile1 Patternfile2 B\nOr\nsmithwaterman Patternfile1 Patternfile2 E matchscore mismatchscore gapscore\n\nWhere B uses the Blowsum Matrix for evaluation and E lets you specify which values will be applied for scoring");
System.exit(1);
}
//just a debugging function!
private static void help(int id)
{
System.out.println("Call from "+id);
System.exit(1);
}
public smithwaterman(){}//
public static void main(String[] args)
{
if(args.length<3)help();
/*
if(args[2]=="B"||args[2]=="E"){System.out.println("["+args[2]+"]");help(1);}
if(args[2]=="E"&&args.length!=6)help(2);
*/
float gap=8;//gap penality
switch(args[2].codePointAt(0))
{
case 69://let's do our own scoring
if(args.length<7)help();
edit algo=new edit(getFloat(args[3]),getFloat(args[4]));
gap=getFloat(args[5]);
break;
case 66://use Blosum Matrix
blosum algo=new blosum();
break;
default:help();
}
String A=fasFile(args[0]);
String B=fasFile(args[1]);
}
public static String fasFile(String datei)
{
BufferedReader in;
try
{
in=new BufferedReader(new FileReader(datei));
}
catch(IOException e)
{
System.out.println("Can not open file "+datei);
System.exit(1);
}
StringBuilder sb=new StringBuilder();
String line=in.readLine();//drop first line
while((line=in.readLine())!=null)
{
sb.append(line);
}
in.close();
return sb.toString();
}
static float getFloat(String i)
{
float f;
try
{
f=Float.parseFloat(i);
}
catch(NumberFormatException e)
{
System.out.println("Error: "+i+" is not a valid floating-point value!");
System.exit(1);
}
return f;
}
}