Changeset 3705


Ignore:
Timestamp:
Aug 29, 2007, 8:50:44 PM (14 years ago)
Author:
Peter Johansson
Message:

refs #639

File:
1 edited

Legend:

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

    r3679 r3705  
    103103     use in MeV (available from http://www.tm4.org).
    104104   - BASEfile.
    105 
    106    @author enell, jari
     105   - Plain Matrix
     106
     107   @author enell, jari, peter
    107108   @version 2.1
    108109   @base.modified $Date$
     
    747748
    748749
     750  public void exportPlainMatrix(BioAssaySet bioassayset, OutputStream os,
     751                                ProgressReporter progress)
     752    throws IOException, SQLException
     753  {
     754    DbControl dc=bioassayset.getDbControl();
     755    PrintWriter out = new PrintWriter(os);
     756    List<ExtendedProperty> reporterProperties =
     757      ExtendedProperties.getProperties("ReporterData");
     758
     759    int nof_bioassays=0;
     760    nof_bioassays=bioassayset.getBioAssays().list(dc).size();
     761
     762    if (progress != null)
     763      progress.display(0, "Exporting ... performing database query");
     764
     765    DynamicSpotQuery query=bioassayset.getSpotData();
     766    query.select(Dynamic.select(VirtualColumn.POSITION));
     767    query.select(Dynamic.select(VirtualColumn.COLUMN));
     768    query.select(Dynamic.select(VirtualColumn.channel(1)));
     769   
     770    query.order(Orders.asc(Dynamic.column(VirtualColumn.POSITION)));
     771    query.order(Orders.asc(Dynamic.column(VirtualColumn.COLUMN)));
     772
     773    DynamicResultIterator spotData = query.iterate(dc);
     774    int column_position=spotData.getIndex(VirtualColumn.POSITION.getName());
     775    int column_column=spotData.getIndex(VirtualColumn.COLUMN.getName());
     776    int column_channel=spotData.getIndex(VirtualColumn.channel(1).getName());
     777   
     778    int position=-1;
     779    int column=nof_bioassays;
     780    //double log2=Math.log(2.0);
     781    int nof_spots=bioassayset.getNumSpots();
     782    int progress_spot_interval=nof_spots/10;
     783    int nof_processed_spots=0;
     784    while (spotData.hasNext())
     785    {
     786      SqlResult item = spotData.next();
     787      int thisposition=item.getInt(column_position);
     788      short thiscolumn=item.getShort(column_column);
     789
     790      if (progress != null &&
     791          (nof_processed_spots%progress_spot_interval == 0))
     792        {
     793          progress.display(100 * nof_processed_spots / nof_spots,
     794                           "Exporting ..." + nof_processed_spots + " of " +
     795                           nof_spots + " done.");
     796        }
     797        ++nof_processed_spots;
     798 
     799      if (position!=thisposition) // new position
     800      {
     801        // fill missing values before next spot
     802        while (column < nof_bioassays) {
     803          out.write("\t");
     804          ++column;
     805        }
     806        column=1;
     807        if (position != -1) // no leading newline in output
     808        {
     809          out.write("\n");
     810        }
     811        position=thisposition;
     812      }
     813
     814      // fill missing values up to next available column (bioassay)
     815      while (column < thiscolumn)
     816      {
     817        ++column;
     818        out.write("\t");
     819      }
     820
     821      // Calculate expression value
     822      String ch1=item.getString(column_channel);
     823      out.write(ch1);
     824    }
     825    out.flush();
     826  }
     827
     828
    749829  public About getAbout()
    750830  {
     
    9861066      formats.add(FORMAT_MEV, "MultiExperiment Viewer (MeV)");
    9871067      formats.add(FORMAT_BASEFILE, "BASEfile");
     1068      formats.add(FORMAT_PLAIN_MATRIX, "Plain Matrix");
    9881069      formatParameter = new PluginParameter<String>
    9891070        ( "fileformat",
     
    11401221        }
    11411222      }
     1223      else if (format.equals(FORMAT_PLAIN_MATRIX))
     1224      {
     1225        exportPlainMatrix(bas, out, progress);
     1226      }
    11421227      else
    11431228      {
     
    11771262      "- Tab Delimited, Multiple Sample Files (TDMS Format) for " +
    11781263      "use in MeV (available from http://www.tm4.org).\n"+
    1179       "- BASEfile",
     1264      "- BASEfile, and Plain Matrix",
    11801265      "2.0",
    11811266      "2006, Base 2 development team",
     
    12051290  private static final String FORMAT_BASEFILE = "BASEfile";
    12061291  private static final String FORMAT_MEV = "MeV";
    1207 
     1292  private static final String FORMAT_PLAIN_MATRIX = "Plain Matrix";
     1293 
    12081294
    12091295  public class QueryItem
Note: See TracChangeset for help on using the changeset viewer.