Changeset 4531
- Timestamp:
- Sep 17, 2008, 2:27:26 PM (15 years ago)
- Location:
- branches/2.8-stable/src
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.8-stable/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java
r4530 r4531 1827 1827 List<String> setExtraFloats = new ArrayList<String>(); 1828 1828 if (ffp.getHeader("setExtraFloats") != null) 1829 { 1829 1830 setExtraFloats = Arrays.asList(ffp.getHeader("setExtraFloats").split("\\t")); 1830 1831 } 1831 1832 ffp.setMinDataColumns(columns.size() - 1 + assays.size() * assayFields.size()); 1832 1833 … … 1880 1881 1881 1882 for (int i = 0; i < intCol.length; ++i) 1883 { 1882 1884 intCol[i] += dataCol; 1885 } 1883 1886 aCol += dataCol; 1884 1887 mCol += dataCol; … … 1906 1909 } 1907 1910 1911 float[] intensities = new float[intCol.length]; 1908 1912 while (ffp.hasMoreData()) 1909 1913 { … … 1911 1915 FlatFileParser.Data dataline = ffp.nextData(); 1912 1916 int index = 0; 1917 Integer position = Values.getInteger(dataline.get(posCol), null); 1913 1918 for (Integer assayId : assays) 1914 1919 { 1920 // Only insert the spot if all intensity values are correct numbers 1921 boolean insertSpot = true; 1915 1922 short dataCubeColumn = bioAssayColumns.get(assayId); 1916 try1923 if (intCols) 1917 1924 { 1918 float[] intensities = new float[intCol.length]; 1919 Integer position = dataline.get(posCol) == null ? null : new Integer(dataline.get(posCol)); 1920 1921 if (intCols) 1925 for (int i = 0; i < intCol.length; ++i) 1922 1926 { 1923 for (int i = 0; i < intCol.length; ++i) 1924 intensities[i] = dataline.get(intCol[i] + index) == null ? Float.NaN : new Float(dataline.get(intCol[i] + index)); 1927 float value = Values.getFloat(dataline.get(intCol[i] + index), Float.NaN); 1928 insertSpot &= !Float.isNaN(value); 1929 intensities[i] = value; 1925 1930 } 1926 else 1931 } 1932 else 1933 { 1934 float a = Values.getFloat(dataline.get(aCol + index), Float.NaN); 1935 float m = Values.getFloat(dataline.get(mCol + index), Float.NaN); 1936 insertSpot = !Float.isNaN(m) && !Float.isNaN(a); 1937 if (insertSpot) 1927 1938 { 1928 float a = dataline.get(aCol + index) == null ? Float.NaN : new Float(dataline.get(aCol + index));1929 float m = dataline.get(mCol + index) == null ? Float.NaN : new Float(dataline.get(mCol + index));1930 1931 1939 // int2 = 10^a / 2^(0.5*m) 1932 1940 // int1 = int2 * 2^m 1933 intensities[1] = new Float(Math.pow(10, a) / Math.pow(2, 0.5 * m));1934 intensities[0] = new Float(intensities[1] * Math.pow(2, m));1941 intensities[1] = (float)(Math.pow(10, a) / Math.pow(2, 0.5 * m)); 1942 intensities[0] = (float)(intensities[1] * Math.pow(2, m)); 1935 1943 } 1936 1944 } 1945 if (insertSpot) 1946 { 1937 1947 spotBatcher.insert(dataCubeColumn, position, intensities); 1938 1948 // Extra values 1939 1949 for (int i = 0; i < evBatcher.size(); i++) 1940 1950 { 1941 try 1951 float value = Values.getFloat(dataline.get(extraFloatsCol[i] + index), Float.NaN); 1952 if (!Float.isNaN(value)) 1942 1953 { 1943 Float ev = new Float(dataline.get(extraFloatsCol[i] + index)); 1944 evBatcher.get(i).insert(dataCubeColumn, position, ev); 1954 evBatcher.get(i).insert(dataCubeColumn, position, value); 1945 1955 } 1946 catch (NumberFormatException e)1947 {}1948 1956 } 1949 1957 } 1950 catch (NumberFormatException e) 1951 {} 1952 finally 1953 { 1954 index += assayFields.size(); 1955 } 1956 } 1957 } 1958 } 1959 } 1960 1958 index += assayFields.size(); 1959 } 1960 } 1961 } 1962 } 1961 1963 } 1962 1964 -
branches/2.8-stable/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java
r4480 r4531 942 942 ExtraValueType evt = ev.getExtraValueType(); 943 943 items.add(new QueryItem("xtra."+evt.getExternalId(), "[Extra] "+evt.getName(), 944 "_xc_"+evt.get Name(), "xtra('" + evt.getExternalId() + "')", evt.getAverageMethod()));944 "_xc_"+evt.getExternalId(), "xtra('" + evt.getExternalId() + "')", evt.getAverageMethod())); 945 945 } 946 946 Collections.sort(items, new QueryItemTitleComparator()); -
branches/2.8-stable/src/test/Base1NullPlugin.java
r4480 r4531 71 71 while (line != null) 72 72 { 73 if (line.startsWith("assayFields") && line.contains("_xc_")) 74 { 75 /* 76 The file contains extra values. To make the 77 import work we must remove the _xc_ prefix for the 78 extra value columns and add a setExtraFloats header 79 */ 80 String[] columns = line.split("\\t"); 81 line = "assayFields"; 82 String setExtraFloats = "setExtraFloats"; 83 for (int i = 1; i < columns.length; ++i) 84 { 85 String column = columns[i]; 86 if (column.startsWith("_xc_")) 87 { 88 column = column.substring(4); 89 setExtraFloats += "\t" + column; 90 } 91 line += "\t" + column; 92 } 93 System.out.println(setExtraFloats); 94 } 73 95 System.out.println(line); 74 96 log.println(line); -
branches/2.8-stable/src/test/TestAnalyzePluginUtil.java
r4480 r4531 27 27 import java.util.regex.Pattern; 28 28 29 import net.sf.basedb.core.BioAssaySet; 29 30 import net.sf.basedb.core.DbControl; 30 31 import net.sf.basedb.core.Experiment; 31 32 import net.sf.basedb.core.Item; 33 import net.sf.basedb.core.ItemQuery; 32 34 import net.sf.basedb.core.Permission; 33 35 import net.sf.basedb.core.Platform; … … 37 39 import net.sf.basedb.core.ReporterBatcher; 38 40 import net.sf.basedb.core.data.RawData; 41 import net.sf.basedb.core.query.Hql; 42 import net.sf.basedb.core.query.Orders; 39 43 import net.sf.basedb.util.FileUtil; 40 44 import net.sf.basedb.util.Values; … … 48 52 * @param rawBioAssays number of {@link net.sf.basedb.core.RawBioAssay RawBioAssays} in experiment 49 53 * @param spots number of spots in each RawBioAssay 54 * @param randomize Randomize imported intensity values by multiplying them with 55 * a random value between 1+randomize and 1-randomize. Eg. if randomize=0.8, the factory is 56 * a random value between 0.8 and 1.2 50 57 */ 51 static int test_createExperiment(String file, int rawBioAssays, int spots )58 static int test_createExperiment(String file, int rawBioAssays, int spots, float randomize) 52 59 { 53 60 if (!TestUtil.hasPermission(Permission.CREATE, Item.EXPERIMENT)) return 0; … … 89 96 rawData.setReporter(reporterId == null ? null : reporterBatcher.getByExternalId(reporterId)); 90 97 98 float randomCh1 = (float)((2 * Math.random() - 1) * randomize + 1); 99 float randomCh2 = (float)((2 * Math.random() - 1) * randomize + 1); 100 91 101 Map<String, Object> extraData = rawData.getAllExtended(); 92 102 extraData.put("diameter", Values.getFloat(parsedData.get(7), null)); 93 extraData.put("ch1FgMedian", Values.getFloat(parsedData.get(8), null));94 extraData.put("ch1FgMean", Values.getFloat(parsedData.get(9), null));95 extraData.put("ch1FgSd", Values.getFloat(parsedData.get(10), null));96 extraData.put("ch1BgMedian", Values.getFloat(parsedData.get(11), null));97 extraData.put("ch1BgMean", Values.getFloat(parsedData.get(12), null));98 extraData.put("ch1BgSd", Values.getFloat(parsedData.get(13), null));103 extraData.put("ch1FgMedian", randomCh1 * Values.getFloat(parsedData.get(8), null)); 104 extraData.put("ch1FgMean", randomCh1 * Values.getFloat(parsedData.get(9), null)); 105 extraData.put("ch1FgSd", randomCh1 * Values.getFloat(parsedData.get(10), null)); 106 extraData.put("ch1BgMedian", randomCh1 * Values.getFloat(parsedData.get(11), null)); 107 extraData.put("ch1BgMean", randomCh1 * Values.getFloat(parsedData.get(12), null)); 108 extraData.put("ch1BgSd", randomCh1 * Values.getFloat(parsedData.get(13), null)); 99 109 extraData.put("ch1PercSd1", Values.getInteger(parsedData.get(14), null)); 100 110 extraData.put("ch1PercSd2", Values.getInteger(parsedData.get(15), null)); 101 111 extraData.put("ch1PercSat", Values.getInteger(parsedData.get(16), null)); 102 extraData.put("ch2FgMedian", Values.getFloat(parsedData.get(17), null));103 extraData.put("ch2FgMean", Values.getFloat(parsedData.get(18), null));104 extraData.put("ch2FgSd", Values.getFloat(parsedData.get(19), null));105 extraData.put("ch2BgMedian", Values.getFloat(parsedData.get(20), null));106 extraData.put("ch2BgMean", Values.getFloat(parsedData.get(21), null));107 extraData.put("ch2BgSd", Values.getFloat(parsedData.get(22), null));112 extraData.put("ch2FgMedian", randomCh2 * Values.getFloat(parsedData.get(17), null)); 113 extraData.put("ch2FgMean", randomCh2 * Values.getFloat(parsedData.get(18), null)); 114 extraData.put("ch2FgSd", randomCh2 * Values.getFloat(parsedData.get(19), null)); 115 extraData.put("ch2BgMedian", randomCh2 * Values.getFloat(parsedData.get(20), null)); 116 extraData.put("ch2BgMean", randomCh2 * Values.getFloat(parsedData.get(21), null)); 117 extraData.put("ch2BgSd", randomCh2 * Values.getFloat(parsedData.get(22), null)); 108 118 extraData.put("ch2PercSd1", Values.getInteger(parsedData.get(23), null)); 109 119 extraData.put("ch2PercSd2", Values.getInteger(parsedData.get(24), null)); … … 150 160 formulaId, rawBioAssayIds); 151 161 TestJob.test_execute(jobId); 152 162 ItemQuery<BioAssaySet> query = e.getBioAssaySets(); 163 query.order(Orders.desc(Hql.property("id"))); 164 id = query.iterate(dc).next().getId(); 153 165 write("--Create root BioAssaySet in TestAnalyzePluginUtil OK"); 154 166 } -
branches/2.8-stable/src/test/TestBase1PluginExecuter.java
r4480 r4531 16 16 import net.sf.basedb.core.PluginResponse; 17 17 import net.sf.basedb.core.RequestInformation; 18 import net.sf.basedb.core.Type; 18 19 import net.sf.basedb.core.plugin.Response; 19 20 … … 63 64 64 65 // Create experiment 65 int experimentId = TestAnalyzePluginUtil.test_createExperiment("data/test.rawdata.import.txt", 2, 100 );66 int experimentId = TestAnalyzePluginUtil.test_createExperiment("data/test.rawdata.import.txt", 2, 100, 0.8f); 66 67 int[] rawBioAssays = TestExperiment.test_list_rawbioassays(experimentId, -1); 67 68 … … 74 75 int fileId = TestFile.test_create("data/test.nullplugin.base", false, false); 75 76 int fileId2 = TestFile.test_create("data/test.base1plugin.base", false, false); 77 int fileIdMatrix = TestFile.test_create("data/test.nullplugin.matrix.base", false, false); 76 78 int directoryId = TestDirectory.test_create(true, "Base1PluginExecuter"); 77 79 78 TestAnalyzePluginUtil.test_createRootBioAssaySet(experimentId, formulaId); 80 int rootBioAssaySetId = TestAnalyzePluginUtil.test_createRootBioAssaySet(experimentId, formulaId); 81 int filteredBioAssaySetId = TestExperiment.test_filter_bioassayset(rootBioAssaySetId, 1); 79 82 int pluginDefinitionId = TestPluginDefinition.test_get("net.sf.basedb.plugins.Base1PluginExecuter"); 80 83 int pluginConfigurationId = test_create_configuration(pluginDefinitionId, fileId); 81 84 int pluginConfigurationId2 = test_create_configuration(pluginDefinitionId, fileId2); 82 83 // Copy input to output 84 int jobId = test_create_job(pluginConfigurationId, experimentId, directoryId); 85 int pluginConfigurationIdMatrix = test_create_configuration(pluginDefinitionId, fileIdMatrix); 86 87 // Calculate extra value 88 int aExtraValueId = TestExtraValueType.test_create("a", Type.FLOAT, false); 89 TestExperiment.test_calculate_spotextravalues(rootBioAssaySetId, false, 0, aExtraValueId, 0); 90 TestExperiment.test_calculate_spotextravalues(filteredBioAssaySetId, false, 0, aExtraValueId, 0); 91 92 // Copy input to output - serial format 93 int jobId = test_create_job(pluginConfigurationId, experimentId, rootBioAssaySetId, directoryId); 85 94 TestJob.test_execute(jobId); 86 95 96 // Copy input to output - matrix format 97 int jobIdMatrix = test_create_job(pluginConfigurationIdMatrix, experimentId, rootBioAssaySetId, directoryId); 98 TestJob.test_execute(jobIdMatrix); 99 100 // Copy input to output - matrix format - filtered bioassayset 101 int jobIdMatrix2 = test_create_job(pluginConfigurationIdMatrix, experimentId, filteredBioAssaySetId, directoryId); 102 TestJob.test_execute(jobIdMatrix2); 103 87 104 // One-to-one mapping on assays and reporters 88 int jobId2 = test_create_job(pluginConfigurationId 2, experimentId, directoryId);105 int jobId2 = test_create_job(pluginConfigurationIdMatrix, experimentId, rootBioAssaySetId, directoryId); 89 106 TestJob.test_execute(jobId2); 90 107 91 108 // Merge assays 92 int jobId3 = test_create_job(pluginConfigurationId2, experimentId, directoryId,109 int jobId3 = test_create_job(pluginConfigurationId2, experimentId, rootBioAssaySetId, directoryId, 93 110 new Parameter("mergeAssays", "1")); 94 111 TestJob.test_execute(jobId3); 95 112 96 113 // Offset positions 97 int jobId4 = test_create_job(pluginConfigurationId2, experimentId, directoryId,114 int jobId4 = test_create_job(pluginConfigurationId2, experimentId, rootBioAssaySetId, directoryId, 98 115 new Parameter("offsetPositions", "1")); 99 116 TestJob.test_execute(jobId4); 100 117 101 118 // Offset positions and merge assays 102 int jobId5 = test_create_job(pluginConfigurationId2, experimentId, directoryId,119 int jobId5 = test_create_job(pluginConfigurationId2, experimentId, rootBioAssaySetId, directoryId, 103 120 new Parameter("mergeAssays", "1"), new Parameter("offsetPositions", "1")); 104 121 TestJob.test_execute(jobId5); 105 122 106 123 // Create reporter list 107 int jobId6 = test_create_job(pluginConfigurationId2, experimentId, directoryId,124 int jobId6 = test_create_job(pluginConfigurationId2, experimentId, rootBioAssaySetId, directoryId, 108 125 new Parameter("reporterList", "1")); 109 126 TestJob.test_execute(jobId6); … … 120 137 } 121 138 } 139 TestExtraValueType.test_delete(aExtraValueId); 122 140 TestPluginConfiguration.test_delete(pluginConfigurationId); 123 141 TestPluginConfiguration.test_delete(pluginConfigurationId2); 142 TestPluginConfiguration.test_delete(pluginConfigurationIdMatrix); 124 143 TestFormula.test_delete(formulaId); 125 144 TestFormula.test_delete(formulaChromosomeId); 126 145 TestFile.test_delete(fileId); 127 146 TestFile.test_delete(fileId2); 147 TestFile.test_delete(fileIdMatrix); 128 148 TestDirectory.test_delete(directoryId, true); 129 149 TestReporter.test_delete(); … … 177 197 } 178 198 179 static int test_create_job(int pluginConfigurationId, int experimentId, int directoryId, Parameter... parameters)199 static int test_create_job(int pluginConfigurationId, int experimentId, int bioAssaySetId, int directoryId, Parameter... parameters) 180 200 { 181 201 if (pluginConfigurationId == 0 || !TestUtil.hasPermission(Permission.CREATE, Item.JOB)) return 0; … … 187 207 188 208 Experiment e = Experiment.getById(dc, experimentId); 189 BioAssaySet bioAssaySet = e.getBioAssaySets().iterate(dc).next();209 BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId); 190 210 191 211 PluginConfiguration pc = PluginConfiguration.getById(dc, pluginConfigurationId); -
branches/2.8-stable/src/test/TestBioAsssaySetExporter.java
r4480 r4531 111 111 TestExperiment.test_add_rawbioassay(experiment, rba2); 112 112 bas = TestExperiment.test_create_root_bioassayset_using_calculator(experiment, "medianfg", new int[] {rba1, rba2}); 113 TestExperiment.test_calculate_spotextravalues(bas, 0, 0, 0);114 113 115 114 test_exportBaseFile(bas, file, false, false); -
branches/2.8-stable/src/test/TestExperiment.java
r4480 r4531 110 110 111 111 112 int filterBasId = test_filter_bioassayset(rootBasId );112 int filterBasId = test_filter_bioassayset(rootBasId, 2.0f); 113 113 int basId = test_create_bioassayset(filterBasId); 114 114 … … 117 117 int stringExtraId = TestExtraValueType.test_create("test.string", Type.STRING, false); 118 118 119 int extraSpotId = test_calculate_spotextravalues(filterBasId, intExtraId, floatExtraId, stringExtraId); 119 int extraSpotId = test_calculate_spotextravalues(filterBasId, true, 120 intExtraId, floatExtraId, stringExtraId); 120 121 int extraPosId = test_calculate_positionextravalues(filterBasId, intExtraId, floatExtraId, stringExtraId); 121 122 // TODO … … 934 935 } 935 936 936 static int test_filter_bioassayset(int bioAssaySetId )937 static int test_filter_bioassayset(int bioAssaySetId, float factor) 937 938 { 938 939 if (bioAssaySetId == 0) return 0; … … 963 964 ) 964 965 ); 965 query.setParameter("factor", 2, Type.INT);966 query.setParameter("factor", factor, Type.FLOAT); 966 967 967 968 FilterBatcher filterBatcher = bas.getFilterBatcher(); … … 998 999 } 999 1000 1000 static int test_calculate_spotextravalues(int bioAssaySetId, int intExtraId, int floatExtraId, int stringExtraId) 1001 static int test_calculate_spotextravalues(int bioAssaySetId, boolean createChild, 1002 int intExtraId, int floatExtraId, int stringExtraId) 1001 1003 { 1002 1004 if (bioAssaySetId == 0) return 0; … … 1008 1010 BioAssaySet source = BioAssaySet.getById(dc, bioAssaySetId); 1009 1011 1010 Transformation t = source.newTransformation(null); 1011 dc.saveItem(t); 1012 1013 BioAssaySet bas = t.newProduct(null, null, true); 1014 bas.setName("Extra spot values bioassayset"); 1015 dc.saveItem(bas); 1012 BioAssaySet insertTo = source; 1013 if (createChild) 1014 { 1015 Transformation t = source.newTransformation(null); 1016 dc.saveItem(t); 1017 1018 insertTo = t.newProduct(null, null, true); 1019 insertTo.setName("Extra spot values bioassayset"); 1020 dc.saveItem(insertTo); 1021 } 1016 1022 1017 1023 SpotExtraValueBatcher<Integer> intBatcher = null; … … 1019 1025 { 1020 1026 ExtraValueType intExtraValue = ExtraValueType.getById(dc, intExtraId); 1021 intBatcher = bas.getSpotExtraValueBatcher(Integer.class, intExtraValue, null);1027 intBatcher = insertTo.getSpotExtraValueBatcher(Integer.class, intExtraValue, null); 1022 1028 } 1023 1029 SpotExtraValueBatcher<Float> floatBatcher = null; … … 1025 1031 { 1026 1032 ExtraValueType floatExtraValue = ExtraValueType.getById(dc, floatExtraId); 1027 floatBatcher = bas.getSpotExtraValueBatcher(Float.class, floatExtraValue, null);1033 floatBatcher = insertTo.getSpotExtraValueBatcher(Float.class, floatExtraValue, null); 1028 1034 } 1029 1035 SpotExtraValueBatcher<String> stringBatcher = null; … … 1031 1037 { 1032 1038 ExtraValueType stringExtraValue = ExtraValueType.getById(dc, stringExtraId); 1033 stringBatcher = bas.getSpotExtraValueBatcher(String.class, stringExtraValue, null);1039 stringBatcher = insertTo.getSpotExtraValueBatcher(String.class, stringExtraValue, null); 1034 1040 } 1035 1041 … … 1066 1072 1067 1073 dc.commit(); 1068 id = bas.getId();1069 dc = TestUtil.getDbControl(); 1070 dc.reattachItem( bas);1071 write_item(0, bas);1074 id = insertTo.getId(); 1075 dc = TestUtil.getDbControl(); 1076 dc.reattachItem(insertTo); 1077 write_item(0, insertTo); 1072 1078 write("--Calculate spot extra values OK ("+numSpots+" values inserted)"); 1073 1079 -
branches/2.8-stable/src/test/TestLowessNormalization.java
r4480 r4531 54 54 { 55 55 write("++Testing TestLowessNormalization"); 56 int experimentId = TestAnalyzePluginUtil.test_createExperiment("data/test.rawdata.import.txt", 2, 100 );56 int experimentId = TestAnalyzePluginUtil.test_createExperiment("data/test.rawdata.import.txt", 2, 100, 1.0f); 57 57 58 58 int formulaId = TestFormula.test_create(null, Formula.Type.INTENSITY_EXPRESSION, -
branches/2.8-stable/src/test/TestMedianRatioNormalization.java
r4480 r4531 49 49 { 50 50 write("++Testing MedianRatioNormalization"); 51 int experimentId = TestAnalyzePluginUtil.test_createExperiment("data/test.rawdata.import.txt", 2, 100 );51 int experimentId = TestAnalyzePluginUtil.test_createExperiment("data/test.rawdata.import.txt", 2, 100, 1.0f); 52 52 int formulaId = TestFormula.test_create(null, Formula.Type.INTENSITY_EXPRESSION, 53 53 "genepix", new String[] { "raw('ch1FgMedian')", "raw('ch2FgMedian')" }, false); -
branches/2.8-stable/src/test/data/test.nullplugin.base
r4232 r4531 1 1 BASEfile 2 2 section plugin 3 uniqueName onk.lu.se/enell/wget3 uniqueName nullplugin-serial 4 4 versionNumber 1.0 5 5 name Base1NullPlugin
Note: See TracChangeset
for help on using the changeset viewer.