Changeset 4790


Ignore:
Timestamp:
Feb 25, 2009, 9:58:48 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1243: Fix TestBioAssaySetExporter? and include it in TestAll?

Also cleaned up the code to make it more up to date regarding coding style.

Location:
trunk/src/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/test/TestAll.java

    r4740 r4790  
    156156   
    157157    // Complex tests
     158    results.put("TestBioAssaySetExporter", TestBioAsssaySetExporter.test_all());
    158159    results.put("TestBase1PluginExecuter", TestBase1PluginExecuter.test_all());
    159160    results.put("TestGenericOverview", TestGenericOverview.test_all());
  • trunk/src/test/TestBioAsssaySetExporter.java

    r4537 r4790  
    9999
    100100    int experiment = 0;
    101     int file = 0;
     101    int fileSerialNoMerge = test_createFile("serial.nomerge.txt");
     102    int fileSerialMerge = test_createFile("serial.merge.txt");
     103    int fileMatrixNoMerge = test_createFile("matrix.nomerge.txt");
     104    int fileMatrixMerge = test_createFile("matrix.merge.txt");
    102105    int bas = 0;
    103106    if (ok)
    104107    {
    105       file = test_createFile("testexport.base");
    106108      experiment = TestExperiment.test_create("genepix", false);
    107109      test_addExperimentalFactor(experiment, annotationType);
     
    110112      bas = TestExperiment.test_create_root_bioassayset_using_calculator(experiment, "medianfg", new int[] {rba1, rba2});
    111113     
    112       test_exportBaseFile(bas, file, false, false);
    113       test_exportBaseFile(bas, file, true, false);
    114       test_exportBaseFile(bas, file, false, true);
    115       test_exportBaseFile(bas, file, true, true);
    116     }
    117    
    118     if (experiment > 0)
    119       TestExperiment.test_delete(experiment);
    120     if (rba1 > 0)
    121       TestRawBioAssay.test_delete(rba1);
    122     if (rba1 > 0)
    123       TestRawBioAssay.test_delete(rba2);
    124     if (file > 0)
    125       TestFile.test_delete(file);
    126     if (annotationType > 0)
    127       TestAnnotationType.test_delete(annotationType);
     114      test_exportBaseFile(bas, fileSerialNoMerge, false, false);
     115      test_exportBaseFile(bas, fileSerialMerge, false, true);
     116      test_exportBaseFile(bas, fileMatrixNoMerge, true, false);
     117      test_exportBaseFile(bas, fileMatrixMerge, true, true);
     118    }
     119   
     120    if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
     121   
     122    TestExperiment.test_delete(experiment);
     123    TestRawBioAssay.test_delete(rba1);
     124    TestRawBioAssay.test_delete(rba2);
     125    TestFile.test_delete(fileSerialNoMerge);
     126    TestFile.test_delete(fileSerialMerge);
     127    TestFile.test_delete(fileMatrixNoMerge);
     128    TestFile.test_delete(fileMatrixMerge);
     129    TestAnnotationType.test_delete(annotationType);
    128130    test_deleteReporter(r1, r2);
    129131   
     132    write("++Testing BioAsssaySetExporter "+(ok ? "OK" : "Failed")+"\n");
    130133    return ok;
    131134  }
     
    177180        rd.setColumn(i%2);
    178181        rd.setRow((int)Math.floor(i/2));
    179         if (i < 2) rd.setReporter(r1);
    180         else rd.setReporter(r2);
     182        rd.setReporter(i < 2 ? r1 : r2);
    181183        rd.setExtended("flags", Integer.valueOf(0));
    182184        rd.setExtended("ch1FgMedian", Float.valueOf(1));
     
    416418      spotsColumns.add("assayData");
    417419      HashSet<String> spotsAssays = new HashSet<String>();
    418       for (BioAssay ba : bas.getBioAssays().list(dc)) spotsAssays.add(String.valueOf(ba.getId()));
     420      for (BioAssay ba : bas.getBioAssays().list(dc))
     421      {
     422        spotsAssays.add(String.valueOf(ba.getId()));
     423      }
    419424      Set<String> spotsCount;
    420425      if (matrix)
    421426      {
    422         if (mergeReporters) spotsCount = Collections.singleton("2");
    423         else spotsCount = Collections.singleton("6");
     427        if (mergeReporters)
     428        {
     429          spotsCount = Collections.singleton("2");
     430        }
     431        else
     432        {
     433          spotsCount = Collections.singleton("6");
     434        }
    424435      }
    425436      else
    426437      {
    427         if (mergeReporters) spotsCount = Collections.singleton("2");
    428         else spotsCount = Collections.singleton("5");
     438        if (mergeReporters)
     439        {
     440          spotsCount = Collections.singleton("2");
     441        }
     442        else
     443        {
     444          spotsCount = Collections.singleton("5");
     445        }
    429446      }
    430447     
     
    438455        exporter.exportBaseFileSerial(bas, file, parameters, rep, spot, mergeReporters);
    439456      }
     457      dc.commit();
     458     
     459      dc = TestUtil.getDbControl();
    440460     
    441461      ffp = new FlatFileParser();
     
    453473      // Test settings section
    454474      ffp.parseHeaders();
    455       for (Line l : ffp.getLines()) readlines.add(l.toString());
     475      for (Line l : ffp.getLines())
     476      {
     477        readlines.add(l.toString());
     478      }
    456479      TestFlatFileParser.testLine(ffp.getLine(0), "BASEfile");
    457480      TestFlatFileParser.testSection(ffp.nextSection(), "settings");
    458481      ffp.parseHeaders();
    459       for (Line l : ffp.getLines()) readlines.add(l.toString());
     482      for (Line l : ffp.getLines())
     483      {
     484        readlines.add(l.toString());
     485      }
    460486      TestFlatFileParser.testHeaderLine(ffp.getLine(0), "a", "some other parameter");
    461487      TestFlatFileParser.testHeaderLine(ffp.getLine(1), "b", "some parameter");
    462      
    463488     
    464489      readlines.clear();
     
    466491      TestFlatFileParser.testSection(ffp.nextSection(), "assays");
    467492      ffp.parseHeaders();
    468       for (Line l : ffp.getLines()) readlines.add(l.toString());
     493      for (Line l : ffp.getLines())
     494      {
     495        readlines.add(l.toString());
     496      }
    469497     
    470498      test_baseFileSectionHeader("annotationColumns", ffp.getHeader("annotationColumns"), assaysAnnotationColumns);
     
    495523          if (mergeReporters)
    496524          {
    497             String[] cols = {"\\d+","New reporter","","[14]","","","","0\\.5","[14]","","","","0\\.5"};
     525            String[] cols = {"\\d+","New reporter","[123456]","[14]\\.0","","","","0\\.5","[14]\\.0","","","","0\\.5"};
    498526            rows.add(cols);
    499527            rows.add(cols);
     
    501529          else
    502530          {
    503             String[] cols1 = {"\\d+","New reporter","[1234]","1","[01]","[01]","0","0\\.5","1","[01]","[01]","0","0\\.5"};
    504             String[] cols2 = {"\\d+","New reporter","[56]","(10)|","2|","0|","-50|","0\\.5|","(10)|","2|","0|","-50|","0\\.5|"};
     531            String[] cols1 = {"\\d+","New reporter","[1234]","1\\.0","[01]","[01]","0","0\\.5","1\\.0","[01]","[01]","0","0\\.5"};
     532            String[] cols2 = {"\\d+","New reporter","[56]","(10\\.0)|","2|","0|","-50|","0\\.5|","(10\\.0)|","2|","0|","-50|","0\\.5|"};
    505533            rows.add(cols1);
    506534            rows.add(cols1);
     
    515543          if (mergeReporters)
    516544          {
    517             String[] cols = {"\\d+","New reporter","","[14]","","","","0\\.5"};
     545            String[] cols = {"\\d+","New reporter","[123456]","[14]\\.0","","","","0\\.5"};
    518546            rows.add(cols);
    519547            rows.add(cols);
     
    521549          else
    522550          {
    523             String[] cols = {"\\d+","New reporter","[123456]","10?","[012]","[01]","(0)|(-50)","0\\.5"};
     551            String[] cols = {"\\d+","New reporter","[123456]","10?\\.0","[012]","[01]","(0)|(-50)","0\\.5"};
    524552            rows.add(cols);
    525553            rows.add(cols);
     
    534562        --numOfSections;
    535563      }
    536      
    537564      write("--Exporting basefile [matrix:"+matrix+", mergeReporters:"+mergeReporters+"] SUCCEEDED");
    538565    }
    539566    catch (Throwable ex)
    540567    {
     568      for (String line : readlines)
     569      {
     570        write("["+line+"]");
     571      }
    541572      write("--Exporting basefile [matrix:"+matrix+", mergeReporters:"+mergeReporters+"] FAILED");
    542       for (String line : readlines)
    543       {
    544         write("["+line+"]");
    545       }
    546573      ex.printStackTrace();
    547574      ok = false;
     
    565592   
    566593    if (datalines.size() != rows.size())
     594    {
    567595      throw new Exception("Wrong number of data lines. Found "+datalines.size()+" expected "+rows.size());
     596    }
    568597   
    569598    for (int i = 0; i < rows.size(); ++i)
     
    575604      {
    576605        if (dataline.columns() != row.length)
     606        {
    577607          throw new Exception("Wrong number of columns. Found "+dataline.columns()+" expected "+row.length+". ["+dataline+"]");
     608        }
    578609       
    579610        for (int j = 0; j < row.length; ++j)
     
    598629    HashSet<String> foundSet = new HashSet<String>(Arrays.asList(found.split("\\t")));
    599630    if (!expected.containsAll(foundSet))
     631    {
    600632      throw new Exception("Expected values '"+expected+"' didnt contain the header values '"+foundSet+"' for header '"+header+"'");
    601    
     633    }
    602634  }
    603635
Note: See TracChangeset for help on using the changeset viewer.