Search in sources :

Example 6 with Gfa1Adapter

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
        }
    }
}
Also used : Gfa1Adapter(org.dishevelled.bio.assembly.gfa1.Gfa1Adapter) Segment(org.dishevelled.bio.assembly.gfa1.Segment) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) PrintWriter(java.io.PrintWriter)

Example 7 with Gfa1Adapter

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
        }
    }
}
Also used : Gfa1Adapter(org.dishevelled.bio.assembly.gfa1.Gfa1Adapter) Link(org.dishevelled.bio.assembly.gfa1.Link) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) PrintWriter(java.io.PrintWriter)

Example 8 with Gfa1Adapter

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
        }
    }
}
Also used : Gfa1Adapter(org.dishevelled.bio.assembly.gfa1.Gfa1Adapter) Link(org.dishevelled.bio.assembly.gfa1.Link) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) PrintWriter(java.io.PrintWriter)

Example 9 with Gfa1Adapter

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
        }
    }
}
Also used : Traversal(org.dishevelled.bio.assembly.gfa1.Traversal) Gfa1Adapter(org.dishevelled.bio.assembly.gfa1.Gfa1Adapter) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) PrintWriter(java.io.PrintWriter)

Aggregations

Gfa1Adapter (org.dishevelled.bio.assembly.gfa1.Gfa1Adapter)9 PrintWriter (java.io.PrintWriter)8 CommandLineParseException (org.dishevelled.commandline.CommandLineParseException)8 Segment (org.dishevelled.bio.assembly.gfa1.Segment)5 Link (org.dishevelled.bio.assembly.gfa1.Link)4 Traversal (org.dishevelled.bio.assembly.gfa1.Traversal)3 BufferedReader (java.io.BufferedReader)2 HashMap (java.util.HashMap)2 Path (org.dishevelled.bio.assembly.gfa1.Path)2 HashBasedTable (com.google.common.collect.HashBasedTable)1 Table (com.google.common.collect.Table)1 FileReader (java.io.FileReader)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 CyEdge (org.cytoscape.model.CyEdge)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyNode (org.cytoscape.model.CyNode)1 CyRow (org.cytoscape.model.CyRow)1 CyTable (org.cytoscape.model.CyTable)1 Annotation (org.dishevelled.bio.annotation.Annotation)1