Changeset 3022


Ignore:
Timestamp:
Dec 12, 2006, 10:57:50 AM (16 years ago)
Author:
dominic
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/tab2mage_ebi/src/plugins/core/net/sf/basedb/plugins/Tab2MageExporter.java

    r3009 r3022  
    33  Copyright (C) Authors contributing to this file.
    44
     5  This file is for NutriBASE - Nutrigenomics BioArray Software Environment.
     6  A customisation of the BASE SOFTWARE.
     7 
    58  BASE is free software; you can redistribute it and/or
    69  modify it under the terms of the GNU General Public License
     
    1821  Boston, MA  02111-1307, USA.
    1922*/
    20 package net.sf.basedb.plugins;
    21 
     23package com.plugin;
    2224
    2325import java.io.BufferedWriter;
    2426import java.io.OutputStreamWriter;
    2527import java.io.Writer;
     28import java.nio.charset.Charset;
    2629import java.util.ArrayList;
    2730import java.util.Arrays;
     
    2932import java.util.Date;
    3033import java.util.HashMap;
     34import java.util.HashSet;
    3135import java.util.LinkedHashSet;
     36import java.util.LinkedHashMap;
    3237import java.util.LinkedList;
     38import java.util.Iterator;
    3339import java.util.List;
    3440import java.util.Map;
    3541import java.util.Set;
     42import java.util.TreeSet;
     43import java.text.DateFormat;
     44import java.util.TreeMap;
    3645
    37 import net.sf.basedb.core.Affymetrix;
     46import utils.Values;
     47import net.sf.basedb.core.plugin.About;
     48import net.sf.basedb.core.plugin.AbstractPlugin;
     49import net.sf.basedb.core.plugin.GuiContext;
     50import net.sf.basedb.core.plugin.InteractivePlugin;
     51import net.sf.basedb.core.plugin.AboutImpl;
     52import net.sf.basedb.core.plugin.Plugin;
     53import net.sf.basedb.core.plugin.Request;
     54import net.sf.basedb.core.plugin.Response;
     55import net.sf.basedb.core.plugin.Plugin.MainType;
     56import net.sf.basedb.core.query.Annotations;
     57import net.sf.basedb.core.query.Hql;
     58import net.sf.basedb.core.query.Orders;
     59import net.sf.basedb.core.query.Restrictions;
     60import net.sf.basedb.core.query.Expressions;
    3861import net.sf.basedb.core.Annotatable;
    3962import net.sf.basedb.core.Annotation;
    4063import net.sf.basedb.core.AnnotationSet;
    4164import net.sf.basedb.core.AnnotationType;
    42 import net.sf.basedb.core.Application;
    4365import net.sf.basedb.core.ArrayDesign;
    4466import net.sf.basedb.core.BaseException;
     67import net.sf.basedb.core.BioMaterial;
    4568import net.sf.basedb.core.BioMaterialEvent;
     69import net.sf.basedb.core.BooleanParameterType;
    4670import net.sf.basedb.core.BioSource;
    47 import net.sf.basedb.core.BooleanParameterType;
     71import net.sf.basedb.core.Client;
    4872import net.sf.basedb.core.DbControl;
    4973import net.sf.basedb.core.Experiment;
     
    5175import net.sf.basedb.core.File;
    5276import net.sf.basedb.core.Hybridization;
    53 import net.sf.basedb.core.Include;
    5477import net.sf.basedb.core.Item;
    5578import net.sf.basedb.core.ItemAlreadyExistsException;
     
    5780import net.sf.basedb.core.ItemQuery;
    5881import net.sf.basedb.core.ItemResultList;
     82import net.sf.basedb.core.Label;
    5983import net.sf.basedb.core.LabeledExtract;
     84import net.sf.basedb.core.MeasuredBioMaterial;
     85import net.sf.basedb.core.ParameterType;
    6086import net.sf.basedb.core.Path;
    6187import net.sf.basedb.core.PathParameterType;
     88import net.sf.basedb.core.PlateMapping;
    6289import net.sf.basedb.core.PluginParameter;
    6390import net.sf.basedb.core.ProgressReporter;
     
    6895import net.sf.basedb.core.Scan;
    6996import net.sf.basedb.core.StringParameterType;
     97import net.sf.basedb.core.Type;
    7098import net.sf.basedb.core.User;
    71 import net.sf.basedb.core.plugin.About;
    72 import net.sf.basedb.core.plugin.AboutImpl;
    73 import net.sf.basedb.core.plugin.AbstractPlugin;
    74 import net.sf.basedb.core.plugin.GuiContext;
    75 import net.sf.basedb.core.plugin.InteractivePlugin;
    76 import net.sf.basedb.core.plugin.Plugin;
    77 import net.sf.basedb.core.plugin.Request;
    78 import net.sf.basedb.core.plugin.Response;
    79 import net.sf.basedb.core.query.Hql;
    80 import net.sf.basedb.core.query.Orders;
    81 import net.sf.basedb.util.Values;
     99import net.sf.basedb.core.Include;
     100import net.sf.basedb.core.ArraySlide;
     101import net.sf.basedb.core.Application;
     102import net.sf.basedb.core.Affymetrix;
    82103
    83104/**
    84105  A plugin that exports an experiment in tab2mage specification for submission to ArrayExpress public repository.
    85106  @author Dominic
    86   @version 2.0
     107  @version 1.0
    87108  @base.modified $Date$
    88109*/
     
    253274    DbControl dc=null;
    254275    Set<Protocol> protocols = new LinkedHashSet<Protocol>(); //to get protocols as they are entered
     276     
    255277    Set<String> hybSectionHeader= new LinkedHashSet<String>();
    256278    Set<String>  protocolHybSectionHeader= new LinkedHashSet<String>();
    257279    Set<String>  parameterHybSectionHeader= new LinkedHashSet<String>();
    258     Map<AnnotationType, Annotation> factorValues= new HashMap<AnnotationType,Annotation>();
     280   
     281    //Map<String, String> bioMaterials= new LinkedHashMap<String, String>();
     282    //Map<String, String> arrayDataInfo= new LinkedHashMap<String,String>();
    259283    List<String> protocolRefId= new LinkedList<String>();
    260284    List<String> hybridizationDataRows=new LinkedList<String>();
    261285    List<String> parameterValues= new LinkedList<String>();
     286   
    262287    List<Annotation> expFactorValues= new LinkedList<Annotation>();
    263    
    264     List<String> twoColorHybDataRowsFirstSection=new LinkedList<String>();
    265     List<String> twoColorHybDataRowsSecondSection=new LinkedList<String>();
    266  
    267    
     288    Map<AnnotationType, Annotation> factorValues= new HashMap<AnnotationType,Annotation>();
     289    List<String> twoColorHybDataRows=new LinkedList<String>();
     290    List<String> twoColorParameterValues=new LinkedList<String>();
     291    List<String> twoColorFirstParameterValues=new LinkedList<String>();
     292    List<String> twoColorProtocolRefId= new LinkedList<String>();
     293    List<String> twoColorFirstProtocolRefId= new LinkedList<String>();
     294       
    268295    boolean overwrite = false;
    269296    boolean twoColorHyb= false;
     
    301328      Writer out= new BufferedWriter(new OutputStreamWriter(file.getUploadStream(false),"ISO-8859-1"));
    302329     
    303       // Header section
     330      /*
     331        Tab2Mage Header section
     332       */
    304333      out.write("# This file contains an experiment exported in tab2mage specification from BASE2\n\n");
    305       // Experiment Section
     334     
     335      /*
     336        Tab2Mage Experiment Section
     337       */
    306338      out.write("Experiment section \n");
    307339      out.write("domain\t"+Application.getHostName()+"\n");
     
    327359      out.write("\n");
    328360      out.flush();
    329      
    330      
     361         
    331362      // Get all protocols and hybs   
    332363      ItemQuery<RawBioAssay> rawBioAssaysQuery = experiment.getRawBioAssays();
     
    335366      for (RawBioAssay rba : rawBioAssays)
    336367      {
    337         twoColorHybDataRowsFirstSection.add("-done-"); //initialise the twocolor hyb row with -done- as the delimeter
     368        twoColorHybDataRows.add("-done-"); //initialise the twocolor hyb row with -done- as the delimeter
    338369        /*
    339370          Data files and array information section//
     
    348379          hybSectionHeader.add("File[raw]");
    349380          hybridizationDataRows.add(celFile.getName());
    350           twoColorHybDataRowsFirstSection.add(celFile.getName());
     381          twoColorHybDataRows.add(celFile.getName());
    351382          hybSectionHeader.add("File[cdf]");
    352383          hybridizationDataRows.add(cdfFile.getName());
    353           twoColorHybDataRowsFirstSection.add(cdfFile.getName());
     384          twoColorHybDataRows.add(cdfFile.getName());
    354385        }
    355386        else
     
    357388          hybSectionHeader.add("File[raw]");
    358389          hybridizationDataRows.add(rba.getName());
    359           twoColorHybDataRowsFirstSection.add(rba.getName());
     390          twoColorHybDataRows.add(rba.getName());
    360391        }
    361392        hybSectionHeader.add("Array[accession]");
    362393        hybridizationDataRows.add(arrayDesign.getName());
    363         twoColorHybDataRowsFirstSection.add(arrayDesign.getName());
     394        twoColorHybDataRows.add(arrayDesign.getName());
    364395       
    365             //Raw BioAssay protocol
     396            //Raw BioAssay protocol and parameters
    366397        protocolRefId.add(getFormattedProtocolId(rba.getProtocol()));
     398        twoColorFirstProtocolRefId.add(getFormattedProtocolId(rba.getProtocol()));
    367399        protocolHybSectionHeader.add("Protocol[image_analysis]");
    368         //if (rba.getProtocol()!=null)
    369         //{
    370           protocols.add(rba.getProtocol()); //rawbioassay protocol
    371          
    372         //  System.out.println("raw bioassay protocol: P-BASE-"+rba.getProtocol().getId());
    373         //}
     400        protocols.add(rba.getProtocol()); //rawbioassay protocol
    374401        if (rba.isAnnotated())
    375402        {
     
    383410              for (int i=0; i<annotation.getValues().size(); i++)
    384411              {
    385                 parameterValues.add(annotation.getValues().get(i).toString());
     412                if (annotation.getValues().get(i)!=null)
     413                {
     414                  parameterValues.add(annotation.getValues().get(i).toString());
     415                  //twoColorParameterValues.add(annotation.getValues().get(i).toString());
     416                  twoColorFirstParameterValues.add(annotation.getValues().get(i).toString());
     417                }
     418                else
     419                {
     420                  System.out.println("Here becuase the annotation value for parameter at raw bioassay  is null");
     421                  parameterValues.add("\t");
     422                }
    386423              }
    387424            }
    388             //else
    389             //{
    390             //  parameterValues.add("\t");
    391             //}
     425           
    392426          }
    393427        }
    394           //Scanning and Protocol
     428          //Scanning Protocol and Parameters
    395429        Scan scan= rba.getScan();
    396430        Protocol scanProtocol =scan.getProtocol();
    397431        protocolRefId.add(getFormattedProtocolId(scanProtocol));
     432        twoColorFirstProtocolRefId.add(getFormattedProtocolId(scanProtocol));
    398433        protocolHybSectionHeader.add("Protocol[scanning]");
    399         protocols.add(scanProtocol);  //scaning protocol
     434        protocols.add(scanProtocol);  //scanning protocol
    400435        if (scan.isAnnotated())
    401436        {
     
    409444              for (int i=0; i<annotation.getValues().size(); i++)
    410445              {
    411                 parameterValues.add(annotation.getValues().get(i).toString());
     446                if (annotation.getValues().get(i)!=null)
     447                {
     448                  parameterValues.add(annotation.getValues().get(i).toString());
     449                  //if (twoColorHyb)twoColorParameterValues.add(annotation.getValues().get(i).toString());
     450                  twoColorFirstParameterValues.add(annotation.getValues().get(i).toString());
     451                }
     452                else
     453                {
     454                  parameterValues.add("\t");
     455                  twoColorFirstParameterValues.add("\t");
     456                }
    412457              }
    413458            }
    414             //else
    415             //{
    416           //    parameterValues.add("\t");
    417           //  }
     459           
    418460          }
    419461        }
    420462       
    421         //Hybridization
     463          //Hybridization
    422464        Hybridization hyb= scan.getHybridization();
    423465        hybSectionHeader.add("Array[serial]");
    424466        hybridizationDataRows.add(hyb.getArraySlide().getName());
    425         twoColorHybDataRowsFirstSection.add(hyb.getArraySlide().getName());     
     467        twoColorHybDataRows.add(hyb.getArraySlide().getName());     
    426468        /*
    427469          Names of materials and processes section
     
    429471        hybSectionHeader.add("Hybridization");
    430472        hybridizationDataRows.add(hyb.getName());
    431         twoColorHybDataRowsFirstSection.add(hyb.getName());
     473        twoColorHybDataRows.add(hyb.getName());
    432474       
    433475        System.out.println("The number of scans: "+hyb.countScans()); // count scans that created the hyb
     
    437479        protocols.add(hybProtocol);
    438480        protocolRefId.add(getFormattedProtocolId(hybProtocol));
     481        twoColorFirstProtocolRefId.add(getFormattedProtocolId(hybProtocol));
    439482        protocolHybSectionHeader.add("Protocol[hybridization]");
    440483        if (hyb.isAnnotated())
     
    450493              {
    451494                parameterValues.add(annotation.getValues().get(i).toString());
     495                //if (twoColorHyb)twoColorParameterValues.add(annotation.getValues().get(i).toString());
     496                twoColorFirstParameterValues.add(annotation.getValues().get(i).toString());
    452497              }
    453498            }
     
    463508        int hybsize=labeledExtracts.size();
    464509        int count=1;
    465         //STOPPED HERE (LAST CODE) TRYING TO IMPLEMENT TWO COLOR HYBS
    466         //if (hybsize==2 && !hybridizationDataRows.contains("-done-"))
    467         //{
    468         //  twoColorHybDataRowsFirstSection.addAll(hybridizationDataRows); //create anew data row for 2 color experiment
    469         //  twoColorHybDataRowsSecondSection.addAll(hybridizationDataRows);
    470         //  twoColorHyb=true;
    471         //}else if(hybsize==2 && twoColorHyb )
    472         //{ //NOTE THE OUTPUT SHOWS THAT i AM ADDING THE LAST INFORMATION, SO FIX THIS
    473         //  twoColorHybDataRowsFirstSection.addAll(twoColorHybDataRowsSecondSection);
    474         //}
    475         // END OF LAST CODE
    476         System.out.println("The size of the two color data hyb data row before the labeled extract section: " +twoColorHybDataRowsFirstSection.size());
    477         System.out.println("The size of the hyb data row before adding to tow color hyb row: " +hybridizationDataRows.size());
     510        System.out.println("The size of the two color data hyb data row before the labeled extract section: " +twoColorHybDataRows.size());
     511        System.out.println("The size of the tow color param value before adding the labeled extract section is: " +twoColorFirstParameterValues.size());
    478512        System.out.println(hybsize ==1 ? "Affy Expriment. Hyb size:"+hybsize :"2 - color Expreriment. Hyb size : "+hybsize );
    479513        for (LabeledExtract labeledExtract :labeledExtracts) // can have more than one labeled extract (2 color experiments)
    480514        {
    481          
    482515            //  labeled extract
    483516          hybSectionHeader.add("LabeledExtract");
    484           if (count<hybsize)
    485           {
    486             hybridizationDataRows.add(labeledExtract.getName());
    487           }
    488           else if (count==2)
    489           {
    490             twoColorHyb=true;
    491             twoColorHybDataRowsFirstSection.add(labeledExtract.getName());
    492           }
    493        
     517          protocolHybSectionHeader.add("Protocol[labeling]");
    494518          Protocol lbExtractProtocol= labeledExtract.getCreationEvent().getProtocol();
    495519          protocols.add(lbExtractProtocol); // labeled extract protocol
    496           protocolRefId.add(getFormattedProtocolId(lbExtractProtocol));
    497           protocolHybSectionHeader.add("Protocol[labeling]");
     520          if (count<hybsize || count==1)
     521          {
     522            hybridizationDataRows.add(labeledExtract.getName());
     523            protocolRefId.add(getFormattedProtocolId(lbExtractProtocol));
     524     
     525          }
     526          else if (count==2)
     527          {
     528            twoColorHyb=true;
     529            twoColorHybDataRows.add(labeledExtract.getName());
     530            twoColorProtocolRefId.add(getFormattedProtocolId(lbExtractProtocol));
     531          }
    498532          if (labeledExtract.isAnnotated())
    499533          {
     
    507541                for (int i=0; i<annotation.getValues().size(); i++)
    508542                {
    509                   parameterValues.add(annotation.getValues().get(i).toString());
     543                  if (count < hybsize || count==1)
     544                  {
     545                    parameterValues.add(annotation.getValues().get(i).toString());
     546                  }
     547                  else if(count==2)
     548                  {
     549                    twoColorParameterValues.add(annotation.getValues().get(i).toString());
     550                  }
    510551                }
    511552              }
     
    516557            }
    517558          }
     559            // Label
    518560          String labelName= labeledExtract.getLabel().getName(); // the name of the label
    519561          hybSectionHeader.add("Dye");
     
    524566          else if (count==2)
    525567          {
    526             twoColorHybDataRowsFirstSection.add(labelName);
     568            twoColorHybDataRows.add(labelName);
    527569          }
    528570            //  Extract
     
    533575          {
    534576            hybSectionHeader.add("Extract");
    535             if (count < hybsize)
    536             {
    537               hybridizationDataRows.add(extract.getName());
    538             }
    539             else if (count==2)
    540             {
    541               twoColorHybDataRowsFirstSection.add(extract.getName());
    542             }
    543            
     577            protocolHybSectionHeader.add("Protocol[extraction]");
    544578            Protocol extractProtocol =extract.getCreationEvent().getProtocol(); //extract protocol
    545579            protocols.add(extractProtocol);
    546             protocolRefId.add(getFormattedProtocolId(extractProtocol));
    547             protocolHybSectionHeader.add("Protocol[extraction]");
     580            if (count < hybsize || count==1)
     581            {
     582              hybridizationDataRows.add(extract.getName());
     583              protocolRefId.add(getFormattedProtocolId(extractProtocol));
     584            }
     585            else if (count==2)
     586            {
     587              twoColorHybDataRows.add(extract.getName());
     588              twoColorProtocolRefId.add(getFormattedProtocolId(extractProtocol));
     589            }
     590           
    548591            if (extract.isAnnotated())
    549592            {
     
    558601                  {
    559602                    System.out.println("The extract protocol parameter is :" + annotation.getValues().get(i).toString());
    560                     parameterValues.add(annotation.getValues().get(i).toString());
     603                    if (count < hybsize || count==1)
     604                    {
     605                      parameterValues.add(annotation.getValues().get(i).toString());
     606                    }
     607                    else if(count==2)
     608                    {
     609                      twoColorParameterValues.add(annotation.getValues().get(i).toString());
     610                    }
    561611                  }
    562612                }
     
    570620         
    571621            //Sample
    572           Set<Annotatable>sampleOrPooledExtract= extract.getAnnotatableParents(); //get the sample or pooled extract
     622          //Set<Annotatable>sampleOrPooledExtract= extract.getAnnotatableParents(); //get the sample or pooled extract
    573623          Sample sample =extract.getSample(); // The sample, extract is created from
    574624          if (sample != null)
    575625          {
    576626            hybSectionHeader.add("Sample");
    577             if (count < hybsize)
     627            protocolHybSectionHeader.add("Protocol[treatment]");
     628            Protocol sampleProtocol=sample.getCreationEvent().getProtocol();      //sampling protocol
     629            protocols.add(sampleProtocol);
     630            if (count < hybsize || count==1)
    578631            {
    579632              hybridizationDataRows.add(sample.getName());
     633              protocolRefId.add(getFormattedProtocolId(sampleProtocol));
    580634            }
    581635            else if (count==2)
    582636            {
    583               twoColorHybDataRowsFirstSection.add(sample.getName());
     637              twoColorHybDataRows.add(sample.getName());
     638              twoColorProtocolRefId.add(getFormattedProtocolId(sampleProtocol));
    584639            }
    585640           
    586             Protocol sampleProtocol=sample.getCreationEvent().getProtocol();      //sampling protocol
    587             protocols.add(sampleProtocol); 
    588             protocolRefId.add(getFormattedProtocolId(sampleProtocol));
    589             protocolHybSectionHeader.add("Protocol[treatment]");
    590               // sample protocol parameter
     641              // sampling protocol parameter
    591642            if (sample.isAnnotated())
    592643            {
    593644              ItemQuery<Annotation> annotationsQuery = sample.getAnnotationSet().getAnnotations();
     645              annotationsQuery.include(Include.MINE,Include.IN_PROJECT, Include.SHARED);
    594646              ItemResultList<Annotation> annotations= annotationsQuery.list(dc);
    595647              for (Annotation annotation: annotations)
    596648              {
     649               
    597650                if (sampleProtocol.isParameter(annotation.getAnnotationType()))
    598651                {
     
    600653                  for (int i=0; i<annotation.getValues().size(); i++)
    601654                  {
    602                     System.out.println("The sample protocl parameter is :" + annotation.getValues().get(i).toString());
    603                     parameterValues.add(annotation.getValues().get(i).toString());
     655                    System.out.println("The sample protocol parameter is :" + annotation.getValues().get(i).toString());
     656                    if (annotation.getValues().get(i)!=null)
     657                    {
     658                      if (count < hybsize || count==1)
     659                      {
     660                        parameterValues.add(annotation.getValues().get(i).toString());
     661                      }
     662                      else if(count==2)
     663                      {
     664                        twoColorParameterValues.add(annotation.getValues().get(i).toString());
     665                      }
     666                    }
     667                    else if(annotation.getValues().get(i)!=null)
     668                    {
     669                      System.out.println(annotation.getAnnotationType().getName()+ " is not a PARAMETER");
     670                      parameterValues.add("\t");
     671                    }
     672                   
    604673                  }
    605674                }
    606675                //else
    607676                //{
    608                 //  parameterValues.add("\t");
     677                  //System.out.println(annotation.getAnnotationType().getName()+ " is not a PARAMETER");
     678                  //parameterValues.add("\t");
    609679                //}
    610680              }
     
    618688           
    619689            hybSectionHeader.add("Biosource");
    620             if (count < hybsize)
     690            if (count < hybsize || count==1)
    621691            {
    622692              hybridizationDataRows.add(bioSource.getName());
     
    624694            else if(count==2)
    625695            {
    626               twoColorHybDataRowsFirstSection.add(bioSource.getName());
     696              twoColorHybDataRows.add(bioSource.getName());
    627697            }
    628698            AnnotationSet bsAnnotationSet =bioSource.getAnnotationSet();
     
    637707                for (int i=0; i<annotation.getValues().size(); i++)
    638708                {
    639                   if (count < hybsize)
     709                  if (count < hybsize || count==1)
    640710                  {
    641711                    hybridizationDataRows.add(annotation.getValues().get(i).toString());
     
    643713                  else if(count==2)
    644714                  {
    645                     twoColorHybDataRowsFirstSection.add(annotation.getValues().get(i).toString());
     715                    twoColorHybDataRows.add(annotation.getValues().get(i).toString());
    646716                  }
    647                  
    648717                }
    649718              }
     
    655724        } //end of labeled extract loop
    656725       
    657         System.out.println("THE VALUE OF COUNT IS: "+ count);
    658         //for (String protcolId : protocolRefId) //add protocol id
    659         //{
     726        //System.out.println("THE VALUE OF COUNT IS: "+ count);
     727          // add protocol hyb ref ids
     728        for (String protcolId : protocolRefId) //add protocol id
     729        {
    660730          //System.out.println("----Test protocol id added----");
    661731          //System.out.println("Id: "+protcolId);
    662         /// hybridizationDataRows.add(protcolId);
    663         //}
    664         //for (String paramValue : parameterValues ) //add parameter values
    665         //{
     732          hybridizationDataRows.add(protcolId);
     733        }
     734        if (twoColorHyb)
     735        {
     736          twoColorFirstProtocolRefId.addAll(twoColorProtocolRefId);
     737          for (String protocolId : twoColorFirstProtocolRefId )
     738          {
     739            twoColorHybDataRows.add(protocolId);
     740          }
     741        }
     742          //  add parameter values
     743        for (String paramValue : parameterValues )
     744        {
    666745          //System.out.println("----Test parametervalue added----");
    667         //  hybridizationDataRows.add(paramValue);
    668         //}
     746          hybridizationDataRows.add(paramValue);
     747        }
     748        if (twoColorHyb)
     749        {
     750          twoColorFirstParameterValues.addAll(twoColorParameterValues);
     751          for (String paramValue : twoColorFirstParameterValues  )
     752          {
     753            twoColorHybDataRows.add(paramValue);
     754          }
     755        }
     756       
    669757        /*
    670758          Experimental Factor Section
     
    678766            {
    679767              hybridizationDataRows.add(Values.getEmptyStringIfNull(value.getValues().get(i).toString()).toString());
     768              if (twoColorHyb) twoColorHybDataRows.add(Values.getEmptyStringIfNull(value.getValues().get(i).toString()).toString());
    680769            }
    681770          }
     
    683772          {
    684773            hybridizationDataRows.add("\t");
    685           }
    686         }
    687         if (twoColorHyb)
    688         {
    689           //twoColorHybDataRowsFirstSection.add("-done-");
    690           hybridizationDataRows.addAll(twoColorHybDataRowsFirstSection);
    691           //hybridizationDataRows.add("-done-");
    692         }
     774            if (twoColorHyb) twoColorHybDataRows.add("\t");
     775          }
     776        }
     777       
     778        if (twoColorHyb)hybridizationDataRows.addAll(twoColorHybDataRows);
     779        // clear all necessary data holder for reuse
    693780        protocolRefId.clear();
    694781        parameterValues.clear();
    695782        factorValues.clear();
    696         if (!twoColorHybDataRowsFirstSection.isEmpty())
    697         {
    698           twoColorHybDataRowsFirstSection.clear();
     783        twoColorParameterValues.clear();
     784        twoColorFirstParameterValues.clear();
     785        twoColorFirstProtocolRefId.clear();
     786        twoColorProtocolRefId.clear();
     787        if (!twoColorHybDataRows.isEmpty())
     788        {
     789          twoColorHybDataRows.clear();
    699790          twoColorHyb=false;
    700791        }
     
    716807      }
    717808     
    718       //Protocol Section
     809      /*
     810        Tab2Mage Protocol Section
     811       */
    719812      out.write("Protocol section \n");
    720813      out.write("accession\ttext\tname\ttype\tparameters\n");
     
    745838      out.flush();
    746839     
    747       //Hybridization Section
     840      /*
     841        Tab2Mage Hybridization Section
     842       */
    748843      out.write("Hybridization section \n"); 
     844        //header
    749845      for (String header:hybSectionHeader)
    750846      {
     
    753849     
    754850      out.write("\n");
    755       //values
     851        //values
    756852      for (String hybRow: hybridizationDataRows)
    757853      {
     
    765861        }
    766862      }
    767       //for (String twoColor :twoColorHybDataRowsFirstSection )
    768       //{
    769       //  if (twoColor!="-done-")
    770       //  {
    771       //    out.write(twoColor+"\t");
    772       //  }
    773       //  else if("-done-".equals(twoColor))
    774       //  {
    775       //    out.write("\n");
    776       //  }
    777       //}
    778863      out.write("\n");
    779864   
     
    792877    }       
    793878  }
    794   //   get all the experimental factors for this experiments,
     879  /**
     880     get all the experimental factors for an experiments
     881     @param DcControl dc, the database control
     882     @param Experiment experiment, the experiment
     883     @param RawBioassay, the rawbioassay that the experimental factors are obtained from
     884     @return List, list of annotations
     885   */
    795886  private static List<Annotation> getExperimentalFactorValues(DbControl dc, Experiment experiment, RawBioAssay rba)
    796887  {
     
    799890    experimentalFactorsQuery.include(Include.MINE,Include.IN_PROJECT, Include.SHARED, Include.OTHERS);
    800891    ItemResultList<AnnotationType> experimentalFactors = experimentalFactorsQuery.list(dc);
    801     for (AnnotationType exprFactor :experimentalFactors) //create the factor value for this experiment obtaining annotations from rawbioassay
     892    for (AnnotationType exprFactor :experimentalFactors) //create the expr factor value for this experiment, obtaining annotations from rawbioassay
    802893    {
    803894      factorValuesHybSectionHeader.add("FactorValue["+exprFactor.getName()+"]");
     
    811902    return values;
    812903  }
    813   // get the base format id for the protocol if protocol is null and empty string is returned , this helps to  mentain the tab delim format
     904  /**
     905    Gets the base format id for the protocol, if protocol is null and tab string is returned
     906    this is required to have consistent tab delimeted format
     907    @param protocol, the protocol used in the experiment
     908    @return protocol id, this is a tab when the protocol is null
     909   */
    814910  private static String getFormattedProtocolId (Protocol protocol)
    815911  {
    816     String empty="";
     912    String tab="\t";
    817913    String protocolId;
    818914    if (protocol!=null)
     
    822918    else
    823919    {
    824       protocolId= empty;
     920      protocolId= tab;
    825921    }
    826922    return  protocolId ;
Note: See TracChangeset for help on using the changeset viewer.