Skip to content

Commit

Permalink
new test cases for mzid 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
julianu committed Jul 12, 2024
1 parent a568536 commit 20dd8d3
Show file tree
Hide file tree
Showing 3 changed files with 13,016 additions and 45 deletions.
58 changes: 16 additions & 42 deletions src/test/java/de/mpc/pia/intermediate/IntermediateJAXBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,33 @@
import java.io.File;
import java.io.IOException;

import org.apache.log4j.Logger;
import org.junit.BeforeClass;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;

import de.mpc.pia.intermediate.xmlhandler.PIAIntermediateJAXBHandler;
import de.mpc.pia.modeller.PIAModellerTest;

public class IntermediateJAXBTest {

/** logger for this class */
private static final Logger LOGGER = Logger.getLogger(IntermediateJAXBTest.class);

private static File piaFile;


@BeforeClass
public static void setUpBeforeClass() {
piaFile = new File(PIAModellerTest.class.getResource("/55merge_mascot_tandem.pia.xml").getPath());
}

private static final Logger LOGGER = LogManager.getLogger();

@Test
public void testIntermediateJAXB() {
public void testIntermediateJAXB() throws IOException{
PIAIntermediateJAXBHandler intermediateHandler;
intermediateHandler = new PIAIntermediateJAXBHandler();

Runtime runtime = Runtime.getRuntime();
double mb = 1024*1024;
final long startTime = System.nanoTime();
final long endTime;

try {
intermediateHandler.parse(piaFile.getAbsolutePath(), null);
} catch (IOException e) {
LOGGER.error(e);
}

endTime = System.nanoTime();

assertEquals(2, intermediateHandler.getFiles().size());
assertEquals(2, intermediateHandler.getSpectraData().size());
assertEquals(2, intermediateHandler.getSearchDatabase().size());
assertEquals(2, intermediateHandler.getAnalysisSoftware().size());
assertEquals(1941, intermediateHandler.getGroups().size());
assertEquals(2131, intermediateHandler.getAccessions().size());
assertEquals(2113, intermediateHandler.getPeptides().size());
assertEquals(2478, intermediateHandler.getPSMs().size());
assertEquals(1856, intermediateHandler.getNrTrees());

LOGGER.info("Total Memory: " + runtime.totalMemory() / mb + " MB");
LOGGER.info("Used Memory: " + (runtime.totalMemory() - runtime.freeMemory()) / mb + " MB");
LOGGER.info("Free Memory: " + runtime.freeMemory() / mb + " MB");
LOGGER.info("Max Memory: " + runtime.maxMemory() / mb + " MB");
LOGGER.info("Execution time: " + ((endTime - startTime) / 1000000000.0) + " s");
File piaFile = new File(IntermediateJAXBTest.class.getResource("/55merge_mascot_tandem.pia.xml").getPath());
intermediateHandler.parse(piaFile.getAbsolutePath(), null);

assertEquals("Number of Files differ", 2, intermediateHandler.getFiles().size());
assertEquals("Number of SpectraData differ", 2, intermediateHandler.getSpectraData().size());
assertEquals("Number of SearchDatabases differ", 2, intermediateHandler.getSearchDatabase().size());
assertEquals("Number of AnalysisSoftware differ", 2, intermediateHandler.getAnalysisSoftware().size());
assertEquals("Number of Groups differ", 1941, intermediateHandler.getGroups().size());
assertEquals("Number of Accessions differ", 2131, intermediateHandler.getAccessions().size());
assertEquals("Number of Peptides differ", 2113, intermediateHandler.getPeptides().size());
assertEquals("Number of PSMs differ", 2478, intermediateHandler.getPSMs().size());
assertEquals("Number of NrTrees differ", 1856, intermediateHandler.getNrTrees());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.junit.Test;

import de.mpc.pia.intermediate.compiler.PIACompiler;
import de.mpc.pia.intermediate.compiler.PIACompilerTest;
import de.mpc.pia.intermediate.compiler.PIASimpleCompiler;
import de.mpc.pia.modeller.PIAModeller;
import de.mpc.pia.modeller.protein.inference.SpectrumExtractorInference;
Expand All @@ -28,6 +27,7 @@ public class MzIdentMLExportAndImportTest {

private File tandemIdXMLResults;
private File tandemMzidResults;
private File cometMzid12Results;
private String piaIntermediateFileName;
/** logger for this class */
private static final Logger LOGGER = Logger.getLogger(PIACompiler.class);
Expand All @@ -36,8 +36,9 @@ public class MzIdentMLExportAndImportTest {
public void setUp() {
piaIntermediateFileName = "PIACompilerTest.pia.xml";

tandemIdXMLResults = new File(PIACompilerTest.class.getResource("/merge1-tandem-fdr_filtered-015.idXML").getPath());
tandemMzidResults = new File(PIACompilerTest.class.getResource("/55merge_tandem.mzid").getPath());
tandemIdXMLResults = new File(MzIdentMLExportAndImportTest.class.getResource("/merge1-tandem-fdr_filtered-015.idXML").getPath());
tandemMzidResults = new File(MzIdentMLExportAndImportTest.class.getResource("/55merge_tandem.mzid").getPath());
cometMzid12Results = new File(MzIdentMLExportAndImportTest.class.getResource("/comet_mzid12.mzid").getPath());
}


Expand All @@ -57,6 +58,22 @@ public void testMzIdentMLv1_1_0Import() throws IOException {
}


@Test
public void testMzIdentMLv1_2_0Import() {
PIACompiler piaCompiler = new PIASimpleCompiler();

assertTrue(piaCompiler.getDataFromFile("mzid", cometMzid12Results.getAbsolutePath(), null, null));

piaCompiler.buildClusterList();
piaCompiler.buildIntermediateStructure();

piaCompiler.setName("testFile");

assertEquals("Wrong number of imported peptides", 600, piaCompiler.getNrPeptides());
assertEquals("Wrong number of imported PSMs", 610, piaCompiler.getNrPeptideSpectrumMatches());
}


@Test
public void testMzIdentMLExportAndImport() throws IOException {
PIACompiler piaCompiler = new PIASimpleCompiler();
Expand Down
Loading

0 comments on commit 20dd8d3

Please sign in to comment.