1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.format.fasta;
26
27 import java.io.BufferedReader;
28 import java.io.IOException;
29 import java.io.InputStreamReader;
30 import java.io.Reader;
31 import java.net.URL;
32 import java.util.ArrayList;
33 import java.util.List;
34
35 import org.utgenome.gwt.utgb.client.bio.CytoBand;
36 import org.xerial.core.XerialException;
37 import org.xerial.lens.SilkLens;
38 import org.xerial.util.ObjectHandler;
39
40
41
42
43
44
45
46 public class CompactFASTAIndex {
47
48
49
50
51 public String name;
52
53
54
55 public String description;
56
57
58
59
60 public long offset;
61
62
63
64 public int length;
65
66 private static class IndexHolder implements ObjectHandler<CompactFASTAIndex> {
67
68 ArrayList<CompactFASTAIndex> index = new ArrayList<CompactFASTAIndex>();
69
70 public void init() throws Exception {
71
72 }
73
74 public void handle(CompactFASTAIndex input) throws Exception {
75 index.add(input);
76 }
77
78 public void finish() throws Exception {
79
80 }
81
82 }
83
84 public static List<CompactFASTAIndex> load(URL indexFile) throws XerialException, IOException {
85 Reader in = new BufferedReader(new InputStreamReader(indexFile.openStream()));
86 return load(in);
87 }
88
89 public static List<CompactFASTAIndex> load(Reader indexFile) throws XerialException, IOException {
90 IndexHolder holder = new IndexHolder();
91 SilkLens.findFromSilk(indexFile, "sequence", CompactFASTAIndex.class, holder);
92
93 return holder.index;
94 }
95
96
97
98
99
100
101 public CytoBand toCytoBand() {
102 return new CytoBand(name, 1, length, "", null);
103 }
104
105 }