Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- //import org.apache.commons.lang.StringUtils;
- /*
- * Alan Ruvalcaba
- * CS 301 12:00 - 12:50am
- *
- */
- public class Huntingtons {
- public static void main(String[] args) throws IOException {
- BufferedReader in = new BufferedReader(new FileReader(args[0]));
- StringBuffer result = new StringBuffer();//Create StringBuffer
- String iterator = "";
- while ((iterator = in.readLine()) != null) {
- result.append(iterator);
- }
- String copyNospace = new String(result);
- copyNospace = copyNospace.replaceAll("\\s", "");
- countOccurrences(copyNospace);
- }
- public static void countOccurrences(String input) {
- Pattern pattern = Pattern.compile("(C\\s*A\\s*G\\s*)*");
- Matcher matcher = pattern.matcher(input);
- int max = 0;
- while(matcher.find()){
- //System.out.println(matcher.group().length());
- int length = matcher.group().length();
- if(max < length/3)
- max = length/3;
- }
- if (max < 28)
- System.out.println("< 28 Normal " + max);
- else if (max >= 28 && max <= 35)
- System.out
- .println("28-35 Intermediate Level,no symptoms " + max);
- else if (max >= 36 && max <= 39)
- System.out.println("36-39 At risk for Huntington's Disease "
- + max);
- else if (max >= 40 && max <= 180)
- System.out.println("40-180 Huntington's Disease " + max);
- else if (max > 180)
- System.out.println("> 180 Not a human being.");
- }
- }
Add Comment
Please, Sign In to add comment