Changeset 2485


Ignore:
Timestamp:
Aug 3, 2006, 1:03:02 PM (17 years ago)
Author:
Johan Enell
Message:

Position batcher added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java

    r2481 r2485  
    5252import net.sf.basedb.core.ProgressReporter;
    5353import net.sf.basedb.core.RawBioAssay;
     54import net.sf.basedb.core.Reporter;
    5455import net.sf.basedb.core.RequestInformation;
    5556import net.sf.basedb.core.SpotBatcher;
     
    702703    throws IOException
    703704  {
     705    int posCnt = 0;
     706   
    704707    BioAssaySet bas = null;
    705708    SpotBatcher spotBatcher = null;
    706     PositionBatcher posBatcher = null; 
     709    PositionBatcher posBatcher = null;
    707710
    708711    HashMap<String, BioAssay> idMap = new HashMap<String, BioAssay>();
     712    HashMap<PosRep, Integer> posMap = new HashMap<PosRep, Integer>();
    709713
    710714    FlatFileParser ffp = getInitializedFlatFileParser(new FileInputStream(new java.io.File(getExecDirectory(), "stdout.txt")));
     
    756760      else if (section.name().equals("spots"))
    757761      {
     762        posBatcher = bas.getPositionBatcher(); // TODO: BioAssaySet can be null
    758763        spotBatcher = bas.getSpotBatcher(); // TODO: BioAssaySet can be null
    759764        List<String> columns = Arrays.asList(ffp.getHeader("columns").split("\\t"));
     
    762767
    763768        ffp.setMinDataColumns(columns.size() - 1 + assays.size() * assayFields.size());
    764         ffp.setUseNullIfEmpty(false);
    765769
    766770        int posCol = columns.indexOf("position");
     
    778782          {
    779783            intCols = true;
    780             int1Col += dataCol;
    781             int2Col += dataCol;
    782784          }
    783785          else if (mCol > -1 && aCol > -1)
    784786          {
    785787            intCols = false;
    786             mCol += dataCol;
    787             aCol += dataCol;
    788788          }
    789789          else
     
    798798        }
    799799       
     800        int1Col += dataCol;
     801        int2Col += dataCol;
     802        aCol += dataCol;
     803        mCol += dataCol;
     804       
    800805        while (ffp.hasMoreData())
    801806        {
     
    804809          {
    805810            BioAssay ba = idMap.get(assayId);
    806 
    807             float int1;
    808             float int2;
    809 
    810811            try
    811812            {
    812               int position = Integer.parseInt(dataline.get(posCol));
     813              Float int1;
     814              Float int2;             
     815              Integer reporter = dataline.get(repCol) == null ? null : new Integer(dataline.get(repCol));
     816              Integer position = dataline.get(posCol) == null ? null : new Integer(dataline.get(posCol));
     817             
    813818              if (intCols)
    814819              {
    815                 int1 = Float.parseFloat(dataline.get(int1Col));
    816                 int2 = Float.parseFloat(dataline.get(int2Col));
     820                int1 = dataline.get(int1Col) == null ? Float.NaN : new Float(dataline.get(int1Col));
     821                int2 = dataline.get(int2Col) == null ? Float.NaN : new Float(dataline.get(int2Col));
    817822              }
    818823              else
    819824              {
    820                 double a = Double.parseDouble(dataline.get(aCol));
    821                 double m = Double.parseDouble(dataline.get(mCol));
     825                float a = dataline.get(aCol) == null ? Float.NaN : new Float(dataline.get(aCol));
     826                float m = dataline.get(mCol) == null ? Float.NaN : new Float(dataline.get(mCol));
    822827
    823828                // int2 = 10^a / 2^(0.5*m)
    824829                // int1 = int2 * 2^m
    825                 int2 = (float) (Math.pow(10, a) / Math.pow(2, 0.5 * m));
    826                 int1 = (float) (int2 * Math.pow(2, m));
     830                int2 = new Float(Math.pow(10, a) / Math.pow(2, 0.5 * m));
     831                int1 = new Float(int2 * Math.pow(2, m));
     832              }
     833             
     834              PosRep pr = new PosRep(position, reporter);
     835              position = posMap.get(pr);
     836              if (position == null)
     837              {
     838                if (posMap.values().contains(position))
     839                {
     840                  position = pr.getPosition();
     841                  if (position > posCnt)
     842                  {
     843                    posCnt = position;
     844                  }
     845                }
     846                else
     847                {
     848                  posCnt++;
     849                  position = posCnt;
     850                }
     851                posMap.put(pr, position);
    827852              }
    828853             
     
    830855              {
    831856                spotBatcher.insert(ba.getDataCubeColumnNo(), position, int1, int2);
     857                if (reporter != null)
     858                {
     859                  posBatcher.insert(position, Reporter.getById(dc, reporter));
     860                }
     861                else
     862                {
     863                  posBatcher.insert(position, null);
     864                }
    832865              }
    833866            }
     
    11821215    }
    11831216  }
     1217
     1218 
     1219  private class PosRep
     1220  {
     1221    Integer position;
     1222   
     1223    Integer reporter;
     1224
     1225    PosRep(Integer position, Integer reporter)
     1226    {
     1227      this.position = position;
     1228      this.reporter = reporter;
     1229    }
     1230
     1231    public final Integer getPosition()
     1232    {
     1233      return position;
     1234    }
     1235
     1236    public final Integer getReporter()
     1237    {
     1238      return reporter;
     1239    }
     1240
     1241    @Override
     1242    public boolean equals(Object o)
     1243    {
     1244      if (this == o)
     1245      {
     1246        return true;
     1247      }
     1248      else if (o instanceof PosRep)
     1249      {
     1250        PosRep pr = (PosRep) o;
     1251        return position.equals(pr.getPosition()) && (reporter == pr.getReporter() || reporter.equals(pr.getReporter()));
     1252      }
     1253      return false;
     1254    }
     1255   
     1256  }
    11841257}
Note: See TracChangeset for help on using the changeset viewer.