Changeset 1210


Ignore:
Timestamp:
Mar 23, 2010, 3:47:51 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #248 and #252. Median fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.illumina/trunk/src/net/sf/basedb/illumina/plugins/BackgroundCorrection.java

    r1208 r1210  
    440440
    441441    int nofSpots=0;
    442     SqlResult r = null;
    443     while (nofSpots++<count) r=dri.next();
    444 
    445     // odd number, next number is the median
    446     if (!even) return dri.next().getFloat(index);
    447     // even number, median is average of this and next number
    448     return (r.getFloat(index) + dri.next().getFloat(index))/2;
     442    float median=0;
     443    HashMap<Integer,SData> hmap=(saveBG ? new HashMap<Integer,SData>() : null);
     444    SData sdata=new SData(dri);
     445
     446    while (dri.hasNext())
     447    {
     448      SqlResult sr=dri.next();
     449      ++nofSpots;
     450      // odd number, median is the centre
     451      // even number, median is the average of two values in the centre
     452      if ((nofSpots==count) || (even && nofSpots==(count+1))) median+=sr.getFloat(index);
     453
     454      if (saveBG)
     455      {
     456        Integer position=sdata.extractData(sr);
     457        allNegPos.add(position);
     458        hmap.put(position,new SData(sdata));
     459      }
     460    }
     461
     462    if (saveBG) negSData.add(hmap);
     463
     464    // even number of spot,  median is an average of two values
     465    return (even ? median/2 : median);
    449466  }
    450467
Note: See TracChangeset for help on using the changeset viewer.