Ejemplo n.º 1
0
 @Override
 @SuppressWarnings(value = "unchecked")
 public RunImportData constructRunImportData() {
   // Instanciate the DOM document
   DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
   docFactory.setIgnoringComments(true);
   docFactory.setIgnoringElementContentWhitespace(true);
   docFactory.setValidating(false);
   DocumentBuilder docBuilder;
   Document xmlDoc = null;
   try {
     docBuilder = docFactory.newDocumentBuilder();
     xmlDoc = docBuilder.parse(new InputSource("./LC480.xml"));
   } catch (Exception ex) {
     Exceptions.printStackTrace(ex);
   }
   // Setup the objects need for the import
   // Setup the Run object
   //            Run run = new RunImpl();
   // Set the run name and date
   Run run = new RunImpl();
   // Retrieve the xml file
   // For development purposes, just use an example xml file
   //        File lcRdmlFile = IOUtilities.openXmlFile("Lightcycler XML Data Import");
   //        if (lcRdmlFile == null) {
   //            return null;
   //        }
   // Setup the profile arraylists
   ArrayList<SampleProfile> sampleProfileList = Lists.newArrayList();
   ArrayList<CalibrationProfile> calbnProfileList = Lists.newArrayList();
   // Determine the strandedness of the majority of the Targets...too bad that this is not provided
   // by the instrument
   TargetStrandedness targetStrandedness = RunImportUtilities.isTheTargetSingleStranded();
   // Get the all of the profile nodes
   NodeList profileNodeList = xmlDoc.getElementsByTagName("series");
   // Cycle through all of the profile nodes
   for (int i = 0; i < profileNodeList.getLength(); i++) {
     // TODO determine whether this profile is sample or calibration
     Profile profile = createProfileType(run);
     Element profileElement = (Element) profileNodeList.item(i);
     String wellLabel = profileElement.getAttribute("title");
     // TODO parse the well label, sample and amplicon name from the wellLabel
     NodeList cycleList = profileElement.getElementsByTagName("point");
     // Collect and set the Fc reading
     profile.setFcReadings(retrieveFcReadings(cycleList));
     if (CalibrationProfile.class.isAssignableFrom(profile.getClass())) {
       CalibrationProfile calProfile = (CalibrationProfile) profile;
       calbnProfileList.add(calProfile);
     } else {
       SampleProfile sampleProfile = (SampleProfile) profile;
       sampleProfileList.add(sampleProfile);
     }
   }
   return null;
 }
 /**
  * This conducts both nonlinear regression-derived Fb subtraction and baseline slope correction.
  *
  * @param profile
  */
 private void conductBaselineCorrection() {
   // Start with correcting for the NR-derived Fb slope
   double[] rawFcReadings = profile.getRawFcReadings();
   double[] processedFcDataset = new double[rawFcReadings.length]; // The new optimized Fc dataset
   // This assumes that nonlinear regression has been conducted AND it was successfully completed
   double nrFb = profile.getNrFb(); // The regression derived Fb
   double nrFbSlope = profile.getNrFbSlope(); // The regression-derived Fb slope
   for (int i = 0; i < processedFcDataset.length; i++) {
     processedFcDataset[i] = rawFcReadings[i] - nrFb - (nrFbSlope * (i + 1));
   }
   profile.setFcReadings(processedFcDataset);
 }