Search in sources :

Example 11 with Path

use of net.minecraft.server.v1_14_R1.Path in project dishevelled by heuermh.

the class AssemblyModel method setPath.

/**
 * Set the selected path for this assembly model to <code>path</code>.
 *
 * <p>This is a bound property.</p>
 *
 * @param path selected path for this assembly model, if any
 */
void setPath(final Path path) {
    Path oldPath = this.path;
    this.path = path;
    traversals.clear();
    if (this.path != null && traversalsByPath.containsKey(path)) {
        traversals.addAll(traversalsByPath.get(path));
    }
    propertyChangeSupport.firePropertyChange("path", oldPath, this.path);
}
Also used : Path(org.dishevelled.bio.assembly.gfa1.Path)

Example 12 with Path

use of net.minecraft.server.v1_14_R1.Path in project dishevelled-bio by heuermh.

the class ReassemblePaths method call.

@Override
public Integer call() throws Exception {
    BufferedReader reader = null;
    PrintWriter writer = null;
    try {
        reader = reader(inputGfa1File);
        writer = writer(outputGfa1File);
        final PrintWriter w = writer;
        final List<Path> paths = new ArrayList<Path>();
        final ListMultimap<String, Traversal> traversalsByPathName = ArrayListMultimap.create();
        Gfa1Reader.stream(reader, new Gfa1Listener() {

            @Override
            public boolean record(final Gfa1Record gfa1Record) {
                if (gfa1Record instanceof Path) {
                    Path path = (Path) gfa1Record;
                    paths.add(path);
                } else if (gfa1Record instanceof Traversal) {
                    Traversal traversal = (Traversal) gfa1Record;
                    traversalsByPathName.put(traversal.getPathName(), traversal);
                } else {
                    Gfa1Writer.write(gfa1Record, w);
                }
                return true;
            }
        });
        for (Path path : paths) {
            List<Traversal> traversals = traversalsByPathName.get(path.getName());
            Collections.sort(traversals, new Comparator<Traversal>() {

                @Override
                public int compare(final Traversal t0, final Traversal t1) {
                    return t0.getOrdinal() - t1.getOrdinal();
                }
            });
            List<Reference> segments = new ArrayList<Reference>();
            List<String> overlaps = new ArrayList<String>();
            for (Traversal traversal : traversals) {
                if (segments.isEmpty()) {
                    segments.add(traversal.getSource());
                }
                segments.add(traversal.getTarget());
                if (traversal.hasOverlap()) {
                    overlaps.add(traversal.getOverlap());
                }
            }
            Gfa1Writer.write(new Path(path.getName(), segments, overlaps.isEmpty() ? null : overlaps, path.getAnnotations()), w);
        }
        return 0;
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
        // ignore
        }
        try {
            writer.close();
        } catch (Exception e) {
        // ignore
        }
    }
}
Also used : Path(org.dishevelled.bio.assembly.gfa1.Path) Reference(org.dishevelled.bio.assembly.gfa1.Reference) ArrayList(java.util.ArrayList) Traversal(org.dishevelled.bio.assembly.gfa1.Traversal) Gfa1Listener(org.dishevelled.bio.assembly.gfa1.Gfa1Listener) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) Gfa1Record(org.dishevelled.bio.assembly.gfa1.Gfa1Record) BufferedReader(java.io.BufferedReader) PrintWriter(java.io.PrintWriter)

Example 13 with Path

use of net.minecraft.server.v1_14_R1.Path in project dishevelled-bio by heuermh.

the class TruncatePaths method call.

@Override
public Integer call() throws Exception {
    BufferedReader reader = null;
    PrintWriter writer = null;
    try {
        reader = reader(inputGfa1File);
        writer = writer(outputGfa1File);
        final PrintWriter w = writer;
        Gfa1Reader.stream(reader, new Gfa1Listener() {

            @Override
            public boolean record(final Gfa1Record gfa1Record) {
                if (gfa1Record instanceof Path) {
                    Path path = (Path) gfa1Record;
                    Gfa1Writer.write(new Path(path.getName(), EMPTY_SEGMENTS, null, path.getAnnotations()), w);
                } else {
                    Gfa1Writer.write(gfa1Record, w);
                }
                return true;
            }
        });
        return 0;
    } finally {
        try {
            reader.close();
        } catch (Exception e) {
        // ignore
        }
        try {
            writer.close();
        } catch (Exception e) {
        // ignore
        }
    }
}
Also used : Path(org.dishevelled.bio.assembly.gfa1.Path) Gfa1Record(org.dishevelled.bio.assembly.gfa1.Gfa1Record) BufferedReader(java.io.BufferedReader) Gfa1Listener(org.dishevelled.bio.assembly.gfa1.Gfa1Listener) CommandLineParseException(org.dishevelled.commandline.CommandLineParseException) PrintWriter(java.io.PrintWriter)

Example 14 with Path

use of net.minecraft.server.v1_14_R1.Path in project SilkSpawners by timbru31.

the class NMSHandler method setMobNameOfSpawner.

@Override
public boolean setMobNameOfSpawner(final BlockState blockState, final String mobID) {
    // Prevent ResourceKeyInvalidException: Non [a-z0-9/._-] character in path of location
    final String safeMobID = caseFormatOf(mobID.replace(" ", "_")).to(CaseFormat.LOWER_UNDERSCORE, mobID.replace(" ", "_")).toLowerCase(Locale.ENGLISH);
    final CraftCreatureSpawner spawner = (CraftCreatureSpawner) blockState;
    try {
        final TileEntityMobSpawner tile = (TileEntityMobSpawner) tileField.get(spawner);
        tile.getSpawner().setMobName(IRegistry.ENTITY_TYPE.get(new MinecraftKey(safeMobID)));
        return true;
    } catch (IllegalArgumentException | IllegalAccessException e) {
        Bukkit.getLogger().warning("[SilkSpawners] Reflection failed: " + e.getMessage());
        e.printStackTrace();
    }
    return false;
}
Also used : CraftCreatureSpawner(org.bukkit.craftbukkit.v1_14_R1.block.CraftCreatureSpawner) TileEntityMobSpawner(net.minecraft.server.v1_14_R1.TileEntityMobSpawner) MinecraftKey(net.minecraft.server.v1_14_R1.MinecraftKey)

Aggregations

Path (org.dishevelled.bio.assembly.gfa1.Path)7 BufferedReader (java.io.BufferedReader)5 PrintWriter (java.io.PrintWriter)4 CommandLineParseException (org.dishevelled.commandline.CommandLineParseException)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Traversal (org.dishevelled.bio.assembly.gfa1.Traversal)3 HashBasedTable (com.google.common.collect.HashBasedTable)2 Table (com.google.common.collect.Table)2 ApduConnectionException (es.gob.jmulticard.apdu.connection.ApduConnectionException)2 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)2 TlvException (es.gob.jmulticard.asn1.TlvException)2 Odf (es.gob.jmulticard.asn1.der.pkcs15.Odf)2 Path (es.gob.jmulticard.asn1.der.pkcs15.Path)2 InvalidCardException (es.gob.jmulticard.card.InvalidCardException)2 FileNotFoundException (es.gob.jmulticard.card.iso7816four.FileNotFoundException)2 Iso7816FourCardException (es.gob.jmulticard.card.iso7816four.Iso7816FourCardException)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 PathEntity (net.minecraft.server.v1_14_R1.PathEntity)2