1 /*--------------------------------------------------------------------------
\r
2 * Copyright 2009 Taro L. Saito
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
15 *--------------------------------------------------------------------------*/
\r
16 //--------------------------------------
\r
20 // Since: Jul 3, 2009 7:11:49 PM
\r
24 //--------------------------------------
\r
25 package org.xerial.silk;
\r
27 import java.lang.annotation.ElementType;
\r
28 import java.lang.annotation.Retention;
\r
29 import java.lang.annotation.RetentionPolicy;
\r
30 import java.lang.annotation.Target;
\r
31 import java.util.List;
\r
33 import org.junit.After;
\r
34 import org.junit.Before;
\r
35 import org.junit.Test;
\r
36 import org.xerial.lens.Lens;
\r
37 import org.xerial.lens.ObjectLens;
\r
38 import org.xerial.util.FileResource;
\r
39 import org.xerial.util.log.Logger;
\r
41 @Retention(RetentionPolicy.RUNTIME)
\r
42 @Target( { ElementType.TYPE, ElementType.METHOD })
\r
45 public String[] left();
\r
47 public String[] right();
\r
49 public Class< ? > leftClass();
\r
53 public class FastaTest
\r
55 private static Logger _logger = Logger.getLogger(FastaTest.class);
\r
58 public void setUp() throws Exception
\r
62 public void tearDown() throws Exception
\r
65 public static class FastaQuery
\r
67 FastaItem prev = null;
\r
69 public void addGroup_Name(String group, FastaItem f)
\r
71 _logger.info(String.format("group: %s, fasta: %s", group, ObjectLens.toJSON(f)));
\r
74 public void addName(FastaItem f)
\r
76 _logger.debug(ObjectLens.toJSON(f));
\r
78 if (prev != null && prev.getSequence().contains("TTAGGG"))
\r
80 // output both records
\r
83 if (f.getSequence().contains("TTAGGG"))
\r
99 public static class S1
\r
102 public String name;
\r
104 public int getRid()
\r
111 public static class S2
\r
114 public String info;
\r
117 @EqJoin(left = "rid", leftClass = S1.class, right = "rid")
\r
118 public static class S3
\r
122 public List<S2> s2;
\r
126 public static class FastaItem
\r
128 public String value;
\r
129 public String link;
\r
131 private StringBuilder sequence = new StringBuilder();
\r
133 public void appendSequence(String s)
\r
135 sequence.append(s);
\r
138 public String getSequence()
\r
140 return sequence.toString();
\r
146 public void testname() throws Exception
\r
148 FastaQuery result = Lens.loadSilk(FastaQuery.class, FileResource.open(FastaTest.class, "fasta.silk"));
\r
151 //ObjectStream<S3> sin = Lens.joinSilk(S3.class, "input1", "input2");
\r
153 //ObjectStream<S4> out = Lens.joinSilk(S4.class, sin, "input3");
\r