+++ /dev/null
-/*--------------------------------------------------------------------------\r
- * Copyright 2009 Taro L. Saito\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- *--------------------------------------------------------------------------*/\r
-//--------------------------------------\r
-// XerialJ\r
-//\r
-// FastaTest.java\r
-// Since: Jul 3, 2009 7:11:49 PM\r
-//\r
-// $URL$\r
-// $Author$\r
-//--------------------------------------\r
-package org.xerial.silk;\r
-\r
-import java.lang.annotation.ElementType;\r
-import java.lang.annotation.Retention;\r
-import java.lang.annotation.RetentionPolicy;\r
-import java.lang.annotation.Target;\r
-import java.util.List;\r
-\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.xerial.lens.Lens;\r
-import org.xerial.lens.ObjectLens;\r
-import org.xerial.util.FileResource;\r
-import org.xerial.util.log.Logger;\r
-\r
-@Retention(RetentionPolicy.RUNTIME)\r
-@Target( { ElementType.TYPE, ElementType.METHOD })\r
-@interface EqJoin {\r
-\r
- public String[] left();\r
-\r
- public String[] right();\r
-\r
- public Class< ? > leftClass();\r
-\r
-}\r
-\r
-public class FastaTest\r
-{\r
- private static Logger _logger = Logger.getLogger(FastaTest.class);\r
-\r
- @Before\r
- public void setUp() throws Exception\r
- {}\r
-\r
- @After\r
- public void tearDown() throws Exception\r
- {}\r
-\r
- public static class FastaQuery\r
- {\r
- FastaItem prev = null;\r
-\r
- public void addGroup_Name(String group, FastaItem f)\r
- {\r
- _logger.info(String.format("group: %s, fasta: %s", group, ObjectLens.toJSON(f)));\r
- }\r
-\r
- public void addName(FastaItem f)\r
- {\r
- _logger.debug(ObjectLens.toJSON(f));\r
-\r
- if (prev != null && prev.getSequence().contains("TTAGGG"))\r
- {\r
- // output both records\r
- }\r
-\r
- if (f.getSequence().contains("TTAGGG"))\r
- {\r
-\r
- }\r
-\r
- prev = f;\r
-\r
- }\r
-\r
- public void flush()\r
- {\r
-\r
- }\r
-\r
- }\r
-\r
- public static class S1\r
- {\r
- public int id;\r
- public String name;\r
-\r
- public int getRid()\r
- {\r
- return id - 1;\r
- }\r
-\r
- }\r
-\r
- public static class S2\r
- {\r
- public int rid;\r
- public String info;\r
- }\r
-\r
- @EqJoin(left = "rid", leftClass = S1.class, right = "rid")\r
- public static class S3\r
- {\r
- public S1 s1;\r
-\r
- public List<S2> s2;\r
-\r
- }\r
-\r
- public static class FastaItem\r
- {\r
- public String value;\r
- public String link;\r
-\r
- private StringBuilder sequence = new StringBuilder();\r
-\r
- public void appendSequence(String s)\r
- {\r
- sequence.append(s);\r
- }\r
-\r
- public String getSequence()\r
- {\r
- return sequence.toString();\r
- }\r
-\r
- }\r
-\r
- @Test\r
- public void testname() throws Exception\r
- {\r
- FastaQuery result = Lens.loadSilk(FastaQuery.class, FileResource.open(FastaTest.class, "fasta.silk"));\r
- result.flush();\r
-\r
- //ObjectStream<S3> sin = Lens.joinSilk(S3.class, "input1", "input2");\r
-\r
- //ObjectStream<S4> out = Lens.joinSilk(S4.class, sin, "input3");\r
-\r
- }\r
-\r
-}\r