/* reads a weight matrix from the specified file,
    inserts it into the database with the specified name and
    version, and returns its dbid.  This means that the file may contain
    only a single weight matrix*/
public static int insertWMFromFile(String species, String wmname, String wmversion, String wmtype, String wmfile, String bgFreq) 
  throws SQLException, NotFoundException, UnknownRoleException, FileNotFoundException, ParseException, IOException {
    WeightMatrix matrix;
    if (wmtype.matches(".*TAMO.*")) {
      matrix = PWMParser.readTamoMatrix(wmfile);
    } else if (wmtype.matches(".*MEME.*")) {
      matrix = PWMParser.readMemeMatrix(wmfile);
    } else if (wmtype.matches(".*SEQ.*")) { 
      matrix = PWMParser.readAlignedSequenceMatrix(wmfile);
    } else if (wmtype.matches(".*TRANSFAC.*")) {
      //TODO add a method to read a single transfac matrix
      matrix = PWMParser.readTRANSFACFreqMatrices(wmfile, wmversion).get(0);
    } else if (wmtype.matches(".*PRIORITY.*")) {
      matrix = PWMParser.parsePriorityBestOutput(wmfile);
    } else if (wmtype.toUpperCase().matches(".*GIMME.*")) {
        matrix = PWMParser.readGimmeMotifsMatrices(wmfile,wmversion,wmtype).get(0);
    } else {
      System.err.println("Didn't see a program I recognize in the type.  defaulting to reading TAMO format");
      matrix = PWMParser.readTamoMatrix(wmfile);
    }
    matrix.name = wmname;
    matrix.version = wmversion;
    matrix.type = wmtype;
    matrix.speciesid = (new Species(species)).getDBID();
    return insertMatrixIntoDB(matrix);
 }
public static int insertWMFromFile(String species, String wmname, String wmversion, String wmtype, String wmfile, String bgFreq)
throws SQLException, NotFoundException, UnknownRoleException, FileNotFoundException, ParseException, IOException {
WeightMatrix matrix;
if (wmtype.matches(".*TAMO.*")) {
matrix = PWMParser.readTamoMatrix(wmfile);
} else if (wmtype.matches(".*MEME.*")) {
matrix = PWMParser.readMemeMatrix(wmfile);
} else if (wmtype.matches(".*SEQ.*")) {
matrix = PWMParser.readAlignedSequenceMatrix(wmfile);
} else if (wmtype.matches(".*TRANSFAC.*")) {
//TODO add a method to read a single transfac matrix
matrix = PWMParser.readTRANSFACFreqMatrices(wmfile, wmversion).get(0);
} else if (wmtype.matches(".*PRIORITY.*")) {
matrix = PWMParser.parsePriorityBestOutput(wmfile);
} else if (wmtype.toUpperCase().matches(".*GIMME.*")) {
matrix = PWMParser.readGimmeMotifsMatrices(wmfile,wmversion,wmtype).get(0);
} else {
System.err.println("Didn't see a program I recognize in the type. defaulting to reading TAMO format");
matrix = PWMParser.readTamoMatrix(wmfile);
}
matrix.name = wmname;
matrix.version = wmversion;
matrix.type = wmtype;
matrix.speciesid = (new Species(species)).getDBID();
return insertMatrixIntoDB(matrix);
}
public static int insertWMFromFile(String species, String wmname, String wmversion, String wmtype, String wmfile, String bgFreq)
throws SQLException, NotFoundException, UnknownRoleException, FileNotFoundException, ParseException, IOException {
WeightMatrix matrix;
if (wmtype.matches(".*TAMO.*")) {
matrix = PWMParser.readTamoMatrix(wmfile);
} else if (wmtype.matches(".*MEME.*")) {
matrix = PWMParser.readMemeMatrix(wmfile);
} else if (wmtype.matches(".*SEQ.*")) {
matrix = PWMParser.readAlignedSequenceMatrix(wmfile);
} else if (wmtype.matches(".*TRANSFAC.*")) {
//TODO add a method to read a single transfac matrix
matrix = PWMParser.readTRANSFACFreqMatrices(wmfile, wmversion).get(0);
} else if (wmtype.matches(".*PRIORITY.*")) {
matrix = PWMParser.parsePriorityBestOutput(wmfile);
} else if (wmtype.toUpperCase().matches(".*GIMME.*")) {
matrix = PWMParser.readGimmeMotifsMatrices(wmfile,wmversion,wmtype).get(0);
} else {
System.err.println("Didn't see a program I recognize in the type. defaulting to reading TAMO format");
matrix = PWMParser.readTamoMatrix(wmfile);
}
matrix.name = wmname;
matrix.version = wmversion;
matrix.type = wmtype;
matrix.speciesid = (new Species(species)).getDBID();
return insertMatrixIntoDB(matrix);
}
public static int insertWMFromFile(String species, String wmname, String wmversion, String wmtype, String wmfile, String bgFreq)
throws SQLException, NotFoundException, UnknownRoleException, FileNotFoundException, ParseException, IOException {
WeightMatrix matrix;
if (wmtype.matches(".*TAMO.*")) {
matrix = PWMParser.readTamoMatrix(wmfile);
} else if (wmtype.matches(".*MEME.*")) {
matrix = PWMParser.readMemeMatrix(wmfile);
} else if (wmtype.matches(".*SEQ.*")) {
matrix = PWMParser.readAlignedSequenceMatrix(wmfile);
} else if (wmtype.matches(".*TRANSFAC.*")) {
//TODO add a method to read a single transfac matrix
matrix = PWMParser.readTRANSFACFreqMatrices(wmfile, wmversion).get(0);
} else if (wmtype.matches(".*PRIORITY.*")) {
matrix = PWMParser.parsePriorityBestOutput(wmfile);
} else if (wmtype.toUpperCase().matches(".*GIMME.*")) {
matrix = PWMParser.readGimmeMotifsMatrices(wmfile,wmversion,wmtype).get(0);
} else {
System.err.println("Didn't see a program I recognize in the type. defaulting to reading TAMO format");
matrix = PWMParser.readTamoMatrix(wmfile);
}
matrix.name = wmname;
matrix.version = wmversion;
matrix.type = wmtype;
matrix.speciesid = (new Species(species)).getDBID();
return insertMatrixIntoDB(matrix);
}