Search in sources :

Example 26 with Annotation

use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.

the class Gap method valueOf.

/**
 * Parse a gap GFA 2.0 record from the specified value.
 *
 * @param value value, must not be null
 * @return a gap GFA 2.0 record parsed from the specified value
 */
public static Gap valueOf(final String value) {
    checkNotNull(value);
    checkArgument(value.startsWith("G"), "gap value must start with G");
    List<String> tokens = Splitter.on("\t").splitToList(value);
    if (tokens.size() < 6) {
        throw new IllegalArgumentException("gap value must have at least six tokens, was " + tokens.size());
    }
    String id = "*".equals(tokens.get(1)) ? null : tokens.get(1);
    Reference source = Reference.valueOf(tokens.get(2));
    Reference target = Reference.valueOf(tokens.get(3));
    int distance = Integer.parseInt(tokens.get(4));
    Integer variance = "*".equals(tokens.get(5)) ? null : Integer.parseInt(tokens.get(5));
    ImmutableMap.Builder<String, Annotation> annotations = ImmutableMap.builder();
    for (int i = 6; i < tokens.size(); i++) {
        String token = tokens.get(i);
        if (!token.isEmpty()) {
            Annotation annotation = Annotation.valueOf(token);
            annotations.put(annotation.getName(), annotation);
        }
    }
    return new Gap(id, source, target, distance, variance, annotations.build());
}
Also used : ImmutableMap(com.google.common.collect.ImmutableMap) Annotation(org.dishevelled.bio.annotation.Annotation)

Example 27 with Annotation

use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.

the class SetTest method setUp.

@Before
public void setUp() {
    id = "id";
    ids = ImmutableSet.of("source", "target");
    annotations = ImmutableMap.<String, Annotation>builder().put("aa", new Annotation("aa", "i", "42")).build();
}
Also used : Annotation(org.dishevelled.bio.annotation.Annotation) Before(org.junit.Before)

Example 28 with Annotation

use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.

the class PathTest method setUp.

@Before
public void setUp() {
    name = "name";
    segments = ImmutableList.of(Reference.valueOf("source+"), Reference.valueOf("target+"));
    overlaps = ImmutableList.of("10M");
    annotations = ImmutableMap.<String, Annotation>builder().put("aa", new Annotation("aa", "i", "42")).build();
}
Also used : Annotation(org.dishevelled.bio.annotation.Annotation) Before(org.junit.Before)

Example 29 with Annotation

use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.

the class SegmentTest method setUp.

@Before
public void setUp() {
    id = "id";
    sequence = "actg";
    annotations = ImmutableMap.<String, Annotation>builder().put("aa", new Annotation("aa", "i", "42")).build();
}
Also used : Annotation(org.dishevelled.bio.annotation.Annotation) Before(org.junit.Before)

Example 30 with Annotation

use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.

the class TraversalTest method setUp.

@Before
public void setUp() {
    pathName = "pathName";
    ordinal = 0;
    source = Reference.valueOf("1+");
    target = Reference.valueOf("2-");
    overlap = "0M";
    annotations = ImmutableMap.<String, Annotation>builder().put("aa", new Annotation("aa", "i", "42")).build();
}
Also used : Annotation(org.dishevelled.bio.annotation.Annotation) Before(org.junit.Before)

Aggregations

Annotation (org.dishevelled.bio.annotation.Annotation)34 ImmutableMap (com.google.common.collect.ImmutableMap)17 Before (org.junit.Before)13 PrintWriter (java.io.PrintWriter)6 HashMap (java.util.HashMap)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2 Test (org.junit.Test)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 GafRecord (org.dishevelled.bio.alignment.gaf.GafRecord)1 Containment (org.dishevelled.bio.assembly.gfa1.Containment)1 Gfa1Adapter (org.dishevelled.bio.assembly.gfa1.Gfa1Adapter)1 Header (org.dishevelled.bio.assembly.gfa1.Header)1 Link (org.dishevelled.bio.assembly.gfa1.Link)1 Path (org.dishevelled.bio.assembly.gfa1.Path)1 Reference (org.dishevelled.bio.assembly.gfa1.Reference)1 Segment (org.dishevelled.bio.assembly.gfa1.Segment)1