Ignore:
Timestamp:
Dec 7, 2007, 5:16:24 PM (14 years ago)
Author:
mbayer
Message:

writer now also writes hybs section out but still needs to be integrated with the rest of the code

Location:
branches/uk_ac_ebi_Tab2MageImporter
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/uk_ac_ebi_Tab2MageImporter/jsp/uk/ac/ebi/nugo/plugins/hybridizations.jsp

    r513 r517  
    171171  <!-- question 6 -->
    172172  <tr>
    173     <td class="boldText">Number of treatments used:</td>
    174     <td class="input"><input type="text" size="3" name="parameter:numTreatments" value="2"/></td>
     173    <td class="boldText">Number of treatment groups:</td>
     174    <td class="input"><input type="text" size="3" name="parameter:numTreatmentGroups" value="12"/></td>
    175175  </tr>
    176176
  • branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/DataBean.java

    r513 r517  
    3737  String dyeSwap;
    3838  String refSample;
    39   String numTreatments;
     39  String numTreatmentGroups;
    4040  String expFactors;
    4141  String numReplicates;
     
    190190    this.numReplicates = numReplicates;
    191191  }
    192   public String getNumTreatments()
    193   {
    194     return numTreatments;
    195   }
    196   public void setNumTreatments(String numTreatments)
    197   {
    198     this.numTreatments = numTreatments;
    199   }
    200192  public String getOrganism()
    201193  {
     
    365357  {
    366358    this.experimentId = experimentId;
     359  }
     360  public String getNumTreatmentGroups()
     361  {
     362    return numTreatmentGroups;
     363  }
     364  public void setNumTreatmentGroups(String numTreatmentGroups)
     365  {
     366    this.numTreatmentGroups = numTreatmentGroups;
    367367  }
    368368 
  • branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Tab2MageImporter.java

    r516 r517  
    112112          "treatmentProtocolParams","extractionProtocolParams","labelingProtocolParams",
    113113          "hybridizationProtocolParams","scanningProtocolParams","platform","organism",
    114           "numDesigns","dyeSwap","refSample","numTreatments","expFactors","numReplicates",
     114          "numDesigns","dyeSwap","refSample","numTreatmentGroups","expFactors","numReplicates",
    115115          "tissues","pooling","zipFile"};
    116116 
  • branches/uk_ac_ebi_Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Tab2MageWriter.java

    r516 r517  
    1313public class Tab2MageWriter
    1414{
    15 //  ===================================================vars================================================
     15  // ===================================================vars================================================
    1616
    1717  Directory dir;
     
    1919  String t2mContent = "";
    2020  ParameterValues job;
    21   String [] paramNames;
     21  String[] paramNames;
    2222
    2323  String domain;
     
    5454  String dyeSwap;
    5555  String refSample;
    56   String numTreatments;
     56  String numTreatmentGroups;
    5757  String expFactors;
    5858  String numReplicates;
     
    6161  String zipFile;
    6262  String experimentId;
    63  
    64  
    65 
    66 //  ===================================================c'tor================================================
    67 
    68   public Tab2MageWriter(ParameterValues job,Directory dir,SessionControl sc,String [] paramNames)
     63
     64  // ===================================================c'tor================================================
     65
     66  public Tab2MageWriter(ParameterValues job, Directory dir, SessionControl sc, String[] paramNames)
    6967  {
    7068    this.dir = dir;
     
    7573  }
    7674
    77   //for testing only
     75  // for testing only
    7876  public Tab2MageWriter()
    7977  {
     
    8179  }
    8280
    83 //  ===================================================methods================================================ 
    84 
    85   //sets all the values of the local variables to those found in the job object
     81  // ===================================================methods================================================
     82
     83  // sets all the values of the local variables to those found in the job object
    8684  private void initJobParamValues()
    8785  {
    8886    try
    8987    {
    90       Class cls = Class.forName("uk.ac.ebi.nugo.plugins.Tab2MageWriter");     
     88      Class cls = Class.forName("uk.ac.ebi.nugo.plugins.Tab2MageWriter");
    9189      for (int i = 0; i < paramNames.length; i++)
    9290      {
     
    10199  }
    102100
    103 //  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     101  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    104102
    105103  public String generateFileContents()
     
    111109  }
    112110
    113 //  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   
    114  
     111  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     112
    115113  private void makeExperimentSection()
    116114  {
    117     //header for this section
     115    // header for this section
    118116    t2mContent += "Experiment section\n";
    119    
    120     String [] rowHeaders = new String [] {"domain","accession","quality_control","experiment_design_type","name","description","release_date","submission_date","submitter","organization","publication_title","authors","journal","volume","issue","pages","year","pubmed_id"};
    121     String [] experimentParams = new String [] {domain,accession,qualityControl,experimentalDesign,experimentName,description,releaseDate,submissionDate,submitter,organization,publicationTitle,authors,journal,volume,issue,pages,year,pubmedId};
    122    
     117
     118    String[] rowHeaders = new String[]
     119    { "domain", "accession", "quality_control", "experiment_design_type", "name", "description",
     120            "release_date", "submission_date", "submitter", "organization",
     121            "publication_title", "authors", "journal", "volume", "issue", "pages",
     122            "year", "pubmed_id" };
     123    String[] experimentParams = new String[]
     124    { domain, accession, qualityControl, experimentalDesign, experimentName, description, releaseDate,
     125            submissionDate, submitter, organization, publicationTitle, authors,
     126            journal, volume, issue, pages, year, pubmedId };
     127
    123128    for (int i = 0; i < rowHeaders.length; i++)
    124129    {
    125130      t2mContent += rowHeaders[i] + "\t" + experimentParams[i] + "\n";
    126131    }
    127    
    128     //separate from next section by a blank line
     132
     133    // separate from next section by a blank line
    129134    t2mContent += "\n\n";
    130135  }
    131  
    132 //  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   
    133  
     136
     137  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     138
    134139  private void makeProtocolSection()
    135140  {
    136     //header for this section
     141    // header for this section
    137142    t2mContent += "Protocol section\n";
    138    
    139     //section needs to look like this:
     143
     144    // section needs to look like this:
    140145    /*
    141     accession name      text    parameters    type
    142     P-DIET-1  treatment   text            grow
    143     P-EXTR-1  extraction    text            extraction
    144     P-LABL-1  labeling      text            labeling
    145     P-HYBR-1  hybridization text            hybridization
    146     P-SCAN-1  scanning    text            scanning
     146     * accession name text parameters type P-DIET-1 treatment text grow P-EXTR-1 extraction text extraction P-LABL-1 labeling text labeling P-HYBR-1 hybridization text hybridization
     147     * P-SCAN-1 scanning text scanning
     148     */
     149    String[] accessions = new String[]
     150    { "P-DIET-1", "P-EXTR-1", "P-LABL-1", "P-HYBR-1", "P-SCAN-1" };
     151    String[] names = new String[]
     152    { "treatment", "extraction", "labeling", "hybridization", "scanning" };
     153    String[] values = new String[]
     154    { treatmentProtocol, extractionProtocol, labelingProtocol, hybridizationProtocol, scanningProtocol };
     155    String[] parameters = new String[]
     156    { treatmentProtocolParams, extractionProtocolParams, labelingProtocolParams,
     157            hybridizationProtocolParams, scanningProtocolParams };
     158    String[] types = new String[]
     159    { "grow", "extraction", "labeling", "hybridization", "scanning" };
     160
     161    // print header
     162    t2mContent += "accession\tname\ttext\tparameters\ttype\n";
     163
     164    // print rows
     165    for (int i = 0; i < accessions.length; i++)
     166    {
     167      t2mContent += accessions[i] + "\t" + names[i] + "\t" + values[i] + "\t" + parameters[i] + "\t" + types[i] + "\n";
     168    }
     169
     170    // separate from next section by a blank line
     171    t2mContent += "\n\n";
     172  }
     173
     174  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     175
     176  private void makeHybridizationsSection()
     177  {
     178    // header for this section
     179    t2mContent += "Hybridization section\n";
     180   
     181    // print column headers for the section
     182    String [] colHeaders  = new String [] {"File[raw]"," array[accession]"," BioSource"," BioMaterialCharacteristics[Organism]"," BioMaterialCharacteristics[OrganismPart]"," BioMaterialCharacteristics[CellType]"," Sample"," Protocol[grow]"," Extract"," Protocol[extraction]"," LabeledExtract"," Protocol[labeling]"," Dye"," Hybridization"," Protocol[hybridization]"," Scan"," Protocol[scanning]"," FactorValue[Treatment Type]"};
     183    for (int i = 0; i < colHeaders.length; i++)
     184    {
     185      t2mContent += colHeaders[i] + "\t";
     186    }
     187    t2mContent += "\n";
     188
     189
     190// //////////////////////////////////////////////////////////////////////////////////////////////////////////
     191
     192
     193    int count = 1;
     194   
     195    int numSubjects = Integer.parseInt(numReplicates);
     196    String [] allTissues = tissues.split(",");
     197    int numTissues = allTissues.length;
     198    int numGroups = Integer.parseInt(numTreatmentGroups);
     199   
     200    // for each treatment group
     201    for(int i = 1; i<= numGroups; i++)
     202    {
     203      int subjectCount=0;
     204      // for each subject within each group
     205      for(int j=1; j <= numSubjects; j++)
     206      {
     207        subjectCount = (i-1)*numSubjects+j;
     208        // for each target tissue
     209        for(int k= 1; k<=numTissues; k++)
     210        {
     211          //this whole first block prints the data for the first channel
     212         
     213          // file count first
     214          t2mContent += "file-" + count + ".txt" + "\t" +
     215          // accession no. i.e the array design
     216          accession + "\t" +
     217          // bio source
     218          "group-" + i + "-subject-" + subjectCount  + "\t" +
     219          // BioMaterialCharacteristics[Organism]
     220          organism  + "\t" +
     221          // BioMaterialCharacteristics[OrganismPart]
     222          allTissues[k-1]  + "\t" +
     223          // BioMaterialCharacteristics[CellType]
     224          ""   + "\t" +
     225          // sample
     226          "group-" + i + "-subject-" + subjectCount + ".sample-" + k + "\t" +
     227          // Protocol[grow]
     228          "P-DIET-1" + "\t" +
     229          // Extract
     230          "group-" + i + "-subject-" + subjectCount + ".sample-" + k  + "-extract" + "\t" +
     231          // Protocol[extraction]
     232          "P-EXTR-1"  + "\t" +
     233          // LabeledExtract
     234          "group-" + i + "-subject-" + subjectCount + ".sample-" + k  + "-extract-le" + "\t" +
     235          // Protocol[labeling]
     236          "P-LABL-1" + "\t" +
     237          // Dye
     238          "Cy3"+ "\t" +
     239          // Hybridization
     240          "hybridization-" + count + "\t" +
     241          // Protocol[hybridization]
     242          "P-HYBR-1" + "\t" +
     243          // Scan
     244          "scan-" + count  + "\t" +
     245          // Protocol[scanning]
     246          "P-SCAN-1" + "\t" +
     247          // FactorValue[Treatment Type]
     248          "trt_group" + i + "\t";
     249         
     250          //new line
     251          t2mContent += "\n";
     252         
     253          //the second block prints the data for the second channel
     254         
     255          // file count first
     256          t2mContent += "file-" + count + ".txt" + "\t" +
     257          // accession no. i.e the array design
     258          accession + "\t" +
     259          // bio source
     260          "reference" + "\t" +
     261          // BioMaterialCharacteristics[Organism]
     262          organism  + "\t" +
     263          // BioMaterialCharacteristics[OrganismPart]
     264          "multi-tissue"  + "\t" +
     265          // BioMaterialCharacteristics[CellType]
     266          "multi-cell type"   + "\t" +
     267          // sample
     268          "reference" + "\t" +
     269          // Protocol[grow]
     270          "P-DIET-1" + "\t" +
     271          // Extract
     272          "reference" + "\t" +
     273          // Protocol[extraction]
     274          "P-EXTR-1"  + "\t" +
     275          // LabeledExtract
     276          "reference" + "\t" +
     277          // Protocol[labeling]
     278          "P-LABL-1" + "\t" +
     279          // Dye
     280          "Cy5"+ "\t" +
     281          // Hybridization
     282          "hybridization-" + count + "\t" +
     283          // Protocol[hybridization]
     284          "P-HYBR-1" + "\t" +
     285          // Scan
     286          "scan-" + count  + "\t" +
     287          // Protocol[scanning]
     288          "P-SCAN-1" + "\t" +
     289          // FactorValue[Treatment Type]
     290          "reference" + "\t" ;
     291         
     292          //new line
     293          t2mContent += "\n";
     294         
     295          count++;
     296        }
     297      }
     298    }
     299   
     300           
     301// //////////////////////////////////////////////////////////////////////////////////////////////////////////
     302       
     303  }
     304
     305  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     306
     307  public void writeTab2MageFile()
     308  {
     309    try
     310    {
     311      // set up a file writer
     312      DbControl dc = sc.newDbControl();
     313      net.sf.basedb.core.File t2mFile = net.sf.basedb.core.File.getNew(dc, dir);
     314      System.out.println("dir for writing new tab2mage file = " + dir.getName());
     315      t2mFile.setName("tab2mage.txt");
     316      dc.saveItem(t2mFile);
     317
     318      if (dc == null)
     319        dc = sc.newDbControl();
     320
     321      Writer out = new BufferedWriter(new OutputStreamWriter(t2mFile.getUploadStream(false), "ISO-8859-1"));
     322
     323      // write content to file
     324      out.write(t2mContent);
     325
     326      // close writer
     327      if (out != null)
     328        out.close();
     329
     330      dc.commit();
     331      if (dc != null)
     332        dc.close();
     333    }
     334    catch (Exception e)
     335    {
     336      e.printStackTrace();
     337    }
     338  }
     339
     340  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     341
     342  private int calcNumHybs()
     343  {
     344    // get values for the parameters we need here
     345    int numReps = Integer.parseInt(numReplicates);
     346    int numTreats = Integer.parseInt(numTreatmentGroups);
     347    int numTissues = tissues.split(",").length;
     348    // Number of hybridizations (NH) = Number of subjects (NS) x Number of Target Tissue (NTT) x Number of Study groups (NSG)
     349    return numReps * numTissues * numTreats;
     350  }
     351
     352  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     353
     354  private void initTestParamValues()
     355  {
     356    /*
     357    --org Homo_sapiens
     358    --array Agilent1
     359    --single 2
     360    --ref yes
     361    --dye no
     362    --trtgroup 6
     363    --factors compound(aspirin,ibuprofen);dose(none,medium,high)
     364    --target liver,heart,brain
     365    --subject 4
    147366    */
    148     String [] accessions = new String [] {"P-DIET-1","P-EXTR-1","P-LABL-1","P-HYBR-1","P-SCAN-1"};
    149     String [] names = new String [] {"treatment","extraction","labeling","hybridization","scanning"};
    150     String [] values = new String [] { treatmentProtocol, extractionProtocol, labelingProtocol, hybridizationProtocol, scanningProtocol};
    151     String [] parameters = new String [] {treatmentProtocolParams, extractionProtocolParams,labelingProtocolParams,hybridizationProtocolParams,scanningProtocolParams};
    152     String [] types = new String [] {"grow","extraction","labeling","hybridization","scanning"};
    153    
    154     //print header
    155     t2mContent += "accession\tname\ttext\tparameters\ttype\n";
    156    
    157     //print rows
    158     for (int i = 0; i < accessions.length; i++)
    159     {
    160       t2mContent += accessions[i] + "\t" + names[i] + "\t" + values[i] + "\t" + parameters[i] + "\t" + types[i] + "\n";
    161     }
    162    
    163     //separate from next section by a blank line
    164     t2mContent += "\n\n";
    165   }
    166 
    167 //  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   
    168  
    169   private void makeHybridizationsSection()
    170   {
    171     //header for this section
    172     t2mContent += "Hybridization section\n";
    173   }
    174  
    175 //  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    176 
    177   public void writeTab2MageFile()
    178   {
    179     try
    180     {
    181       //set up a file writer
    182       DbControl dc = sc.newDbControl();
    183       net.sf.basedb.core.File t2mFile = net.sf.basedb.core.File.getNew(dc, dir);   
    184       System.out.println("dir for writing new tab2mage file = "+dir.getName());
    185       t2mFile.setName("tab2mage.txt");     
    186       dc.saveItem(t2mFile);
    187 
    188       if(dc==null)
    189         dc = sc.newDbControl();
    190 
    191       Writer out= new BufferedWriter(new OutputStreamWriter(t2mFile.getUploadStream(false),"ISO-8859-1"));
    192 
    193       //write content to file
    194       out.write(t2mContent);
    195 
    196       //close writer
    197       if (out!= null) out.close();
    198 
    199       dc.commit();
    200       if(dc!=null)
    201         dc.close();
    202     }
    203     catch (Exception e)
    204     {
    205       e.printStackTrace();
    206     }   
    207   }
    208 
    209 //  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    210  
    211   private int calcNumHybs()
    212   {
    213     //get values for the parameters we need here
    214     int numReps = Integer.parseInt(numReplicates);
    215     int numTreats = Integer.parseInt(numTreatments);   
    216     int numTissues = tissues.split(",").length;
    217     //Number of hybridizations (NH) = Number of subjects (NS) x Number of Target Tissue (NTT) x Number of Study groups (NSG)
    218     return numReps * numTissues * numTreats;
    219   }
    220 
    221 //  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    222 
    223   private void initTestParamValues()
    224   {
     367
     368    //experiment section
    225369    experimentId = "2";
    226370    domain = "scri.ac.uk";
    227     accession = "E-SCRI-001";
     371    accession = "Agilent1";
    228372    qualityControl = "biological replicate,spike quality control";
    229373    experimentalDesign = "cell_component_comparison_design,RNA_stability_design,family_history_design,";
     
    242386    year = "2007";
    243387    pubmedId = "11009762";
     388   
     389    //protocols
    244390    treatmentProtocol = "my treatment protocol text";
    245391    extractionProtocol = " my extraction protocol text";
     
    252398    hybridizationProtocolParams = "param4";
    253399    scanningProtocolParams = " param5";
    254     platform = "Affymetrix";
    255     organism = "barley";
     400   
     401    //hybs
     402    platform = "Agilent";
     403    organism = "Homo_sapiens";
    256404    numDesigns = "1";
    257405    dyeSwap = "no";
    258     refSample = "no";
    259     numTreatments = "2";
    260     expFactors = "Factor 1(value1,value2,...valueN)";
    261     numReplicates = "3";
    262     tissues = "tissues1,tissue2";
     406    refSample = "yes";
     407    numTreatmentGroups = "6";
     408    expFactors = "compound(aspirin,ibuprofen);dose(none,medium,high) )";
     409    numReplicates = "4";
     410    tissues = "liver,heart,brain";
    263411    pooling = "no";
    264412    zipFile = "/home/michab/potato_small.zip";
    265413
    266414  }
    267 //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    268 }//end class
     415  // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     416}// end class
Note: See TracChangeset for help on using the changeset viewer.