Changeset 468


Ignore:
Timestamp:
Nov 12, 2007, 5:47:38 PM (14 years ago)
Author:
dominic
Message:

added newly changed code. This source code is not in sycn with the current released version of the tab2mage importer.

Location:
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/RawDataValidation.java

    r459 r468  
    1212  Note: seperate implementation to base1/ baseloader
    1313    @author Dominic Oyeniran
    14   @email oyeniran@ebi.ac.uk
     14  @email
    1515  @version 1.0
    1616 */
  • trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/Tab2MageHybridizationValidation.java

    r459 r468  
    6161  protected Path spath;
    6262 
     63  // must be added from the HybridizationValidation interface
    6364  protected String path;
    6465  /**
     
    130131      for(Tab2MAGEHybridization hyb : hybs)
    131132      {
     133        // check if the raw data files really exist
    132134        log.info("Checking that file exist.......");
    133135        List<String> fileErrors= checkIfFilesExist(hyb,  spath);
     
    135137       
    136138        log.info("Checking that file has proper type......");
     139        // check if the files have the proper type
     140       
    137141        List<String> fileTypesErrors = checkFileTypes(hyb, platform);
    138142        if (!fileTypesErrors.isEmpty())errors.addAll(fileTypesErrors);
     
    145149        }
    146150      }
     151     
    147152      if (!errors.isEmpty())
    148153      {
     
    172177      Validate the hybridization headers from the Tab2MAGE file.
    173178      This code MUST be modified for MAGE-TAB implementation.
     179      [TODO] convert all headers to lowercase, to facilitate matching of hyb section header to Tab2mageConstants/Spec
    174180      @param header an <code>ArrayList</code> with all headers from the Tab2MAGE file
    175181      @return true if the headers are valid, false otherwise
     
    177183  public static boolean validateHeader(ArrayList<String> header, Writer writer)
    178184  {
     185    //[TODO] convert all headers to lowercase, to facilitate matching of hyb section header to Tab2mageConstants/Spec
    179186    //header= header2LowerCase(header);
    180187    List<String> headerErrors = new LinkedList<String>();
     
    185192      {
    186193        log.error("The column \"" + Tab2MageConstants.hybridization.getName() + "\" wasn't found!");
     194        //valid = false;
    187195        headerErrors.add("The column \"" + Tab2MageConstants.hybridization.getName() + "\" wasn't found!");
    188196      }
     
    191199      {
    192200        log.error("The column \"" + Tab2MageConstants.labeledextract.getName() + "\" wasn't found!");
     201        //valid = false;
    193202        headerErrors.add("The column \"" + Tab2MageConstants.labeledextract.getName() + "\" wasn't found!");
    194203      }
     
    197206      {
    198207        log.error("The column \"" + Tab2MageConstants.dye.getName() + "\" wasn't found!");
     208        //valid = false;
    199209        headerErrors.add("The column \"" + Tab2MageConstants.dye.getName() + "\" wasn't found!");
    200210      }
     
    203213      {
    204214        log.error("The column \"" + Tab2MageConstants.extract.getName()+ "\" wasn't found!");
     215        //valid = false;
    205216        headerErrors.add("The column \"" + Tab2MageConstants.extract.getName()+ "\" wasn't found!");
    206217      }
     
    209220      {
    210221        log.error("The column \"" + Tab2MageConstants.sample.getName() + "\" wasn't found!");
     222        //valid = false;
    211223        headerErrors.add("The column \"" + Tab2MageConstants.sample.getName() + "\" wasn't found!");
    212224      }
     
    215227      {
    216228        log.error("The column \"" + Tab2MageConstants.biosource.getName() + "\" wasn't found!");
     229        //valid = false;
    217230        headerErrors.add("The column \"" + Tab2MageConstants.biosource.getName() + "\" wasn't found!");
    218231      }
     
    221234      {
    222235        log.error("The column \"" + Tab2MageConstants.array_accession.getName() + "\" wasn't found!");
     236        //valid = false;
    223237        headerErrors.add("The column \"" + Tab2MageConstants.array_accession.getName() + "\" wasn't found!");
    224238      }
     239     
     240      /*
     241         a bit flexible to accommodate non provision of array serial
     242       */
     243      //if (!header.contains(Tab2MAGEHybridization.ARRAY + "[" + Constants.ARRAY_SERIAL + "]")){
     244      //  log.error("The column \"" + Tab2MAGEHybridization.ARRAY + "[" + Constants.ARRAY_SERIAL + "]" + " wasn't found!");
     245      //  valid = false;
     246      //}
     247     
     248      /*
     249        check for biomaterial characteristics - simply biosource annotation in base2.
     250        And exisitence of experimental factors
     251        NOTE: "Characteristics" would be used for MAGE-TAB implementation
     252       */
     253   
    225254     
    226255      cont:
     
    244273      {
    245274        log.error("At least one BioMaterial Characteristics should be provided!");
     275        //valid = false;
    246276        headerErrors.add("At least one BioMaterial Characteristics should be provided!");
    247277      }
     
    250280      {
    251281        log.error("At least one Experimental Factor should be provided!");
     282        //valid = false;
    252283        headerErrors.add("At least one Experimental Factor should be provided!");
    253284      }
     
    275306          {
    276307            log.error("The protocol column \"" + head + "\" is not a valid protocol format allowed in the tab2mage specification!");
     308            //valid = false;
    277309            headerErrors.add("The protocol column \"" + head + "\" is not a valid protocol format allowed in the tab2mage specification!");
    278310          }
     
    282314      if(!tmpValid1 || !tmpValid2 || !tmpValid3){
    283315        log.error("The protocol columns of the Tab2MAGE hybridization section aren't valid!");
     316        //valid = false;
    284317        headerErrors.add("The protocol columns of the Tab2MAGE hybridization section aren't valid!");
    285318      }
     
    294327          {
    295328            log.error("The parameter " + head + " does not match parameters specified in the protocol section!");
     329            //valid = false;
    296330            headerErrors.add("The parameter: [" + head + "] does not match parameters specified in the protocol section!");
    297331          }
     
    352386        {
    353387          log.error("The raw data file [" + hyb.getFileRaw() + "] doesn't exist or couldn't be accessed!");
     388          //return false;
    354389          errs.add("The raw data file [" + hyb.getFileRaw() + "] doesn't exist or couldn't be accessed!");
    355390        }
     391       
    356392      }
    357393     
     
    361397        {
    362398          log.error("The image file [" + hyb.getFileImage() + "] doesn't exist or couldn't be accessed!");
     399          //return false;
    363400          errs.add("The image file [" + hyb.getFileImage() + "] doesn't exist or couldn't be accessed!");
    364401        }
    365402      }
     403    /*
     404      Uncomment to ADD support for cdf and chp file
     405     */
     406      //System.out.println("cheking the cdf file.....");
     407      //if(hyb.getFileCDF() != null)
     408      //{
     409      //  if(!File.exists(dc, dir, hyb.getFileCDF()))
     410      //  {
     411      //    log.error("The cdf file " + hyb.getFileCDF() + " doesn't exist or couldn't be accessed!");
     412      //    return false;
     413      //  }
     414      //}
     415      //System.out.println("cheking the chp file.....");
     416      //if(hyb.getFileCHP() != null && !hyb.getFileCHP().equals("NA"))
     417      //{
     418      //  if (!File.exists(dc, dir, hyb.getFileCHP()))
     419      //  {
     420      //    log.error("The chp file " + hyb.getFileCHP() + " doesn't exist or couldn't be accessed!");
     421      //    return false;
     422      //  }
     423      //}
     424     
     425      /*
     426        code to be used for support of file[normalised], file[transformed] not supported yet in Base2
     427        hyb.getFileTransformed and hyb.getFileNormalised should be added to Tab2MAGEHybridization Class.
     428     
     429     
     430      //if(hyb.getFileTransformed() != null )
     431      //{
     432      //  if (!File.exists(dc, directory, hyb.getFileTransformed()))
     433      //  {
     434      //    log.error("The transformed file " + hyb.getFileTransformed() + " doesn't exist or couldn't be accessed!");
     435      //    return false;
     436      //  }
     437      //}
     438     
     439      //if(hyb.getFileNormalised() != null )
     440      //{
     441      //  if (!File.exists(dc, directory, hyb.getFileNormalised()))
     442      //  {
     443      //    log.error("The normalised file " + hyb.getFileNormalised() + " doesn't exist or couldn't be accessed!");
     444      //    return false;
     445      //  }
     446      //}
     447     
     448      END OF THE SECTION TO ADD FUNCTIONALITY ADD-ONS.
     449     */
    366450    }
    367451    catch (Throwable tr)
     
    390474      {
    391475        log.error("The raw data file from the hybridization [" + hyb.getName() + "] has not the proper type.");
     476        //return false;
    392477        er.add("The raw data file from the hybridization [" + hyb.getName() + "] has not the proper type.");
    393478      }
     
    401486        {
    402487          log.error("The CHP file from the hybridization [" + hyb.getName() + "] has not the proper type.");
     488          //return false;
    403489          er.add("The CHP file from the hybridization [" + hyb.getName() + "] has not the proper type.");
    404490        }
     
    412498      {
    413499        log.error("The GPR file from the hybridization [" + hyb.getName() + "] has not the proper type.");
     500        //return false;
    414501        er.add("The GPR file from the hybridization [" + hyb.getName() + "] has not the proper type.");
    415502      }
    416503    }
     504   
     505    //add code to check other raw data file here, do extend the experiment platform enum class too
     506   
    417507    return er;
    418508  }
     
    521611  }
    522612 
     613 
    523614  public void setAllowSlideCreation(boolean allowSlideCreation)
    524615  {
  • trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/Tab2MageImportValidatorUtils.java

    r458 r468  
    186186        if (parameterAnnotationType.containsKey(e.getKey()))
    187187        {
    188           log.info("Found Parameter key : [" + e.getKey()+ "] and value is :" + parameterAnnotationType.get(e.getKey()));
     188          //log.info("Found Parameter key : [" + e.getKey()+ "] and value is :" + parameterAnnotationType.get(e.getKey()));
    189189          parameter="true";
    190190        }
     191        //log.info(".....checking biomat map");
    191192        if (bioMaterialAnnotationType.containsKey(e.getKey()))
    192193        {
    193           log.info("Found BioMat key: [" + e.getKey()+ "] and value is :" + bioMaterialAnnotationType.get(e.getKey()));
     194          //log.info("Found BioMat key: [" + e.getKey()+ "] and value is :" + bioMaterialAnnotationType.get(e.getKey()));
    194195          items.add("biosource");
    195196        }
    196          
     197        //log.info(".....checking factor value map");
    197198        if (factorValueAnnotationType.containsKey(e.getKey()))
    198199        {
    199           log.info("Found Factor Value key: [" + e.getKey()+ "] and value is :" + factorValueAnnotationType.get(e.getKey()));
     200          //log.info("Found Factor Value key: [" + e.getKey()+ "] and value is :" + factorValueAnnotationType.get(e.getKey()));
    200201          items.add("rawbioassay");
    201202        }
     
    228229  }
    229230  /**
    230     creates a simple flatfile into a specified directory using the format of existing similar file
     231    creates a simple flatfile into a specified directory using the format of exisiting similar file
    231232      @param dc, the db control
    232233      @param dir, the directory- parent directory
  • trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/Tab2MageProtocolValidation.java

    r458 r468  
    7979                log.error("The protocol type is empty. Must be provided");
    8080                errors.add("Protocol Type for protocol with accession number: [" + protocol.getAccession()+ "] is empty. Must be provided");
     81                //return false;
    8182            }
    8283           
    8384            //check if protocol is allowed in tab2mage.
     85         
    8486            Set<Tab2MageConstants> allowedProtocols = Collections.unmodifiableSet(Tab2MageConstants.protocolContants());
    8587          for  (Tab2MageConstants  allowedProtocol : allowedProtocols  )
     
    9395          if(!allowed)
    9496            {
     97                // if it is not reachable log the error message and stop
    9598                log.error("The protocol : " + protocol.getName() + " isn't permissible in the tab2mage specification.!");
     99                //return false;
    96100                errors.add("The protocol : [" + protocol.getName() + "] isn't permissible in the tab2mage specification.!");
    97101            }
    98102         
    99103          // check if all protocol types are reachable in base2
     104         
    100105          ItemQuery<ProtocolType> protocolTypesQuery = ProtocolType.getQuery();
    101106          ItemResultList<ProtocolType> protocolTypes =protocolTypesQuery.list(dc);
     
    111116          }
    112117          if(!found)
    113           {
     118           {
     119                // if it is not reachable log the error message and stop
    114120                log.warn("The protocol type: " + protocol.getType() + " isn't existing in BASE.!\n The importer may FAIL and your experiment may not be loaded");
    115121                errors.add("The protocol type: [" + protocol.getType() + "] isn't existing in BASE.!\n The importer may FAIL and your experiment may not be loaded");
    116           }
     122                //    return false;
     123           }
    117124         
    118125          // check name and accession
     
    121128                log.error("A protocol accession is empty.");
    122129                errors.add("A protocol accession is empty in the protocol section. Must be provided to proceed");
     130                //return false;
    123131            }
    124132            if(protocol.getName().equals("") || protocol.getName() == null)
     
    126134                log.error("A protocol name is empty.");
    127135                errors.add("A protocol name is empty in the protocol section. Must be provided to proceed");
    128             }
     136                //return false;
     137            }
     138           
    129139            getAllProtocolParameters(protocol);
    130140        }
     
    196206    Tab2MageProtocolValidation.protocolParameters = protocolParameters;
    197207  }
     208
    198209}
  • trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/Tab2MageValidationFactory.java

    r458 r468  
    132132    response = resp;
    133133    statusFile = file; 
     134    //this calls the Tab2mage file validation routine
     135    //validateTab2MageFile();
    134136    createWriter();
    135137  }
     
    198200   */
    199201  @SuppressWarnings("static-access")
     202  //public void validateTab2MageFile()
    200203  public Map<ValidationConstants, Boolean> validateTab2MageFile()
    201204  {
     
    246249      }
    247250                 
     251      // Display the protocols only for debugging     
     252      //log.info("\n+++++++++++++++++++++++ALL THE PROTOCOLS++++++++++++++++++++++++++++++++++++++\n");
     253      //for (Tab2MAGEProtocol p : protocols)
     254      //{
     255      //  log.warn(p.getAccession()+ "\t" +p.getText()+ "\t" +p.getName() + "\t" +p.getType()+ "\t" +p.getParameters());
     256      //}
     257      //Display all the parameters, only for debugging
     258     
     259      //log.info("\n++++++++++++++++++++ The parameters ++++++++++++++\n");
     260      //List<String> params= protocolVal.getProtocolParameters();
     261      //for (String p : params)
     262      //{
     263      //  log.warn(p);
     264      //}
     265           
    248266      log.info( doneProtocol ? " \n.... Protocol validation is SUCCESSFUL .... \n" :" \n.... Protocol validation FAILED .... \n");
    249267      statusOut.write( doneProtocol ? " \n.... Protocol validation is SUCCESSFUL .... \n" :" \n.... Protocol validation FAILED .... \n");
     
    263281      {
    264282        log.error("SORRY: The header for the hybridization section of the tab2mage file: " +filename+ " is invalid. Must be rectified to proceed. See the log file for more details");
     283        //throw new NutribasePluginException("The header for the hybridization section of the tab2mage file: " +filename+ " is invalid. Must be rectified to proceed. See the log file for more details");
    265284        statusOut.write("Sorry the header for the hybridization section of the tab2mage file: " +filename+ " is invalid. Must be rectified to proceed.");
    266285        doneHybridizationHeaders = false;
    267286      }
    268287      statusOut.write( doneHybridizationHeaders ? " \n.... Hybridization header validation is SUCCESSFUL .... \n" :" \n.... Hybridization header validation FAILED .... \n");
    269            
    270         //validate rows /lines
     288      //statusOut.flush();
     289     
     290      //validate rows /lines
    271291     
    272292      Tab2MageHybridizationValidation validateHyb = new Tab2MageHybridizationValidation(dir, platform, hybs, reader, sc);
     
    286306         
    287307       */
     308      // check if the dc is closed, or disconnected and create a new one if yes
    288309      if (dc == null || !dc.isConnected() || dc.isClosed()) dc = sc.newDbControl();
    289310      dir= Directory.getByPath(dc, dir.getPath());
     
    317338        {
    318339          log.error("Sorry the agilent files cannot be validated. Mandatory Columns are missing. Must be rectified to proceed. See the log file for more details");
     340          //throw new ValidationException("An agilent file is missing once or more mandatory columns!");
    319341          statusOut.write("Sorry the agilent files cannot be validated. Mandatory Columns are missing. Must be rectified to proceed.");
    320342          doneAgilent =false;
     
    386408     
    387409      statusOut.close();
     410      //dc.commit();
    388411    }
    389412    catch(Throwable tr)
Note: See TracChangeset for help on using the changeset viewer.