Changeset 3645


Ignore:
Timestamp:
Aug 8, 2007, 7:28:30 PM (14 years ago)
Author:
Peter Johansson
Message:

refs #639 stupid version of exportPureMatrix method that simply exports channel 1.

File:
1 edited

Legend:

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

    r3622 r3645  
    22  $Id$
    33
    4   Copyright (C) 2006 Jari H�kkinen
     4  Copyright (C) Authors contributing to this file.
    55
    66  This file is part of BASE - BioArray Software Environment.
     
    102102     use in MeV (available from http://www.tm4.org).
    103103   - BASEfile.
    104 
    105    @author jari, enell
     104   - Plain Matrix
     105
     106   @author enell, jari, peter
    106107   @version 2.1
    107108   @base.modified $Date$
     
    745746
    746747
    747   public void exportPureMatrix(BioAssaySet bioassayset, OutputStream to,
    748                                ProgressReporter progress)
     748  public void exportPlainMatrix(BioAssaySet bioassayset, OutputStream os,
     749                                ProgressReporter progress)
    749750    throws IOException, SQLException
    750751  {
    751752    DbControl dc=bioassayset.getDbControl();
    752     PrintWriter out = new PrintWriter(to);
    753 
     753    PrintWriter out = new PrintWriter(os);
    754754    List<ExtendedProperty> reporterProperties =
    755755      ExtendedProperties.getProperties("ReporterData");
    756756
    757     int nof_bioassays=bioassayset.getBioAssays().list(dc).size();
    758 
    759     if (progress != null)
     757    int nof_bioassays=0;
     758    nof_bioassays=bioassayset.getBioAssays().list(dc).size();
     759
     760    if (progress != null)
    760761      progress.display(0, "Exporting ... performing database query");
    761762
    762763    DynamicSpotQuery query=bioassayset.getSpotData();
     764    query.select(Dynamic.select(VirtualColumn.POSITION));
     765    query.select(Dynamic.select(VirtualColumn.COLUMN));
    763766    query.select(Dynamic.select(VirtualColumn.channel(1)));
    764767   
    765     //query.order(Orders.asc(Dynamic.column(VirtualColumn.POSITION)));
    766     //query.order(Orders.asc(Dynamic.column(VirtualColumn.COLUMN)));
     768    query.order(Orders.asc(Dynamic.column(VirtualColumn.POSITION)));
     769    query.order(Orders.asc(Dynamic.column(VirtualColumn.COLUMN)));
     770
    767771    DynamicResultIterator spotData = query.iterate(dc);
    768772    int column_position=spotData.getIndex(VirtualColumn.POSITION.getName());
     
    778782    while (spotData.hasNext())
    779783    {
    780       if (progress != null &&
    781           (nof_processed_spots%progress_spot_interval == 0))
    782       {
    783         progress.display(100 * nof_processed_spots / nof_spots,
    784                          "Exporting ... " + nof_processed_spots + " of " +
    785                          nof_spots + " done.");
    786       }
    787 
    788784      SqlResult item = spotData.next();
    789785      int thisposition=item.getInt(column_position);
    790786      short thiscolumn=item.getShort(column_column);
    791787
     788      if (progress != null &&
     789          (nof_processed_spots%progress_spot_interval == 0))
     790        {
     791          progress.display(100 * nof_processed_spots / nof_spots,
     792                           "Exporting ..." + nof_processed_spots + " of " +
     793                           nof_spots + " done.");
     794        }
     795        ++nof_processed_spots;
     796 
    792797      if (position!=thisposition) // new position
    793798      {
    794         ++nof_processed_spots;
    795799        // fill missing values before next spot
    796         while (nof_bioassays>column++) out.write("\t");
    797         column=0;
     800        while (column < nof_bioassays) {
     801          out.write("\t");
     802          ++column;
     803        }
     804        column=1;
     805        if (position != -1) // no leading newline in output
     806        {
     807          out.write("\n");
     808        }
    798809        position=thisposition;
    799         out.write("\n");
    800       }
     810      }
     811
    801812      // fill missing values up to next available column (bioassay)
    802       while (++column<thiscolumn) out.write("\t");
     813      while (column < thiscolumn)
     814      {
     815        ++column;
     816        out.write("\t");
     817      }
    803818
    804819      // Calculate expression value
     
    10491064      formats.add(FORMAT_MEV, "MultiExperiment Viewer (MeV)");
    10501065      formats.add(FORMAT_BASEFILE, "BASEfile");
     1066      formats.add(FORMAT_PLAIN_MATRIX, "Plain Matrix");
    10511067      formatParameter = new PluginParameter<String>
    10521068        ( "fileformat",
     
    12031219        }
    12041220      }
     1221      else if (format.equals(FORMAT_PLAIN_MATRIX))
     1222      {
     1223        exportPlainMatrix(bas, out, progress);
     1224      }
    12051225      else
    12061226      {
     
    12391259      "Exporter for bioassay sets. Supported formats:\n\n" +
    12401260      "- Tab Delimited, Multiple Sample Files (TDMS Format) for " +
    1241       "use in MeV (available from http://www.tm4.org).\n",
     1261      "use in MeV (available from http://www.tm4.org).\n"+
     1262      "- BASEfile, and Plain Matrix",
    12421263      "2.0",
    12431264      "2006, Base 2 development team",
     
    12671288  private static final String FORMAT_BASEFILE = "BASEfile";
    12681289  private static final String FORMAT_MEV = "MeV";
     1290  private static final String FORMAT_PLAIN_MATRIX = "Plain Matrix";
    12691291 
    12701292
Note: See TracChangeset for help on using the changeset viewer.