Package edu.msu.cme.rdp.classifier

Examples of edu.msu.cme.rdp.classifier.TrainingDataException


        if (matcher.find()){
            trainsetNo = Integer.parseInt(matcher.group(1).trim());
        version = matcher.group(2);
        }
      } catch (NumberFormatException ex){
        throw new TrainingDataException("Error: The trainsetNo should be integer in the header:" + doc);
      }
    }
  }
View Full Code Here


            HierarchyVersion thisVersion = new HierarchyVersion(line);
            int trainsetNo = thisVersion.getTrainsetNo();

            if (thisVersion.getVersion() == null) {
                throw new TrainingDataException("Error: There is no version information "
                        + "in the wordPrior file");
            }
            if (version == null) {
                version = thisVersion;
            } else if (!version.getVersion().equals(thisVersion.getVersion()) || version.getTrainsetNo() != thisVersion.getTrainsetNo()) {
                throw new TrainingDataException("Error: The version information in the wordPrior file is different from the version of the other training files.");
            }
        }


        while ((line = reader.readLine()) != null) {

            StringTokenizer st = new StringTokenizer(line, "\t");
            if (st.countTokens() != 2) {
                throw new TrainingDataException("\nError: " + line + " does not have exact two numbers");
            }
            try {
                int wordIndex = Integer.parseInt(st.nextToken());
                float logWordPrior = Float.parseFloat(st.nextToken());
                arr[wordIndex] = logWordPrior;
            } catch (NumberFormatException e) {
                reader.close();
                throw new TrainingDataException("\nError: "
                        + "The value for wordIndex or word prior is not a number at line : " + line);
            }
        }
        reader.close();
        return version;
View Full Code Here

        if (line != null) {
            HierarchyVersion thisVersion = new HierarchyVersion(line);
            int trainsetNo = thisVersion.getTrainsetNo();

            if (thisVersion.getVersion() == null) {
                throw new TrainingDataException("Error: There is no version information "
                        + "in the bergeyTree file");
            }
            if (version == null) {
                version = thisVersion;
            } else if (!version.getVersion().equals(thisVersion.getVersion()) || version.getTrainsetNo() != thisVersion.getTrainsetNo()) {
                throw new TrainingDataException("Error: The version information in the bergeyTree file is different from the version of the other training files.");
            }
        }

        while ((line = infile.readLine()) != null) {
            load(line);
View Full Code Here

        try {
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser saxParser = factory.newSAXParser();
            saxParser.parse(new InputSource(new StringReader(document)), this);
        } catch (ParserConfigurationException e) {
            throw new TrainingDataException(e);
        } catch (SAXException e) {
            throw new TrainingDataException(e);
        }
    }
View Full Code Here

            String qName, // qualified name
            Attributes attrs) throws SAXException {
        try {
            // the older training file does not contain the copy number info.
            if (attrs == null || (attrs.getLength() != 6 && attrs.getLength() != 7)) {
                throw new TrainingDataException("Error: the attribute for element: "
                        + qName + " is missing or do not have exactly number of attributes");
            }
            int taxid = Integer.parseInt(attrs.getValue(1));
            int parentTaxid = Integer.parseInt(attrs.getValue(3));
            int leaveCount = Integer.parseInt(attrs.getValue(4));
            int genusIndex = Integer.parseInt(attrs.getValue(5));
            double copyNumber = 0.0f
            if ( attrs.getLength() > 6){
                copyNumber = Double.parseDouble(attrs.getValue(6));
            }

            HierarchyTree aTree = new HierarchyTree(attrs.getValue(0), taxid, attrs.getValue(2), leaveCount, genusIndex, copyNumber);
            // The first TreeNode is the root
            if (root == null) {
                aTree.addParent(null);
                root = aTree;
            } else {
                HierarchyTree parent = null;
                while (!treeNodeStack.empty()) {
                    HierarchyTree topNode = (HierarchyTree) treeNodeStack.peek();
                    if (topNode.getTaxid() == parentTaxid) {
                        parent = topNode;
                        break;
                    }
                    treeNodeStack.pop();
                }
                if (parent == null) {
                    throw new TrainingDataException("Error: The parent for treenode name=: "
                            + attrs.getValue(0) + " rank=" + attrs.getValue(2) + " parentTaxid=" + parentTaxid
                            + " can not be found in the input file");
                }
                //System.err.println("parent: " + parent.getName() + " root=" + root.getName());
                aTree.addParent(parent);
View Full Code Here

        if (line != null) {
            HierarchyVersion thisVersion = new HierarchyVersion(line);
            int trainsetNo = thisVersion.getTrainsetNo();

            if (thisVersion.getVersion() == null) {
                throw new TrainingDataException("Error: There is no version information "
                        + "in the probabilityList file");
            }
            if (version == null) {
                version = thisVersion;
            } else if (!version.getVersion().equals(thisVersion.getVersion()) || version.getTrainsetNo() != thisVersion.getTrainsetNo()) {
                throw new TrainingDataException("Error: The version information in the probabilityList file is different from the version of the other training files.");
            }
        }

        while ((line = reader.readLine()) != null) {

            StringTokenizer st = new StringTokenizer(line, "\t");
            if (st.countTokens() != 2) {
                throw new TrainingDataException("\nError: " + line + " does not have exact two numbers");
            }
            try {
                int genusIndex = Integer.parseInt(st.nextToken());
                float prob = Float.parseFloat(st.nextToken());
                GenusWordConditionalProb genusProb = new GenusWordConditionalProb(genusIndex, prob);
                aList.add(genusProb);
            } catch (NumberFormatException e) {
                reader.close();
                throw new TrainingDataException("\nError: "
                        + "The value for genusIndex or word conditional probability is not a number at line : " + line);
            }
        }
        reader.close();
        return version;
View Full Code Here

        if (line != null) {
            HierarchyVersion thisVersion = new HierarchyVersion(line);
            int trainsetNo = thisVersion.getTrainsetNo();

            if (thisVersion.getVersion() == null) {
                throw new TrainingDataException("Error: There is no version information "
                        + "in the probabilityIndex file");
            }
            if (version == null) {
                version = thisVersion;
            } else if (!version.getVersion().equals(thisVersion.getVersion()) || version.getTrainsetNo() != thisVersion.getTrainsetNo()) {
                throw new TrainingDataException("Error: The version information in the probabilityIndex file is different from the version of the other training files.");
            }
        }

        while ((line = reader.readLine()) != null) {

            StringTokenizer st = new StringTokenizer(line, "\t");
            if (st.countTokens() != 2) {
                throw new TrainingDataException("\nError: " + line + " does not have exact two numbers");
            }
            try {
                int wordIndex = Integer.parseInt(st.nextToken());
                int start = Integer.parseInt(st.nextToken());
                arr[wordIndex] = start;
            } catch (NumberFormatException e) {
                reader.close();
                throw new TrainingDataException("\nError: "
                        + "The value for wordIndex or start position is not a number at line : " + line);
            }
        }
        reader.close();
        return version;
View Full Code Here

TOP

Related Classes of edu.msu.cme.rdp.classifier.TrainingDataException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.