MCPcopy Create free account
hub / github.com/BirolLab/RNA-Bloom / nextWithName

Method nextWithName

src/rnabloom/io/FastaReader.java:106–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104 }
105
106 @Override
107 public synchronized String[] nextWithName() throws FileFormatException {
108 if (!itr.hasNext()) {
109 return null;
110 }
111
112 if (header == null) {
113 header = itr.next().trim();
114 }
115
116 if (header.isEmpty()) {
117 return null; //throw new FileFormatException("Empty FASTA header");
118 }
119
120 String name = null;
121 Matcher m = RECORD_NAME_COMMENT_PATTERN.matcher(header);
122 if (m.matches()) {
123 name = m.group(1);
124 if (removeNameSuffix) {
125 Matcher m2 = RECORD_NAME_PATTERN.matcher(name);
126 if (m2.matches()) {
127 name = m2.group(1);
128 }
129 }
130 }
131 else {
132 throw new FileFormatException("Incorrect FASTA header format");
133 }
134
135 StringBuilder builder = new StringBuilder();
136 while (itr.hasNext()) {
137 String line = itr.next().trim();
138 if (line.isEmpty()) {
139 header = null;
140 break;
141 }
142 else if (line.charAt(0) == '>') {
143 header = line;
144 break;
145 }
146 else {
147 builder.append(line);
148 }
149 }
150
151 return new String[]{name, builder.toString()};
152 }
153
154 public synchronized void nextWithName(FastaRecord fr) throws FileFormatException {
155 if (!itr.hasNext()) {

Callers 12

mergeClusterFastasMethod · 0.95
trimSplitByReadDepthMethod · 0.95
extractSimplePathsMethod · 0.95
extractGreedyPathsMethod · 0.95
layoutBackbonesMethod · 0.95
getPolyAInfoMethod · 0.95

Calls 3

hasNextMethod · 0.65
nextMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected