()
| 68 | private String header = null; |
| 69 | |
| 70 | @Override |
| 71 | public synchronized String next() throws FileFormatException { |
| 72 | if (!itr.hasNext()) { |
| 73 | return null; |
| 74 | } |
| 75 | |
| 76 | if (header == null) { |
| 77 | header = itr.next().trim(); |
| 78 | } |
| 79 | |
| 80 | if (header.isEmpty()) { |
| 81 | return null; //throw new FileFormatException("Empty FASTA header"); |
| 82 | } |
| 83 | else if (header.charAt(0) != '>') { |
| 84 | throw new FileFormatException("Incorrect FASTA header format"); |
| 85 | } |
| 86 | |
| 87 | StringBuilder builder = new StringBuilder(); |
| 88 | while (itr.hasNext()) { |
| 89 | String line = itr.next().trim(); |
| 90 | if (line.isEmpty()) { |
| 91 | header = null; |
| 92 | break; |
| 93 | } |
| 94 | else if (line.charAt(0) == '>') { |
| 95 | header = line; |
| 96 | break; |
| 97 | } |
| 98 | else { |
| 99 | builder.append(line); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | return builder.toString(); |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public synchronized String[] nextWithName() throws FileFormatException { |
no test coverage detected