use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.
the class ContainmentTest method setUp.
@Before
public void setUp() {
container = Reference.valueOf("source+");
contained = Reference.valueOf("target+");
position = 42;
overlap = "10M";
annotations = ImmutableMap.<String, Annotation>builder().put("aa", new Annotation("aa", "i", "42")).build();
}
use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.
the class PafReaderTest method testRoundTrip.
@Test
public void testRoundTrip() throws Exception {
Map<String, Annotation> annotations = new HashMap<String, Annotation>();
annotations.put("NM", Annotation.valueOf("NM:i:0"));
annotations.put("MD", Annotation.valueOf("MD:Z:101"));
annotations.put("AS", Annotation.valueOf("AS:i:101"));
annotations.put("XS", Annotation.valueOf("XS:i:55"));
annotations.put("RG", Annotation.valueOf("RG:Z:NA12878-1"));
annotations.put("MQ", Annotation.valueOf("MQ:i:60"));
annotations.put("ms", Annotation.valueOf("ms:i:3614"));
annotations.put("mc", Annotation.valueOf("mc:i:60612"));
annotations.put("MC", Annotation.valueOf("MC:Z:101M"));
annotations.put("ZB", Annotation.valueOf("ZB:B:i1,2"));
annotations.put("ZT", Annotation.valueOf("ZT:B:f3.4,4.5"));
PafRecord expected = new PafRecord("query", 100L, 10L, 20L, '-', "target", 200L, 20L, 30L, 42L, 10L, 32, annotations);
File tmp = File.createTempFile("pafReaderTest", ".paf");
tmp.deleteOnExit();
try (PrintWriter writer = new PrintWriter(new FileWriter(tmp))) {
PafWriter.write(expected, writer);
}
PafRecord observed = read(tmp).iterator().next();
assertEquals(expected.getQueryName(), observed.getQueryName());
}
use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.
the class PafWriterTest method setUp.
@Before
public void setUp() {
Map<String, Annotation> annotations = new HashMap<String, Annotation>();
annotations.put("NM", Annotation.valueOf("NM:i:0"));
annotations.put("MD", Annotation.valueOf("MD:Z:101"));
annotations.put("AS", Annotation.valueOf("AS:i:101"));
annotations.put("XS", Annotation.valueOf("XS:i:55"));
annotations.put("RG", Annotation.valueOf("RG:Z:NA12878-1"));
annotations.put("MQ", Annotation.valueOf("MQ:i:60"));
annotations.put("ms", Annotation.valueOf("ms:i:3614"));
annotations.put("mc", Annotation.valueOf("mc:i:60612"));
annotations.put("MC", Annotation.valueOf("MC:Z:101M"));
annotations.put("ZB", Annotation.valueOf("ZB:B:i,1,2"));
annotations.put("ZT", Annotation.valueOf("ZT:B:f,3.4,4.5"));
record = new PafRecord("query", 100L, 10L, 20L, '-', "target", 200L, 20L, 30L, 42L, 10L, 32, annotations);
records = ImmutableList.of(record);
outputStream = new ByteArrayOutputStream();
writer = new PrintWriter(outputStream);
}
use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.
the class Link method valueOf.
/**
* Parse a link GFA 1.0 record from the specified value.
*
* @param value value, must not be null
* @return a link GFA 1.0 record parsed from the specified value
*/
public static Link valueOf(final String value) {
checkNotNull(value);
checkArgument(value.startsWith("L"), "link value must start with L");
List<String> tokens = Splitter.on("\t").splitToList(value);
if (tokens.size() < 6) {
throw new IllegalArgumentException("link value must have at least six tokens, was " + tokens.size());
}
Reference source = Reference.splitValueOf(tokens.get(1), tokens.get(2));
Reference target = Reference.splitValueOf(tokens.get(3), tokens.get(4));
String overlap = "*".equals(tokens.get(5)) ? null : 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 Link(source, target, overlap, annotations.build());
}
use of org.dishevelled.bio.annotation.Annotation in project dishevelled-bio by heuermh.
the class Segment method valueOf.
/**
* Parse a segment GFA 1.0 record from the specified value.
*
* @param value value, must not be null
* @return a segment GFA 1.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() < 3) {
throw new IllegalArgumentException("segment value must have at least three tokens, was " + tokens.size());
}
String id = tokens.get(1);
String sequence = "*".equals(tokens.get(2)) ? null : tokens.get(2);
ImmutableMap.Builder<String, Annotation> annotations = ImmutableMap.builder();
for (int i = 3; 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, sequence, annotations.build());
}
Aggregations