1   /*--------------------------------------------------------------------------
2    *  Copyright 2008 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-shell Project
18  //
19  // KeywordTest.java
20  // Since: May 20, 2010
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.shell;
26  
27  import java.io.File;
28  
29  import org.junit.Test;
30  import org.utgenome.shell.ProjectGenerator.ProjectInfo;
31  import org.xerial.util.FileResource;
32  import org.xerial.util.FileUtil;
33  
34  public class KeywordTest {
35  
36  	@Test
37  	public void testExecuteStringArray() throws Exception {
38  
39  		ProjectInfo tmpProject = ProjectGenerator.createTemporatyProject();
40  
41  		// import keywords in BED file
42  		File bed = File.createTempFile("bed", ".bed");
43  		FileUtil.copy(FileResource.openByteStream(KeywordTest.class, "wormbase-keyword.bed"), bed);
44  		UTGBShell.runCommand(new String[] { "-d", tmpProject.projectRoot, "keyword", "import", "-r", "ce6", bed.getAbsolutePath() });
45  
46  		// import alias
47  		File alias = File.createTempFile("alias", ".txt");
48  		FileUtil.copy(FileResource.openByteStream(KeywordTest.class, "alias-sample.txt"), alias);
49  		UTGBShell.runCommand(new String[] { "-d", tmpProject.projectRoot, "keyword", "alias", alias.getAbsolutePath() });
50  
51  		// try keyword search
52  		UTGBShell.runCommand(new String[] { "-d", tmpProject.projectRoot, "keyword", "search", "Y74C9" });
53  
54  	}
55  
56  	@Test
57  	public void testSAMKeyword() throws Exception {
58  
59  		ProjectInfo tmpProject = ProjectGenerator.createTemporatyProject();
60  
61  		// import keywords in BED file
62  		File sam = File.createTempFile("keyword", ".sam");
63  		FileUtil.copy(FileResource.openByteStream(KeywordTest.class, "sample.sam"), sam);
64  		UTGBShell.runCommand(new String[] { "-d", tmpProject.projectRoot, "keyword", "import", "-r", "HG18", sam.getAbsolutePath() });
65  
66  		// try keyword search
67  		UTGBShell.runCommand(new String[] { "-d", tmpProject.projectRoot, "keyword", "search", "read_5_2" });
68  	}
69  
70  	@Test
71  	public void testBAMKeyword() throws Exception {
72  
73  		ProjectInfo tmpProject = ProjectGenerator.createTemporatyProject();
74  
75  		// import keywords in BED file
76  		File bam = File.createTempFile("keyword", ".sam");
77  		FileUtil.copy(FileResource.openByteStream(KeywordTest.class, "sample.bam"), bam);
78  		UTGBShell.runCommand(new String[] { "-d", tmpProject.projectRoot, "keyword", "import", "-r", "HG18", bam.getAbsolutePath() });
79  
80  		// try keyword search
81  		UTGBShell.runCommand(new String[] { "-d", tmpProject.projectRoot, "keyword", "search", "read_5_2" });
82  	}
83  
84  }