Changeset 2956


Ignore:
Timestamp:
Nov 26, 2006, 11:33:11 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Addresses #430. Most things fixed for export but experimental factors wont come out. Also fixed other minor issues.

File:
1 edited

Legend:

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

    r2953 r2956  
    197197      for (String key : parameters.keySet())
    198198      {
    199         out.println(key+"/t"+parameters.get(key));
     199        out.println(key+"\t"+parameters.get(key));
    200200      }
    201201      out.println("%");
     
    204204   
    205205    // assay section   
    206     out.println("section/tassays");
     206    out.println("section\tassays");
    207207   
    208208    out.println("%");
     
    214214        out.print("\t");
    215215        Set<Object> values = BioAssaySetUtil.getAnnotationValues(dc, ba, at);
    216         for (Object v : values) out.print("/t"+v);
     216        for (Object v : values) out.print("\t"+v);
    217217      }
    218218    }
     
    220220   
    221221    // spot section(s)
    222     out.println("section/tspots");
     222    out.println("section\tspots");
    223223    out.println("%");
    224224    out.println();
     
    226226 
    227227
    228   private void exportMeV(BioAssaySet bioassayset, File file)
     228  private void exportMeV(BioAssaySet bioassayset, File file,
     229                         ProgressReporter progress)
    229230    throws IOException, SQLException
    230231  {
     
    241242    */
    242243
    243     // data header
    244     out.write("UID\tID");
     244    List<ExtendedProperty> reporterProperties =
     245      ExtendedProperties.getProperties("ReporterData");
     246
     247    // Data header
     248    // Reporter headers
     249    out.write("reporterInternalId\treporterID\tlastUpdate\tgeneSymbol");
     250    for (ExtendedProperty ep : reporterProperties)
     251      out.write("\t"+ep.getName());
     252    // Number 3 in below statement comes from using three reporter
     253    // entries from ReporterData. Below there is dependencies on this
     254    // '3' such as the selectReporter("") in below query.select()
     255    // statements (and more).
     256    int nof_reporter_columns=3+reporterProperties.size();
     257    // Bioassay headers
     258    out.write("\texperimentalFactor");
    245259    short nof_bioassays=0;
    246260    for (BioAssay bioassay : bioassayset.getBioAssays().list(dc))
     
    250264    }
    251265
    252     // data
     266    // Experimental factors
     267    for (AnnotationType at : getExperimentalFactors(dc, bioassayset))
     268    {
     269      out.write("\n");
     270      for (int i=0; i<nof_reporter_columns; ++i) out.write("\t");
     271      out.write("\t"+at.getName());
     272      for (BioAssay bioassay : bioassayset.getBioAssays().list(dc))
     273      {
     274        Set<Object> values = BioAssaySetUtil.getAnnotationValues(dc,bioassay,at);
     275        for (Object v : values) out.write("\t"+v);
     276      }
     277    }
     278
     279    progress.display(0, "Exporting ... performing database query");
     280    // Reporter annotations and expression levels
    253281    int nofchannels=bioassayset.getRawDataType().getChannels();
    254282    DynamicSpotQuery query=bioassayset.getSpotData();
     
    257285    query.select(Dynamic.select(VirtualColumn.COLUMN));
    258286    query.select(Dynamic.selectReporter("externalId"));
     287    query.select(Dynamic.selectReporter("lastUpdate"));
     288    query.select(Dynamic.selectReporter("symbol"));
     289    for (ExtendedProperty ep : reporterProperties)
     290    {
     291      query.select(Dynamic.selectReporter(ep.getName()));
     292    }
    259293    for (int i=1; i<=nofchannels; ++i)
    260294    {
     
    266300    int column_position=spotData.getIndex(VirtualColumn.POSITION.getName());
    267301    int column_column=spotData.getIndex(VirtualColumn.COLUMN.getName());
    268     int column_reporter=spotData.getIndex("externalId");
     302    int[] column_reporter= new int[nof_reporter_columns];
     303    column_reporter[0]=spotData.getIndex("externalId");
     304    column_reporter[1]=spotData.getIndex("lastUpdate");
     305    column_reporter[2]=spotData.getIndex("symbol");
     306    int idx=3;
     307    for (ExtendedProperty ep : reporterProperties)
     308    {
     309      column_reporter[idx++]=spotData.getIndex(ep.getName());
     310    }
    269311    int[] column_channel = new int[nofchannels];
    270312    for (int i=1; i<=nofchannels; ++i)
     
    275317    short column=nof_bioassays;
    276318    double log2=Math.log(2.0);
     319    int nof_reporters=bioassayset.getNumReporters();
     320    int progress_report_interval=nof_reporters/10;
     321    int nof_processed_reporters=0;
    277322    while (spotData.hasNext())
    278323    {
     324      if (nof_processed_reporters%progress_report_interval == 0)
     325      {
     326        progress.display(100 * nof_processed_reporters / nof_reporters,
     327                         "Exporting ... " + nof_processed_reporters + " of " +
     328                         nof_reporters + " done.");
     329      }
     330
    279331      SqlResult item = spotData.next();
    280332      int thisposition=item.getInt(column_position);
     
    283335      if (position!=thisposition) // new reporter
    284336      {
     337        ++nof_processed_reporters;
    285338        // fill missing values before next spot
    286339        while (nof_bioassays>column++) out.write("\t");
    287340        column=0;
    288341        position=thisposition;
    289         out.write("\npos:" + position + "\t" + item.getString(column_reporter));
     342        out.write("\n" + position);
     343        for (int i=0; i<nof_reporter_columns; ++i)
     344        {
     345          String str=item.getString(column_reporter[i]);
     346          out.write("\t" + (str!=null ? str : ""));
     347        }
     348        out.write("\t"); // experimentalFactor is always empty for reporters
    290349      }
    291350      // fill missing values up to next available column (bioassay)
     
    602661      bioassayset = BioAssaySet.getById(dc, bioassayset.getId());
    603662
    604       progress.display(1, "Exporting ...");
     663      progress.display(0, "Exporting ...");
    605664
    606665      // Add other export formats here
    607666      String format = (String) job.getValue("fileformat");
    608       if (format.equals(FORMAT_MEV)) exportMeV(bioassayset,file);
     667      if (format.equals(FORMAT_MEV)) exportMeV(bioassayset,file,progress);
    609668      else if (format.equals(FORMAT_BASEFILE))
    610669      {
Note: See TracChangeset for help on using the changeset viewer.