Search in sources :

Example 6 with Annotation

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

the class LinkTest method setUp.

@Before
public void setUp() {
    source = Reference.valueOf("source+");
    target = Reference.valueOf("target+");
    overlap = "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 7 with Annotation

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

the class Header method valueOf.

/**
 * Parse a header GFA 2.0 record from the specified value.
 *
 * @param value value, must not be null
 * @return a header GFA 2.0 record parsed from the specified value
 */
public static Header valueOf(final String value) {
    checkNotNull(value);
    checkArgument(value.startsWith("H"), "header value must start with H");
    List<String> tokens = Splitter.on("\t").splitToList(value);
    ImmutableMap.Builder<String, Annotation> annotations = ImmutableMap.builder();
    for (int i = 1; i < tokens.size(); i++) {
        String token = tokens.get(i);
        if (!token.isEmpty()) {
            Annotation annotation = Annotation.valueOf(token);
            annotations.put(annotation.getName(), annotation);
        }
    }
    return new Header(annotations.build());
}
Also used : ImmutableMap(com.google.common.collect.ImmutableMap) Annotation(org.dishevelled.bio.annotation.Annotation)

Example 8 with Annotation

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

the class Segment method valueOf.

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

Example 9 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";
    length = 42;
    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 10 with Annotation

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

the class FragmentTest method setUp.

@Before
public void setUp() {
    segmentId = "segmentId";
    external = Reference.valueOf("external+");
    segmentStart = Position.valueOf("1");
    segmentEnd = Position.valueOf("10");
    fragmentStart = Position.valueOf("101");
    fragmentEnd = Position.valueOf("110");
    alignment = Alignment.valueOf("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)

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