use of org.dishevelled.bio.assembly.gfa1.Gfa1Adapter in project dishevelled-bio by heuermh.
the class SegmentsToPropertyGraph method call.
@Override
public Integer call() throws Exception {
PrintWriter nodesWriter = null;
try {
nodesWriter = writer(outputNodesFile);
nodesWriter.println(HEADER);
final PrintWriter nw = nodesWriter;
Gfa1Reader.stream(reader(inputGfa1File), new Gfa1Adapter() {
@Override
public boolean segment(final Segment segment) {
StringBuilder sb = new StringBuilder();
sb.append(segment.getName());
sb.append(",");
sb.append(segment.getSequenceOpt().orElse(""));
sb.append(",");
sb.append(segment.containsLength() ? segment.getLength() : "");
sb.append(",");
sb.append(segment.containsReadCount() ? segment.getReadCount() : "");
sb.append(",");
sb.append(segment.containsFragmentCount() ? segment.getFragmentCount() : "");
sb.append(",");
sb.append(segment.containsKmerCount() ? segment.getKmerCount() : "");
sb.append(",");
sb.append(segment.containsSequenceChecksum() ? String.valueOf(segment.getSequenceChecksum()) : "");
sb.append(",");
sb.append(segment.getSequenceUriOpt().orElse(""));
nw.println(sb);
return true;
}
});
return 0;
} finally {
try {
nodesWriter.close();
} catch (Exception e) {
// empty
}
}
}
use of org.dishevelled.bio.assembly.gfa1.Gfa1Adapter in project dishevelled-bio by heuermh.
the class LinksToCytoscapeEdges method call.
@Override
public Integer call() throws Exception {
PrintWriter edgesWriter = null;
try {
edgesWriter = writer(outputEdgesFile);
edgesWriter.println(HEADER);
final PrintWriter ew = edgesWriter;
Gfa1Reader.stream(reader(inputGfa1File), new Gfa1Adapter() {
@Override
public boolean link(final Link link) {
StringBuilder sb = new StringBuilder();
sb.append(link.getSource().getName());
sb.append("\t");
sb.append(link.getSource().getOrientation().getSymbol());
sb.append("\t");
sb.append(link.getTarget().getName());
sb.append("\t");
sb.append(link.getTarget().getOrientation().getSymbol());
sb.append("\tL\t");
sb.append(link.getIdOpt().orElse(""));
sb.append("\t");
sb.append(link.getOverlapOpt().orElse(""));
sb.append("\t");
sb.append(link.containsMappingQuality() ? link.getMappingQuality() : "");
sb.append("\t");
sb.append(link.containsMismatchCount() ? link.getMismatchCount() : "");
sb.append("\t");
ew.println(sb);
return true;
}
});
return 0;
} finally {
try {
edgesWriter.close();
} catch (Exception e) {
// empty
}
}
}
use of org.dishevelled.bio.assembly.gfa1.Gfa1Adapter in project dishevelled-bio by heuermh.
the class LinksToPropertyGraph method call.
@Override
public Integer call() throws Exception {
PrintWriter edgesWriter = null;
try {
edgesWriter = writer(outputEdgesFile);
edgesWriter.println(HEADER);
final PrintWriter ew = edgesWriter;
Gfa1Reader.stream(reader(inputGfa1File), new Gfa1Adapter() {
@Override
public boolean link(final Link link) {
if (!link.containsId()) {
throw new IllegalArgumentException("link identifiers are required for property graph CSV format");
}
StringBuilder sb = new StringBuilder();
sb.append(link.getId());
sb.append(",");
sb.append(link.getSource().getName());
sb.append(",");
sb.append(link.getTarget().getName());
sb.append(",");
sb.append(link.getSource().getOrientation().getSymbol());
sb.append(",");
sb.append(link.getTarget().getOrientation().getSymbol());
sb.append(",L,");
sb.append(link.getOverlapOpt().orElse(""));
sb.append(",");
sb.append(link.containsMappingQuality() ? link.getMappingQuality() : "");
sb.append(",");
sb.append(link.containsMismatchCount() ? link.getMismatchCount() : "");
ew.println(sb);
return true;
}
});
return 0;
} finally {
try {
edgesWriter.close();
} catch (Exception e) {
// empty
}
}
}
use of org.dishevelled.bio.assembly.gfa1.Gfa1Adapter in project dishevelled-bio by heuermh.
the class TraversalsToCytoscapeEdges method call.
@Override
public Integer call() throws Exception {
PrintWriter edgesWriter = null;
try {
edgesWriter = writer(outputEdgesFile);
edgesWriter.println(HEADER);
final PrintWriter ew = edgesWriter;
Gfa1Reader.stream(reader(inputGfa1File), new Gfa1Adapter() {
@Override
public boolean traversal(final Traversal traversal) {
StringBuilder sb = new StringBuilder();
sb.append(traversal.getSource().getName());
sb.append("\t");
sb.append(traversal.getSource().getOrientation().getSymbol());
sb.append("\t");
sb.append(traversal.getTarget().getName());
sb.append("\t");
sb.append(traversal.getTarget().getOrientation().getSymbol());
sb.append("\tt\t");
sb.append(traversal.getIdOpt().orElse(""));
sb.append("\t");
sb.append(traversal.getPathName());
sb.append("\t");
sb.append(traversal.getOrdinal());
sb.append("\t");
sb.append(traversal.getOverlapOpt().orElse(""));
ew.println(sb);
return true;
}
});
return 0;
} finally {
try {
edgesWriter.close();
} catch (Exception e) {
// empty
}
}
}
Aggregations