(String outFastaPath)
| 4219 | } |
| 4220 | |
| 4221 | private boolean layoutStrandedBackbones(String outFastaPath) throws IOException { |
| 4222 | HashSet<String> containedSet = populateGraphFromOverlaps(); |
| 4223 | |
| 4224 | if (!containedSet.isEmpty()) { |
| 4225 | printMessage("contained reads: " + NumberFormat.getInstance().format(containedSet.size())); |
| 4226 | } |
| 4227 | |
| 4228 | Set<String> vertexSet = graph.vertexSet(); |
| 4229 | if (!vertexSet.isEmpty()) { |
| 4230 | printMessage("dovetail reads: " + NumberFormat.getInstance().format(vertexSet.size())); |
| 4231 | } |
| 4232 | |
| 4233 | int numEdges = graph.edgeSet().size(); |
| 4234 | if (numEdges > 1) { |
| 4235 | printMessage("G: |V|=" + NumberFormat.getInstance().format(graph.vertexSet().size()) + " |E|=" + NumberFormat.getInstance().format(numEdges)); |
| 4236 | |
| 4237 | // ArrayDeque<String> redundantNodeNames = removeRedundantNodes(); |
| 4238 | // for (String n : redundantNodeNames) { |
| 4239 | // containedSet.add(getVertexName(n)); |
| 4240 | // } |
| 4241 | // numEdges = graph.edgeSet().size(); |
| 4242 | // System.out.println("G: |V|=" + NumberFormat.getInstance().format(graph.vertexSet().size()) + " |E|=" + NumberFormat.getInstance().format(numEdges)); |
| 4243 | |
| 4244 | resolveJunctions(); |
| 4245 | numEdges = graph.edgeSet().size(); |
| 4246 | printMessage("G: |V|=" + NumberFormat.getInstance().format(graph.vertexSet().size()) + " |E|=" + NumberFormat.getInstance().format(numEdges)); |
| 4247 | } |
| 4248 | |
| 4249 | // extract read sequences |
| 4250 | HashMap<String, BitSequence> dovetailReadSeqs = new HashMap<>(vertexSet.size()); |
| 4251 | FastaReader fr = new FastaReader(seqFastaPath); |
| 4252 | FastaWriter fw = new FastaWriter(outFastaPath, false); |
| 4253 | long seqID = 0; |
| 4254 | long originalNumSeq = 0; |
| 4255 | while (fr.hasNext()) { |
| 4256 | ++originalNumSeq; |
| 4257 | String[] nameSeq = fr.nextWithName(); |
| 4258 | String name = nameSeq[0]; |
| 4259 | if (vertexSet.contains(name + '+')) { |
| 4260 | String seq = nameSeq[1]; |
| 4261 | dovetailReadSeqs.put(name, new BitSequence(seq)); |
| 4262 | } |
| 4263 | else if (!containedSet.contains(name)) { |
| 4264 | // this sequence either contains shorter sequences or it has no overlaps with others |
| 4265 | fw.write(Long.toString(++seqID), nameSeq[1]); |
| 4266 | } |
| 4267 | } |
| 4268 | fr.close(); |
| 4269 | |
| 4270 | // layout unambiguous paths |
| 4271 | HashSet<String> visitedReadNames = new HashSet<>(vertexSet.size()); |
| 4272 | for (String n : vertexSet) { |
| 4273 | if (!visitedReadNames.contains(getVertexName(n))) { |
| 4274 | ArrayDeque<String> path = getUnambiguousLeftExtension(n); |
| 4275 | path.add(n); |
| 4276 | if (!graph.containsEdge(n, path.getFirst())) { |
| 4277 | // detect cycles |
| 4278 | path.addAll(getUnambiguousRightExtension(n)); |
nothing calls this directly
no test coverage detected