From 0d339aba22aaa4de65ecf520b77aaaa324e7596e Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 29 Jan 2013 14:06:36 +0000 Subject: [PATCH] Code styling. Removed TimeSeries class. Not used inside EvA2 and therefore obsolete. --- .../inference/metabolic/TimeSeries.java | 270 ------------------ 1 file changed, 270 deletions(-) delete mode 100755 src/eva2/server/go/problems/inference/metabolic/TimeSeries.java diff --git a/src/eva2/server/go/problems/inference/metabolic/TimeSeries.java b/src/eva2/server/go/problems/inference/metabolic/TimeSeries.java deleted file mode 100755 index d6bb67dc..00000000 --- a/src/eva2/server/go/problems/inference/metabolic/TimeSeries.java +++ /dev/null @@ -1,270 +0,0 @@ -package eva2.server.go.problems.inference.metabolic; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.StringTokenizer; - -/** - * This class is able to parse and store the contents of a time series data - * file. These files are supposed to be a matrix, whose columns are separated by - * spaces or tabs. Every row is supposed to contain a time value in the first - * column. Every other column contains the concentration of the appropriate - * metabolite. Because the concentrations of different metabolites are not - * measured at the same time, it is possible that some values equal -1 or "NaN". - * For a given metabolite this class provides methods to extract the appropriate - * times as well as the concentration values from this file. - * - * @since 2.0 - * @version - * @author Andreas Dräger (draeger) - * Copyright (c) ZBiT, University of Tübingen, Germany Compiler: - * JDK 1.6.0 - * @date Sep 6, 2007 - */ -public class TimeSeries implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 5744947450930268722L; - - String dataFile[] = new String[] { - "\"Time\" \"PYR\" \"AKG\" \"ALA\" \"NAD\" \"DHIV\" \"nadp\" \"Glut\" \"2IPM\" \"AcLac\" \"Val\" \"Leu\" \"KIV\" \"KIC\"", - "-3.894 0.69956151035 4.640691888659999 0.8149815245099999 0.43831117728999996 0.12919945973 NaN 39.91322431689 0.01634219825 0.22846321864000002 25.300234279730002 0.31457001595 13.06542276153 0.12828553615000002", - "-3.429 0.6887305946 4.4648219135 0.9733354471500001 0.46283738647 0.09269418599 0.01751164422 34.689755620279996 0.016622587119999997 0.26529057205 27.855794163480002 0.21601742448 12.27325468611 0.08806661914", - "-2.964 0.648489239 5.16446833661 1.08501337472 0.510398731 0.09668719327 0.015292064690000001 35.94424701067 0.0218616059 0.24372308822 27.512009946459997 0.19358187491999998 11.83868901432 0.08060740248 ", - "-2.499 0.66263247645 5.46655875364 1.25007291486 0.54709779337 0.27832465706 0.02017254508 42.09304165779 0.02271131235 0.31096389668 31.734637769419997 0.26547698208000003 9.74938023117 0.09527994438000001 ", - "-2.037 0.78148116407 5.01023940504 1.1274704877 0.54374513457 0.10951589105 0.023434610419999998 38.623872567220005 0.02310058527 0.23193180999000002 28.68948017027 0.27338539200999995 9.8790791622 0.06856701949 ", - "-1.572 0.7976018096 4.50327160849 0.9657423536899999 0.58804343197 0.07731788865 0.021456078269999998 39.65098562534 0.02122962586 NaN 23.23780871601 0.21372010324 7.35589658416 0.04408823098 ", - "-1.107 0.62138120097 5.527992933249999 1.11320796018 0.55468774709 0.19127059402000002 0.02151432978 37.43103867786 0.021760915119999998 0.1961057295 28.06503640484 0.25571800238 7.77390798856 0.08440327591999999 ", - "-0.642 0.61440001723 5.6582676904 1.0934342424799999 0.57892866745 0.29234911798 0.02163427084 41.73288066597 0.02358943064 0.23458068462 31.36134966529 0.28291670151 8.77177024347 0.0732470093 ", - "0.363 0.70849102753 5.6485532671600005 1.07913785266 0.5494837929699999 0.22848890345 0.03264048454 40.837490521439996 0.02034557524 0.25195151103 27.336329975730003 0.1981060288 6.68584901645 0.07329936145 ", - "0.828 0.7284264133299999 5.24081938936 1.20656221781 0.56038053457 0.50828902006 0.02799224444 43.839863948079994 0.02365648322 0.33595864068 30.40658463215 0.25328480297 7.46481961657 0.06727204061 ", - "1.293 2.35072982926 12.865197464340001 2.91425720335 0.6174561459100001 0.51680611101 0.0180555805 45.00192868082 0.02789099302 0.27282017381999996 35.47319021015 0.34012252203000004 12.4841096615 0.12075887125 ", - "1.758 1.9467590874099998 9.85083850897 2.38135380833 0.47990344534 0.36137563687 0.02083824064 39.874833705 0.02603135155 0.24703878422 35.24799025209 0.25499939033 10.58660287792 0.12011356083 ", - "2.220 1.76234822871 12.57168005228 2.535743239 0.58312865514 0.17860360497 0.018047886200000002 48.82282962176 0.02531203769 NaN 31.84083292177 0.21013809416 8.79825645884 0.10474495756 ", - "2.685 1.92439252352 11.2260038878 2.8335955021 0.49220203429 0.16592713605 0.0278326992 39.75506759172 0.02115183034 0.24700121622 29.23941353308 0.22169631684000002 8.94277598226 0.09683684583 ", - "3.150 1.92008237217 10.682979534100001 2.63737602928 0.36735949621999997 0.1546055768 0.01515236183 39.012881840679995 NaN 0.46143297886 35.812552779769995 0.28387244697 14.20243053826 0.10933158105 ", - "4.620 1.81992606678 11.067551454270001 2.70934921435 0.40725580208999995 0.24849740356 0.027964720069999997 40.42309102465 0.0170493166 0.42824885292 37.17528380543 0.33573709864 15.33969385816 0.10861095009 ", - "5.085 1.45412618172 8.37506633272 2.5510691881399996 0.5402956812899999 0.29017599822 0.029667666019999997 52.86610489844 0.01551224716 0.37018809756000004 42.07773461152 0.32912302835999996 16.97282365372 0.1127063518 ", - "5.550 1.7963431670299999 10.9951402722 3.2730762781499996 0.49909124182 0.36584625016 0.031689318279999996 49.69757534082 0.030182574599999998 0.50230756817 44.18764066063 0.34318150693 14.45568137413 0.13087029789 ", - "6.015 1.79488675167 10.58210664143 2.82815659112 0.42028499769 0.33884287302 0.02904992542 47.618463449870006 0.02065291348 0.38243112459999995 41.68555649409 0.31270596242 14.18407754513 0.12297689406000001 ", - "6.477 1.71658915979 13.051632359080001 2.86429255047 0.69044126446 0.2906864281 0.02542790495 52.905505205989996 0.0363051233 0.46612294623 51.36020781111 0.52323119427 15.99708653385 0.13462198459000002 ", - "6.942 1.70200349375 11.29511994965 2.47410519106 0.61838724543 0.74141022319 0.02954918008 52.05561320903 0.03626130189 0.36020464648 47.08381733066 0.39496256108 15.29065040412 0.12714131781000002 ", - "7.407 1.4797133761099999 10.85092666902 2.73282139173 0.60893255673 0.91712444816 0.031866304570000004 54.69762263264 0.034354864900000004 0.50457338093 42.85485451463 0.35559022922000005 11.0783278302 0.11004224548000001 ", - "7.872 1.9687388421799998 12.632535436100001 3.38129932903 0.6733727859399999 1.19712426006 0.02287925851 69.03104100976 0.0346858365 0.6115046939 52.213982982809995 0.44352030561 14.17030298056 0.11817042216 ", - "8.877 1.66191235556 10.202950777509999 2.7018080554500004 0.65431385574 0.8630518573 0.03842550936 55.18740808596 0.03100906854 0.43636326995 44.94372991982 0.39590424030000004 11.87915174242 0.12055380252 ", - "9.342 1.79446423883 9.223736902639999 2.82086676673 0.46928184702 0.25036756575999997 0.0261580927 44.218411563610005 0.02307492312 0.37136132062 34.8715067452 0.23048150172999998 9.83227607934 0.08369892896 ", - "9.807 2.02936743557 10.926146897779999 3.40942786382 0.4943626997 0.41616779600000003 0.020775668350000002 57.63290012324 0.02453204368 0.59384364452 41.567799898539995 0.37314942280999996 11.524438278929999 0.10958751164 ", - "10.272 1.96339182674 11.26182399865 3.6725323889699997 0.51033452936 0.38195138421 0.02349833226 68.82889744295 0.02130776115 0.56596184217 43.85824526299 0.3563165939 10.882216090570001 0.11761378372 ", - "10.734 1.69522699956 9.28644900764 3.09521900994 0.46748976233 0.25486955073 0.024124165519999997 56.23949510944 0.01806823073 NaN 36.05982284756 0.25298007274 8.86586676025 0.07157556397999999 ", - "11.199 1.87021691917 9.68208305253 3.2919709268000004 0.5270903229299999 0.42322311943 0.0327964463 59.54087126072 0.022691202100000002 0.47737124454999996 41.842194656909996 0.28466758982 11.91006067162 0.09872917755999999 ", - "11.664 2.23471175262 12.19887299453 3.6051454388299997 0.54389398527 0.54313316601 0.01479252184 63.04737515095 0.02776861734 0.48410774037 46.409590689800005 0.44546516811 12.6862786223 0.10475246765999999 ", - "12.129 1.58626042008 9.99097297113 3.7513050785999997 0.42925918395999996 0.44080053731999996 0.013039703409999999 54.332315720649994 0.02735050961 0.31900140121 39.37877381533 0.32147277213000003 10.09758737431 0.08824555916 ", - "13.134 1.09179740401 6.491353226309999 2.26052958713 0.5481437170200001 NaN 0.01664214786 49.99620609066 0.02341309598 NaN 32.90242406736 0.29822072293 7.4630383928 0.0570285326 ", - "13.599 1.3879954566700001 9.38597812226 3.67292411291 0.41493699655 0.35712124297000003 0.01725904447 49.842043735 0.025759816390000002 0.40749356039 36.65749859265 0.31221753187 8.49907762956 0.08041935436999999 ", - "14.064 1.46398956252 9.514586394050001 3.8008622291900003 0.48941052945 0.43946239095 0.01718538349 54.47374486523 0.02895368422 0.48952197341 40.26813532416 0.40474806982 9.42390966864 0.07994405853 ", - "14.529 1.38755206855 8.484590611449999 3.2508142214399998 0.4940005127 0.48337445569 0.01893519951 47.84282639242 0.026125384369999997 0.4407703548 41.362606442570005 0.27053364357 11.06193869222 0.1028701703 ", - "14.991 0.88675119894 6.09938485345 2.0966046727900003 0.51403159937 0.25811120551 0.0228857864 44.11169057688 0.021193232819999998 NaN 31.027494313570003 0.22906790417 7.52510837768 0.053950203 ", - "15.456 1.8352414024800001 8.469270941569999 3.3301897663099997 0.4957035248 0.26361946777 0.025116875570000002 36.08517318062 0.025039514409999998 0.38916760052 38.21581762714 0.2746950311 11.731711424339998 0.12009641433 ", - "15.921 1.3283163392300001 8.17980680802 3.0409809543 0.38135485122 0.31612171511000003 0.01517163163 32.72595199009 0.02671292861 0.34622186149 42.07802536984 0.2542175654 12.23730313735 0.13746139785 ", - "16.386 1.0127505969 4.742491586150001 1.84597095725 0.34553761760999996 NaN NaN 23.37116254961 NaN NaN NaN 0.15254582637 6.9247716185999995 0.07113160166999999 ", - "17.391 1.3310395982 7.94156759798 2.53879431682 0.48983728463 0.28795700924 0.026527055879999997 26.57827416636 0.02478540202 0.32631108383999996 33.95632215865 0.23618178628 10.48083524196 0.12515650878 ", - "17.856 0.95469028533 6.2343780867100005 2.17715476263 0.38729195765999996 0.28723013923 0.02123345169 24.49108607053 0.02618426224 0.29861161455 32.8592195428 0.2472225415 10.106162722479999 0.10923677735 ", - "18.321 NaN 5.49182392648 1.46886777519 0.34474738841999997 0.40646871383 0.01547566737 20.63720807926 0.02820014831 0.24058040600000002 40.71516409524 0.24270642545999999 14.12503277772 0.12899961175000002 ", - "18.786 0.82619105906 5.95530539146 2.299362329 0.44373946309 0.41075036223 0.02555677606 38.20802369971 0.02900285112 0.32959703389 34.213028316030005 0.25023635697 9.12222153162 0.10197379988000001 ", - "19.248 1.25881942787 6.53214282703 2.7302141736600003 0.50467802709 0.41526312678 0.02242466065 36.837815626659996 0.02483324467 0.38040913803 33.23783851764 0.23737761148 9.48079376972 0.11263783924000001 ", - "19.713 1.18507811227 5.4310205666 2.1360162267800002 0.46222885974 NaN 0.03397622205 28.19338823663 0.02104977904 NaN 25.47234120703 0.14638363385 7.60817737184 0.08542327693999999 ", - "20.178 0.98680703323 6.8729957498 2.34703189167 0.36189835991 0.35197395012 0.0170510439 26.43911126279 0.03024185129 0.30588350463 36.72827117308 0.23660664184000002 13.6943897464 0.16017717532 ", - "20.643 0.97377667062 6.15710096877 2.10492373702 0.46580796436000005 0.38984610765 0.020551778160000003 28.19084298145 0.02817732147 0.31660453741 33.563565688000004 0.17354025424 11.137671980450001 0.11278907400999999" }; - - private int dataFileLineCnt = dataFile.length; - - private Map names; - - public static void main(String args[]) { - new TimeSeries(); - } - - /** - * This constructs a new instance of this class from the given file. All - * entries of the given file are stored in a String matrix. - * The names of the metabolites are stored in a hash for easy retrival. - * - * @param fileName - */ - public TimeSeries() { - try { - int i = 0, j = 0; - this.names = new HashMap(); - StringTokenizer st = new StringTokenizer(dataFile[0]); - - // Lesen zum ersten Mal und initialisieren Matrix. - for (j = 0; st.hasMoreElements(); st.nextElement(), j++) - ; - - String data[][] = new String[dataFileLineCnt - 1][j]; - - // Jetzt in Matrix einlesen. - for (i = 0; i < dataFileLineCnt; i++) { - j = 0; - st = new StringTokenizer(dataFile[i]); - while (st.hasMoreElements()) - if (i > 0) { - data[i - 1][j++] = st.nextElement().toString(); - } - else { - names.put(st.nextElement().toString().replaceAll("\"", - ""), new Integer(j++)); - } - } - - /* - * for (i=0; i iter = names.keySet().iterator(); - while (iter.hasNext()) - try { - double values[][]; - int tcol = 0, count = 0; - String name = iter.next().toString(); - - i = 0; - j = ((Integer) names.get(name)).intValue(); - for (i = 0; i < data.length; i++) { - if (!data[i][j].equals("-1") - && !data[i][j].equals("NaN")) { - count++; - } - } - values = new double[2][count]; - // /* - // * The times are supposed to be the first column. However, - // this - // * enables the times to be any column. - // */ - // try { - // tcol = ((Integer) this.names.get("Time")).intValue(); - // } catch (Exception exc) { - // }; - for (i = 0, count = 0; i < data.length; i++) { - if (!data[i][j].equals("-1") - && !data[i][j].equals("NaN")) { - values[0][count] = Double - .parseDouble(data[i][tcol]); - values[1][count++] = Double.parseDouble(data[i][j]); - } - } - names.put(name, values); - } catch (Exception exc) { - exc.printStackTrace(); - } - data = null; - } catch (Exception exc) { - exc.printStackTrace(); - } - } - - /** - * With this method one retrives the time data of the given metabolite or - * throws an exception if the given metabolite does not exist. - * - * @param metabolite - * The name of the metabolite, whose time data are desired. - * @return The time data. - * @throws Exception - * @throws If - * there is no entry for the desired metabolite, an exeption is - * thrown. - */ - public double[] getTimes(String metabolite) throws Exception { - if (names == null) { - System.err.println("getTimes: names is null"); - } - if (!names.containsKey(metabolite)) { - throw new Exception("No data measured for this metabolite"); - } - if (names.get(metabolite) == null) { - System.err.println("get(metabolite) is null"); - } - return ((double[][]) names.get(metabolite))[0]; - } - - /** - * This method returns all measured times. - * - * @return An array containing all measurement times. - * @throws Exception - * If there is no column called "Time" in the data matrix. - */ - public double[] getTimes() throws Exception { - return getTimes("Time"); - } - - /** - * This method returns the concentration values of the given metabolite or - * throws an exception if there is no measurement for the desired - * metabolite. - * - * @param metabolite - * The name of the desired metabolite. - * @return an array of concentration values. - * @throws Exception - * @throws If - * there is no entry for the desired metabolite, an exception is - * thrown. - */ - public double[] getValues(String metabolite) throws Exception { - if (!names.containsKey(metabolite)) { - throw new Exception("No data measured for this metabolite"); - } - return ((double[][]) names.get(metabolite))[1]; - } - - /** - * With this method it can be checked wheather measurements have been - * perforemd for the given metabolite. - * - * @param name - * The name of the metabolite - * @return true if an entry for this metabolite exists or - * false otherwise. - */ - public boolean containsMetabolite(String name) { - return names.keySet().contains(name); - } - - /** - * Returns the number of measurements taken for this specific metabolite or - * zero if there are no measurements. - * - * @param name - * The name of the metabolite - * @return The number of available measurement data for this metabolite - */ - public int numberOfMeasurements(String name) { - try { - return getTimes(name).length; - } catch (Exception exc) { - return 0; - } - } - - public Iterator namesIterator() { - return this.names.keySet().iterator(); - } - - public int size() { - return names.keySet().size(); - } - -}