├── CircView.tar.gz
├── LICENSE
├── README.md
├── UserGuide.pdf
├── image
├── circrna-clear.png
├── circrna-files-add.png
├── circrna-load.png
├── circrna-mre-rbp-details.png
├── circrna-mre-rbp.png
├── comparison-table.png
├── dblink.png
├── mre-clear.png
├── mre-load.png
├── one-circrna.png
├── species-add.png
├── species-default.png
├── species-del.png
├── tool-add.png
├── tool-del.png
└── whole-circrna.png
├── src
└── cn
│ └── edu
│ └── whu
│ ├── CircRna.java
│ ├── CircRnaTool.java
│ ├── CircView.java
│ ├── Exon.java
│ ├── Gene.java
│ ├── GeneTranscript.java
│ ├── MainData.java
│ ├── exception
│ └── FileReadException.java
│ ├── ui
│ ├── AboutDialog.java
│ ├── CircRnaDataClearDialog.java
│ ├── CircRnaDataLoadDialog.java
│ ├── CircRnaImagePanel.java
│ ├── CircRnaToolAddDialog.java
│ ├── CircRnaToolDelDialog.java
│ ├── ComparisonFrame.java
│ ├── CsvSaveFileChooser.java
│ ├── DataLoadingDialog.java
│ ├── DataLoadingProgressDialog.java
│ ├── DetailsResultDialog.java
│ ├── ImageSaveFileChooser.java
│ ├── MreClearDialog.java
│ ├── MreLoadDialog.java
│ ├── OpenFileChooser.java
│ ├── ProgressDialog.java
│ ├── RbpClearDialog.java
│ ├── RbpLoadDialog.java
│ ├── SaveImageDialog.java
│ ├── SpeciesAddDialog.java
│ └── SpeciesDelDialog.java
│ └── util
│ ├── CloneUtils.java
│ ├── Constant.java
│ ├── DbConfig.java
│ ├── DbUtil.java
│ ├── EvenOddRenderer.java
│ ├── MyMath.java
│ ├── RuntimeUtils.java
│ └── TextAreaCellRenderer.java
└── testdata
└── human.tar.gz
/CircView.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/CircView.tar.gz
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **1. BEST PRACTISE**
2 | > **1.1. Basic Feature: CircRNAs Visualization**
3 | > 1.1.1 Java Virtual Machine needs to be installed before running this program. See **7 HOW TO INSTALL JAVA VIRTUAL MACHINE**.
4 | > 1.1.2 Download and decompress "CircView.tar.gz" from http://github.com/GeneFeng/CircView/blob/master/CircView.tar.gz
5 | > Double click CircView.jar to launch the program.
6 | > 1.1.3 Download and decompress circRNA data from https://github.com/GeneFeng/CircView/blob/master/testdata/human.tar.gz
7 | > 1.1.4 Click “CircRNA”->”Load Data” to load circRNA files according species and tools.
8 | >
9 | > 1.1.5 Click gene transcript name on list panel to view the image of the circRNAs.
10 | >
11 | > 1.1.6 Gene transcript can be searched by name or location.
12 | > 1.1.7 Click one "Circle" to view details of each circRNA.
13 | >
14 | > 1.1.8 Detailed information and image of circRNAs can be saved for further use.
15 | > 1.1.9 Click "Analysis"->"Comparison" to make a comparison between circRNAs with different samples and/or tools.
16 | >
17 | > Click "Save as" button to export results to a ".csv" file for further use.
18 |
19 | > **1.2. Advanced Feature: MRE and RBP sites Visualization on CircRNAs**
20 | > 1.2.1 MySQL needs to be installed, see **8 HOW TO INSTALL MYSQL**.
21 | > 1.2.2 Restart CircView.jar
22 | > 1.2.3 Download and decompress MRE data from http://gb.whu.edu.cn/CircView/testdata/mre_human.tar.gz
23 | > 1.2.4 Click “MRE”->”Load Data” to load MRE file.
24 | > 1.2.5 Download and decompress RBP data from http://gb.whu.edu.cn/CircView/testdata/rbp_human.tar.gz
25 | > 1.2.6 Click “RBP”->”Load Data” to load RBP file.
26 | > 1.2.7 Load circRNAs data, see 1.1.4
27 | > 1.2.8 Check MRE or RBP to add MRE sites (blue lines) or RBP sites (red triangles) to CircRNAs.
28 | >
29 | > 1.2.9 Click "Details" button to see detailed information of MRE and RBP sites.
30 | >
31 |
32 | **2. HOW TO GET CIRCVIEW AND TEST DATA**
33 | > Download CircView application from http://github.com/GeneFeng/CircView/blob/master/CircView.tar.gz
34 | > Download circRNAs test data from https://github.com/GeneFeng/CircView/blob/master/testdata
35 | > Download MRE data from http://gb.whu.edu.cn/CircView/testdata/mre_human.tar.gz
36 | > Download RBP data from http://gb.whu.edu.cn/CircView/testdata/rbp_human.tar.gz
37 |
38 | **3. HOW TO MANAGE CIRCRNAS DATA**
39 | > **3.1. CircRNAs Identification Tool Management**
40 | > CircView integrates 6 CircRNAs identification tools (CIRCexplorer, circRNA_finder, CIRI, find_circ, Mapsplice, and UROBORUB) by default.
41 | > Users can add or delete tool by using menu “CircRNA”->”Add Tool” or “CircRNA”->”Delete Tool”.
42 | >
43 | >
44 | >**3.2. CircRNAs Data Management**
45 | > CircView can load CircRNAs data directly from output of default 6 CircRNAs identification tools.
46 | > Users can also import circRNAs identified by other tools with six tab delimited columns, including chromosome, start point, end point, running number/name, junction reads and strand.
47 | >
48 |
49 | **4. HOW TO MANAGE SPECIES DATA**
50 | > CircView provides 7 species (Human (hg38), Human (hg19), Mouse (mm10), Mouse (mm9), Zebrafish (zv9), Fly (dm6), C.elegans (ce10)) by default.
51 | >
52 | > Users can also add or delete species annotation data with compatible format by using menu “Species”->”Add Species” or “Species”->”Delete Species”.
53 | >
54 |
55 | **5. HOW TO FIND CIRCRNA DATABASES**
56 | > CircView provides links to existing circRNA databases, including Circ2Traits, CircBase, CircInteractome, CircNet, circRNADb, StarBase, and TSCD.
57 | >
58 |
59 | **6. HOW TO MANAGE MRE AND RBP DATA**
60 | > CircRNAs mainly function as sponges for the regulatory elements, such as miRNA respond elements (MREs) and RNA binding proteins (RBPs). CircView provides advanced features to display regulatory elements.
61 | > This module requires the users to install MySQL locally, see **8 HOW TO INSTALL MYSQL**. Users can load and display the MRE data identified by TargetScan (http://targetscan.org/) and/or the RBP data identified by starBase (http://starbase.sysu.edu.cn/) or any other tool. The format requires five tab delimited columns, including chromosome, start site, end site, MRE/RBP name and description.
62 | > Load MRE or RBP file will create table and deposit data into MySQL database, and Clear MRE or RBP will remove data from the database. As the data are persistent, users should not load the same data for more than once.
63 | >
64 |
65 | **7. HOW TO INSTALL JAVA VIRTUAL MACHINE**
66 | > Java Virtual Machine needs to be installed before running this program. Simply access http://www.java.com, download Java, and install it.
67 |
68 | **8. HOW TO INSTALL MYSQL**
69 | > **8.1. For Windows**
70 | > 8.1.1 Download and decompress MySQL Installation file from http://gb.whu.edu.cn/CircView/MySQL/mysql_windows.tar.gz
71 | > 8.1.2 Double click “NDP46-KB3045557-x86-x64-AllOS-ENU.exe” to install .NET Framework.
72 | > 8.1.3 Double click “mysql-installer-community-5.7.16.0.msi” to install MySQL. Please create password “12345” for user root during installation.
73 | >
74 | > **8.2. For Mac OS**
75 | > 8.2.1 Download MySQL Installation file from http://gb.whu.edu.cn/CircView/MySQL/mysql-5.7.17-macos10.12-x86_64.dmg
76 | > 8.2.2 Double click “mysql-5.7.17-macos10.12-x86_64.dmg” to install MySQL. Please create password “12345” for user root during installation.
77 |
--------------------------------------------------------------------------------
/UserGuide.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/UserGuide.pdf
--------------------------------------------------------------------------------
/image/circrna-clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/circrna-clear.png
--------------------------------------------------------------------------------
/image/circrna-files-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/circrna-files-add.png
--------------------------------------------------------------------------------
/image/circrna-load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/circrna-load.png
--------------------------------------------------------------------------------
/image/circrna-mre-rbp-details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/circrna-mre-rbp-details.png
--------------------------------------------------------------------------------
/image/circrna-mre-rbp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/circrna-mre-rbp.png
--------------------------------------------------------------------------------
/image/comparison-table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/comparison-table.png
--------------------------------------------------------------------------------
/image/dblink.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/dblink.png
--------------------------------------------------------------------------------
/image/mre-clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/mre-clear.png
--------------------------------------------------------------------------------
/image/mre-load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/mre-load.png
--------------------------------------------------------------------------------
/image/one-circrna.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/one-circrna.png
--------------------------------------------------------------------------------
/image/species-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/species-add.png
--------------------------------------------------------------------------------
/image/species-default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/species-default.png
--------------------------------------------------------------------------------
/image/species-del.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/species-del.png
--------------------------------------------------------------------------------
/image/tool-add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/tool-add.png
--------------------------------------------------------------------------------
/image/tool-del.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/tool-del.png
--------------------------------------------------------------------------------
/image/whole-circrna.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/image/whole-circrna.png
--------------------------------------------------------------------------------
/src/cn/edu/whu/CircRna.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu;
2 |
3 | import java.io.Serializable;
4 | import java.util.TreeMap;
5 |
6 | /**
7 | * CircRna
8 | *
9 | * @author Gene
10 | *
11 | */
12 | public class CircRna implements Serializable {
13 |
14 | private static final long serialVersionUID = 1L;
15 |
16 | /**
17 | * circRNA ID
18 | */
19 | private String circRnaID;
20 |
21 | /**
22 | * Chromosome name
23 | */
24 | private String chrom;
25 |
26 | /**
27 | * circRNA start point;
28 | */
29 | private long startPoint;
30 |
31 | /**
32 | * circRNA end point;
33 | */
34 | private long endPoint;
35 |
36 | /**
37 | * strand
38 | */
39 | private String strand;
40 |
41 | /**
42 | * junction reads
43 | */
44 | private int junctionReads;
45 |
46 | /**
47 | * "geneName transcriptName" "geneName transcriptName" pair
48 | */
49 | private TreeMap geneTranscrpits;
50 |
51 | /**
52 | * Repeat Times
53 | */
54 | // private int repeat;
55 |
56 | private TreeMap samples;
57 | private TreeMap circTools;
58 | private TreeMap files;
59 |
60 | /**
61 | * exon or intron or intergenic
62 | */
63 | private String region;
64 |
65 | /**
66 | * mRNA or lncRNA or unknown
67 | */
68 | private String circRnaType;
69 |
70 | /**
71 | * Constructor of CircRna
72 | *
73 | * @param geneName
74 | */
75 | public CircRna(String circRnaID) {
76 | this.circRnaID = circRnaID;
77 | geneTranscrpits = new TreeMap();
78 | samples = new TreeMap();
79 | circTools = new TreeMap();
80 | files = new TreeMap();
81 | }
82 |
83 | public String getCircRnaID() {
84 | return circRnaID;
85 | }
86 |
87 | public void setCircRnaID(String circRnaID) {
88 | this.circRnaID = circRnaID;
89 | }
90 |
91 | public String getChrom() {
92 | return chrom;
93 | }
94 |
95 | public void setChrom(String chrom) {
96 | this.chrom = chrom;
97 | }
98 |
99 | public long getStartPoint() {
100 | return startPoint;
101 | }
102 |
103 | public void setStartPoint(long startPoint) {
104 | this.startPoint = startPoint;
105 | }
106 |
107 | public long getEndPoint() {
108 | return endPoint;
109 | }
110 |
111 | public void setEndPoint(long endPoint) {
112 | this.endPoint = endPoint;
113 | }
114 |
115 | public String getStrand() {
116 | return strand;
117 | }
118 |
119 | public void setStrand(String strand) {
120 | this.strand = strand;
121 | }
122 |
123 | public int getJunctionReads() {
124 | return junctionReads;
125 | }
126 |
127 | public void setJunctionReads(int junctionReads) {
128 | this.junctionReads = junctionReads;
129 | }
130 |
131 | public String getRegion() {
132 | return region;
133 | }
134 |
135 | public void setRegion(String region) {
136 | this.region = region;
137 | }
138 |
139 | public String getCircRnaType() {
140 | return circRnaType;
141 | }
142 |
143 | public void setCircRnaType(String circRnaType) {
144 | this.circRnaType = circRnaType;
145 | }
146 |
147 | /**
148 | * @return the geneTranscrpits
149 | */
150 | public TreeMap getGeneTranscrpits() {
151 | return geneTranscrpits;
152 | }
153 |
154 | /**
155 | * @param geneTranscrpits
156 | * the geneTranscrpits to set
157 | */
158 | public void setGeneTranscrpits(TreeMap geneTranscrpits) {
159 | this.geneTranscrpits = geneTranscrpits;
160 | }
161 |
162 | /**
163 | * @return the samples
164 | */
165 | public TreeMap getSamples() {
166 | return samples;
167 | }
168 |
169 | /**
170 | * @param samples
171 | * the samples to set
172 | */
173 | public void setSamples(TreeMap samples) {
174 | this.samples = samples;
175 | }
176 |
177 | /**
178 | * @return the circTools
179 | */
180 | public TreeMap getCircTools() {
181 | return circTools;
182 | }
183 |
184 | /**
185 | * @param circTools
186 | * the circTools to set
187 | */
188 | public void setCircTools(TreeMap circTools) {
189 | this.circTools = circTools;
190 | }
191 |
192 | /**
193 | * @return the files
194 | */
195 | public TreeMap getFiles() {
196 | return files;
197 | }
198 |
199 | /**
200 | * @param files
201 | * the files to set
202 | */
203 | public void setFiles(TreeMap files) {
204 | this.files = files;
205 | }
206 |
207 | // /**
208 | // * @return the repeat
209 | // */
210 | // public int getRepeat() {
211 | // return repeat;
212 | // }
213 | //
214 | // /**
215 | // * @param repeat the repeat to set
216 | // */
217 | // public void setRepeat(int repeat) {
218 | // this.repeat = repeat;
219 | // }
220 | }
221 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/CircRnaTool.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.File;
5 | import java.io.FileReader;
6 | import java.io.Serializable;
7 | import java.util.ArrayList;
8 | import java.util.Collections;
9 | import java.util.TreeMap;
10 | import java.util.Vector;
11 |
12 | import cn.edu.whu.exception.FileReadException;
13 | import cn.edu.whu.util.Constant;
14 |
15 | public class CircRnaTool implements Serializable {
16 | private static final long serialVersionUID = 1L;
17 |
18 | public CircRnaTool() {
19 | }
20 |
21 | public static boolean initSpeciesDataFromFile(File file, TreeMap genes) {
22 | return parseGeneTranscriptFile(file, genes);
23 | }
24 |
25 | public static boolean initCircRnaDataFromFiles(Vector> fileTableData, String speciesName,
26 | TreeMap genes) throws FileReadException {
27 | return addCircRnaData(fileTableData, speciesName, genes);
28 | }
29 |
30 | private static boolean addCircRnaData(Vector> fileTableData, String speciesName,
31 | TreeMap genes) throws FileReadException {
32 | TreeMap circRnas = new TreeMap();
33 | for (Vector rowData : fileTableData) {
34 | String species = rowData.get(0);
35 | if (!species.equalsIgnoreCase(speciesName)) {
36 | continue;
37 | }
38 | String toolName = rowData.get(1);
39 | String fileName = rowData.get(2);
40 | String filePath = rowData.get(3);
41 | String[] tmp = fileName.split("\\.");
42 | String sampleName = tmp[0];
43 | File file = new File(filePath);
44 | if (toolName.equalsIgnoreCase(Constant.TOOL_CIRCRNAFINDER)
45 | || toolName.equalsIgnoreCase(Constant.TOOL_FIND_CIRC)) {
46 | if (!parseCircRnaFinderFile(file, circRnas, sampleName, toolName, fileName)) {
47 | throw new FileReadException("Can not open [" + file.getName() + "] or file FORMAT ERROR!");
48 | }
49 | } else if (toolName.equalsIgnoreCase(Constant.TOOL_CIRI)) {
50 | if (!parseCiriFile(file, circRnas, sampleName, toolName, fileName)) {
51 | throw new FileReadException("Can not open [" + file.getName() + "] or file FORMAT ERROR!");
52 | }
53 | } else if (toolName.equalsIgnoreCase(Constant.TOOL_CIRCEXPLORER)) {
54 | if (!parseCircExplorerFile(file, circRnas, sampleName, toolName, fileName)) {
55 | throw new FileReadException("Can not open [" + file.getName() + "] or file FORMAT ERROR!");
56 | }
57 | } else if (toolName.equalsIgnoreCase(Constant.TOOL_MAPSPLICE)) {
58 | if (!parseMapspliceFile(file, circRnas, sampleName, toolName, fileName)) {
59 | throw new FileReadException("Can not open [" + file.getName() + "] or file FORMAT ERROR!");
60 | }
61 | } else if (toolName.equalsIgnoreCase(Constant.TOOL_UROBORUS)) {
62 | if (!parseUroborusFile(file, circRnas, sampleName, toolName, fileName)) {
63 | throw new FileReadException("Can not open [" + file.getName() + "] or file FORMAT ERROR!");
64 | }
65 | } else {
66 | if (!parseCircRnaFinderFile(file, circRnas, sampleName, toolName, fileName)) {
67 | throw new FileReadException("Can not open [" + file.getName() + "] or file FORMAT ERROR!");
68 | }
69 |
70 | }
71 | }
72 | CircView.log.info("Genes number: " + genes.size());
73 | CircView.log.info("CircRNAs number: " + circRnas.size());
74 | assignAll(genes, circRnas);
75 | return true;
76 | }
77 |
78 | private static boolean parseGeneTranscriptFile(File file, TreeMap genes) {
79 | boolean ret = true;
80 | CircView.log.info("Parsing " + file.getName());
81 | BufferedReader reader = null;
82 | try {
83 | if (file.isFile() && file.exists()) {
84 | reader = new BufferedReader(new FileReader(file));
85 | String lineTxt = null;
86 | int lineNum = 0;
87 | while ((lineTxt = reader.readLine()) != null) {
88 | lineNum++;
89 | if (lineTxt.toLowerCase().contains("gene")) {
90 | continue;
91 | }
92 | String[] parts = lineTxt.split("\t");
93 | // parts[0] Gene Name
94 | // parts[1] Gene Transcript Name
95 | // parts[2] Chromosome name
96 | // parts[3] + or - for strand
97 | // parts[4] Transcription start position
98 | // parts[5] Transcription end position
99 | // parts[6] Coding region start
100 | // parts[7] Coding region end
101 | // parts[8] Number of exons
102 | // parts[9] Exon start postions
103 | // parts[10] Exon end postions
104 | if (parts[3].contains("+") || parts[3].contains("-")) {
105 | } else if (1 == lineNum) {
106 | continue;
107 | } else {
108 | reader.close();
109 | return false;
110 | }
111 | String geneName = parts[0];
112 | GeneTranscript geneTranscript = new GeneTranscript(geneName);
113 | geneTranscript.setTranscriptName(parts[1]);
114 | geneTranscript.setChrom(parts[2]);
115 | geneTranscript.setStrand(parts[3]);
116 | geneTranscript.setTxStart(Long.parseLong(parts[4]));
117 | geneTranscript.setTxEnd(Long.parseLong(parts[5]));
118 | geneTranscript.setCdsStart(Long.parseLong(parts[6]));
119 | geneTranscript.setCdsEnd(Long.parseLong(parts[7]));
120 | geneTranscript.setExonCount(Integer.parseInt(parts[8]));
121 | String[] exonStarts = parts[9].split(",");
122 | for (int i = 0; i < exonStarts.length; i++) {
123 | geneTranscript.getExonStarts().addElement(Long.parseLong(exonStarts[i]));
124 | }
125 | String[] exonEnds = parts[10].split(",");
126 | for (int i = 0; i < exonEnds.length; i++) {
127 | geneTranscript.getExonEnds().addElement(Long.parseLong(exonEnds[i]));
128 | }
129 | if (genes.containsKey(geneName.toUpperCase())) {
130 | genes.get(geneName.toUpperCase()).getGeneTranscripts().put(geneTranscript.getTranscriptName(),
131 | geneTranscript);
132 | } else {
133 | Gene gene = new Gene(geneName);
134 | gene.getGeneTranscripts().put(geneTranscript.getTranscriptName(), geneTranscript);
135 | genes.put(geneName.toUpperCase(), gene);
136 | }
137 | }
138 | reader.close();
139 | } else {
140 | ret = false;
141 | CircView.log.info("Can't open the file: " + file.getName());
142 | }
143 | } catch (Exception e) {
144 | ret = false;
145 | CircView.log.warn(e.getMessage());
146 | }
147 | return ret;
148 | }
149 |
150 | private static boolean parseCircRnaFinderFile(File file, TreeMap circRnas, String sampleName,
151 | String circTool, String fileName) {
152 | boolean ret = true;
153 | CircView.log.info("Parsing " + file.getName());
154 | BufferedReader reader = null;
155 | try {
156 | if (file.isFile() && file.exists()) {
157 | reader = new BufferedReader(new FileReader(file));
158 | String lineTxt = null;
159 | int lineNum = 0;
160 | while ((lineTxt = reader.readLine()) != null) {
161 | lineNum++;
162 | if (lineTxt.toLowerCase().contains("strand")) {
163 | continue;
164 | }
165 | String[] parts = lineTxt.split("\t");
166 | // parts[0] Chromosome name
167 | // parts[1] start position
168 | // parts[2] end position
169 | // parts[3]
170 | // parts[4] junction reads
171 | // parts[5] + or - for strand
172 | if (parts[5].contains("+") || parts[5].contains("-")) {
173 | } else if (1 == lineNum) {
174 | continue;
175 | } else {
176 | reader.close();
177 | return false;
178 | }
179 | String circRnaId = parts[0] + ":" + parts[1] + "|" + parts[2];
180 | CircRna circRna = new CircRna(circRnaId);
181 | circRna.setChrom(parts[0]);
182 | circRna.setStartPoint(Long.parseLong(parts[1]));
183 | circRna.setEndPoint(Long.parseLong(parts[2]));
184 | circRna.setJunctionReads((int) Long.parseLong(parts[4]));
185 | circRna.setStrand(parts[5]);
186 | if (circRnas.containsKey(circRnaId.toUpperCase())) {
187 | if (null != circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName)) {
188 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName,
189 | circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName) + 1);
190 | } else {
191 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName, 1);
192 | }
193 | if (null != circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool)) {
194 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool,
195 | circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool) + 1);
196 | } else {
197 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool, 1);
198 | }
199 | if (null != circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName)) {
200 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName,
201 | circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName) + 1);
202 | } else {
203 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName, 1);
204 | }
205 | // Save the Max Junction reads
206 | if (circRna.getJunctionReads() > circRnas.get(circRnaId.toUpperCase()).getJunctionReads()) {
207 | circRnas.get(circRnaId.toUpperCase()).setJunctionReads(circRna.getJunctionReads());
208 | }
209 | } else {
210 | circRna.getSamples().put(sampleName, 1);
211 | circRna.getCircTools().put(circTool, 1);
212 | circRna.getFiles().put(fileName, 1);
213 | circRnas.put(circRnaId.toUpperCase(), circRna);
214 | }
215 | }
216 | reader.close();
217 | } else {
218 | CircView.log.warn("Can't find the file: " + file.getName());
219 | }
220 | } catch (Exception e) {
221 | CircView.log.warn(e.getMessage());
222 | ret = false;
223 | }
224 | return ret;
225 | }
226 |
227 | private static boolean parseCircExplorerFile(File file, TreeMap circRnas, String sampleName,
228 | String circTool, String fileName) {
229 | boolean ret = true;
230 | CircView.log.info("Parsing " + file.getName());
231 | BufferedReader reader = null;
232 | try {
233 | if (file.isFile() && file.exists()) {
234 | reader = new BufferedReader(new FileReader(file));
235 | String lineTxt = null;
236 | int lineNum = 0;
237 | while ((lineTxt = reader.readLine()) != null) {
238 | lineNum++;
239 | String[] parts = lineTxt.split("\t");
240 | // parts[0] Chromosome name
241 | // parts[1] start position
242 | // parts[2] end position
243 | // parts[3] CircRNA/junction reads
244 | // parts[4]
245 | // parts[5] + or - for strand
246 | if (parts[5].contains("+") || parts[5].contains("-")) {
247 | } else if (1 == lineNum) {
248 | continue;
249 | } else {
250 | reader.close();
251 | return false;
252 | }
253 | String circRnaId = parts[0] + ":" + parts[1] + "|" + parts[2];
254 | CircRna circRna = new CircRna(circRnaId);
255 | circRna.setChrom(parts[0]);
256 | circRna.setStartPoint(Long.parseLong(parts[1]));
257 | circRna.setEndPoint(Long.parseLong(parts[2]));
258 | String tmp = parts[3];
259 | String[] junc = tmp.split("/");
260 | circRna.setJunctionReads((int) Long.parseLong(junc[1]));
261 | circRna.setStrand(parts[5]);
262 | if (circRnas.containsKey(circRnaId.toUpperCase())) {
263 | if (null != circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName)) {
264 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName,
265 | circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName) + 1);
266 | } else {
267 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName, 1);
268 | }
269 | if (null != circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool)) {
270 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool,
271 | circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool) + 1);
272 | } else {
273 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool, 1);
274 | }
275 | if (null != circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName)) {
276 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName,
277 | circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName) + 1);
278 | } else {
279 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName, 1);
280 | }
281 | // Save the Max Junction reads
282 | if (circRna.getJunctionReads() > circRnas.get(circRnaId.toUpperCase()).getJunctionReads()) {
283 | circRnas.get(circRnaId.toUpperCase()).setJunctionReads(circRna.getJunctionReads());
284 | }
285 | } else {
286 | circRna.getSamples().put(sampleName, 1);
287 | circRna.getCircTools().put(circTool, 1);
288 | circRna.getFiles().put(fileName, 1);
289 | circRnas.put(circRnaId.toUpperCase(), circRna);
290 | }
291 | }
292 | reader.close();
293 | } else {
294 | CircView.log.warn("Can't find the file: " + file.getName());
295 | }
296 | } catch (Exception e) {
297 | CircView.log.warn(e.getMessage());
298 | ret = false;
299 | }
300 | return ret;
301 | }
302 |
303 | private static boolean parseCiriFile(File file, TreeMap circRnas, String sampleName,
304 | String circTool, String fileName) {
305 | boolean ret = true;
306 | CircView.log.info("Parsing " + file.getName());
307 | BufferedReader reader = null;
308 | try {
309 | if (file.isFile() && file.exists()) {
310 | reader = new BufferedReader(new FileReader(file));
311 | String lineTxt = null;
312 | int lineNum = 0;
313 | while ((lineTxt = reader.readLine()) != null) {
314 | lineNum++;
315 | String[] parts = lineTxt.split("\t");
316 | // parts[0] CircRNA ID
317 | // parts[1] Chromosome name
318 | // parts[2] start position
319 | // parts[3] end position
320 | // parts[4] junction reads
321 | // parts[10] + or - for strand
322 | if (parts[10].contains("+") || parts[10].contains("-")) {
323 | } else if (1 == lineNum) {
324 | continue;
325 | } else {
326 | reader.close();
327 | return false;
328 | }
329 | String circRnaId = parts[0];
330 | CircRna circRna = new CircRna(circRnaId);
331 | circRna.setChrom(parts[1]);
332 | circRna.setStartPoint(Long.parseLong(parts[2]));
333 | circRna.setEndPoint(Long.parseLong(parts[3]));
334 | circRna.setJunctionReads((int) Long.parseLong(parts[4]));
335 | circRna.setStrand(parts[10]);
336 | if (circRnas.containsKey(circRnaId.toUpperCase())) {
337 | if (null != circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName)) {
338 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName,
339 | circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName) + 1);
340 | } else {
341 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName, 1);
342 | }
343 | if (null != circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool)) {
344 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool,
345 | circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool) + 1);
346 | } else {
347 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool, 1);
348 | }
349 | if (null != circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName)) {
350 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName,
351 | circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName) + 1);
352 | } else {
353 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName, 1);
354 | }
355 | // Save the Max Junction reads
356 | if (circRna.getJunctionReads() > circRnas.get(circRnaId.toUpperCase()).getJunctionReads()) {
357 | circRnas.get(circRnaId.toUpperCase()).setJunctionReads(circRna.getJunctionReads());
358 | }
359 | } else {
360 | circRna.getSamples().put(sampleName, 1);
361 | circRna.getCircTools().put(circTool, 1);
362 | circRna.getFiles().put(fileName, 1);
363 | circRnas.put(circRnaId.toUpperCase(), circRna);
364 | }
365 | }
366 | reader.close();
367 | } else {
368 | CircView.log.warn("Can't find the file: " + file.getName());
369 | ret = false;
370 | }
371 | } catch (Exception e) {
372 | CircView.log.warn(e.getMessage());
373 | ret = false;
374 | }
375 | return ret;
376 | }
377 |
378 | private static boolean parseMapspliceFile(File file, TreeMap circRnas, String sampleName,
379 | String circTool, String fileName) {
380 | boolean ret = true;
381 | CircView.log.info("Parsing " + file.getName());
382 | BufferedReader reader = null;
383 | try {
384 | if (file.isFile() && file.exists()) {
385 | reader = new BufferedReader(new FileReader(file));
386 | String lineTxt = null;
387 | int lineNum = 0;
388 | while ((lineTxt = reader.readLine()) != null) {
389 | lineNum++;
390 | if (lineTxt.toLowerCase().contains("circ")) {
391 | continue;
392 | }
393 | String[] parts = lineTxt.split("\t");
394 | // parts[0] Chromosome name
395 | // parts[1] start position
396 | // parts[2] end position
397 | // parts[3]
398 | // parts[4] junction reads
399 | // parts[5] + or - for strand
400 | // parts[6]
401 | if (parts[5].contains("+") || parts[5].contains("-")) {
402 | } else if (1 == lineNum) {
403 | continue;
404 | } else {
405 | reader.close();
406 | return false;
407 | }
408 | String[] tmp = parts[0].split("~");
409 | String chr = tmp[0];
410 | String circRnaId = chr + ":" + parts[1] + "|" + parts[2];
411 | CircRna circRna = new CircRna(circRnaId);
412 | circRna.setChrom(chr);
413 | circRna.setStartPoint(Long.parseLong(parts[1]));
414 | circRna.setEndPoint(Long.parseLong(parts[2]));
415 | circRna.setStrand(parts[5].substring(0, 1));
416 | circRna.setJunctionReads((int) Long.parseLong(parts[4]));
417 | if (circRnas.containsKey(circRnaId.toUpperCase())) {
418 | if (null != circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName)) {
419 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName,
420 | circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName) + 1);
421 | } else {
422 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName, 1);
423 | }
424 | if (null != circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool)) {
425 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool,
426 | circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool) + 1);
427 | } else {
428 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool, 1);
429 | }
430 | if (null != circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName)) {
431 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName,
432 | circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName) + 1);
433 | } else {
434 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName, 1);
435 | }
436 | // Save the Max Junction reads
437 | if (circRna.getJunctionReads() > circRnas.get(circRnaId.toUpperCase()).getJunctionReads()) {
438 | circRnas.get(circRnaId.toUpperCase()).setJunctionReads(circRna.getJunctionReads());
439 | }
440 | } else {
441 | circRna.getSamples().put(sampleName, 1);
442 | circRna.getCircTools().put(circTool, 1);
443 | circRna.getFiles().put(fileName, 1);
444 | circRnas.put(circRnaId.toUpperCase(), circRna);
445 | }
446 | }
447 | reader.close();
448 | } else {
449 | CircView.log.warn("Can't find the file: " + file.getName());
450 | }
451 | } catch (Exception e) {
452 | CircView.log.warn(e.getMessage());
453 | ret = false;
454 | }
455 | return ret;
456 | }
457 |
458 | private static boolean parseUroborusFile(File file, TreeMap circRnas, String sampleName,
459 | String circTool, String fileName) {
460 | boolean ret = true;
461 | CircView.log.info("Parsing " + file.getName());
462 | BufferedReader reader = null;
463 | try {
464 | if (file.isFile() && file.exists()) {
465 | reader = new BufferedReader(new FileReader(file));
466 | String lineTxt = null;
467 | int lineNum = 0;
468 | while ((lineTxt = reader.readLine()) != null) {
469 | lineNum++;
470 | if (lineTxt.toLowerCase().contains("circ")) {
471 | continue;
472 | }
473 | String[] parts = lineTxt.split("\t");
474 | // parts[0] Chromosome name
475 | // parts[1] start position
476 | // parts[2] end position
477 | // parts[3] + or - for strand
478 | // parts[4]
479 | // parts[5]
480 | // parts[6] junction reads
481 | if (parts[3].contains("+") || parts[3].contains("-")) {
482 | } else if (1 == lineNum) {
483 | continue;
484 | } else {
485 | reader.close();
486 | return false;
487 | }
488 | String circRnaId = parts[0] + ":" + parts[1] + "|" + parts[2];
489 | CircRna circRna = new CircRna(circRnaId);
490 | circRna.setChrom(parts[0]);
491 | circRna.setStartPoint(Long.parseLong(parts[1]));
492 | circRna.setEndPoint(Long.parseLong(parts[2]));
493 | circRna.setStrand(parts[3]);
494 | circRna.setJunctionReads((int) Long.parseLong(parts[6]));
495 | if (circRnas.containsKey(circRnaId.toUpperCase())) {
496 | if (null != circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName)) {
497 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName,
498 | circRnas.get(circRnaId.toUpperCase()).getSamples().get(sampleName) + 1);
499 | } else {
500 | circRnas.get(circRnaId.toUpperCase()).getSamples().put(sampleName, 1);
501 | }
502 | if (null != circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool)) {
503 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool,
504 | circRnas.get(circRnaId.toUpperCase()).getCircTools().get(circTool) + 1);
505 | } else {
506 | circRnas.get(circRnaId.toUpperCase()).getCircTools().put(circTool, 1);
507 | }
508 | if (null != circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName)) {
509 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName,
510 | circRnas.get(circRnaId.toUpperCase()).getFiles().get(fileName) + 1);
511 | } else {
512 | circRnas.get(circRnaId.toUpperCase()).getFiles().put(fileName, 1);
513 | }
514 | // Save the Max Junction reads
515 | if (circRna.getJunctionReads() > circRnas.get(circRnaId.toUpperCase()).getJunctionReads()) {
516 | circRnas.get(circRnaId.toUpperCase()).setJunctionReads(circRna.getJunctionReads());
517 | }
518 | } else {
519 | circRna.getSamples().put(sampleName, 1);
520 | circRna.getCircTools().put(circTool, 1);
521 | circRna.getFiles().put(fileName, 1);
522 | circRnas.put(circRnaId.toUpperCase(), circRna);
523 | }
524 | }
525 | reader.close();
526 | } else {
527 | CircView.log.warn("Can't find the file: " + file.getName());
528 | }
529 | } catch (Exception e) {
530 | CircView.log.warn(e.getMessage());
531 | ret = false;
532 | }
533 | return ret;
534 | }
535 |
536 | private static void preAssign(TreeMap allGene, TreeMap> txStartMap,
537 | TreeMap> txEndMap, TreeMap> txStart2Name,
538 | TreeMap> txEnd2Name) {
539 |
540 | // Init Maps
541 | txStartMap.clear();
542 | txEndMap.clear();
543 | txStart2Name.clear();
544 | txEnd2Name.clear();
545 |
546 | // Create Chrom -- > txStart-geneNames pair
547 | for (String geneName : allGene.keySet()) {
548 | String chrom = "";
549 | TreeMap tmpUniqueStart = new TreeMap();
550 | TreeMap tmpUniqueEnd = new TreeMap();
551 | TreeMap transcripts = allGene.get(geneName.toUpperCase()).getGeneTranscripts();
552 | for (String transcriptName : transcripts.keySet()) {
553 | GeneTranscript transcript = transcripts.get(transcriptName);
554 | chrom = transcript.getChrom();
555 | Long txStart = transcript.getTxStart();
556 | Long txEnd = transcript.getTxEnd();
557 | if (txStart2Name.get(txStart) != null) {
558 | TreeMap genesTmp = txStart2Name.get(txStart);
559 | genesTmp.put(geneName, geneName);
560 | txStart2Name.put(txStart, genesTmp);
561 | } else {
562 | TreeMap genesTmp = new TreeMap();
563 | genesTmp.put(geneName, geneName);
564 | txStart2Name.put(txStart, genesTmp);
565 | }
566 | if (txEnd2Name.get(txEnd) != null) {
567 | TreeMap genesTmp = txEnd2Name.get(txEnd);
568 | genesTmp.put(geneName, geneName);
569 | txEnd2Name.put(txEnd, genesTmp);
570 | } else {
571 | TreeMap genesTmp = new TreeMap();
572 | genesTmp.put(geneName, geneName);
573 | txEnd2Name.put(txEnd, genesTmp);
574 | }
575 | tmpUniqueStart.put(txStart, 1);
576 | tmpUniqueEnd.put(txEnd, 1);
577 | }
578 | // Create Unique txStart and txEnd list
579 | ArrayList uniqueStartList = new ArrayList();
580 | ArrayList uniqueEndList = new ArrayList();
581 | for (Long txStart : tmpUniqueStart.keySet()) {
582 | uniqueStartList.add(txStart);
583 | }
584 | for (Long txEnd : tmpUniqueEnd.keySet()) {
585 | uniqueEndList.add(txEnd);
586 | }
587 | // Create Chrom --> Unique List
588 | if (txStartMap.get(chrom) != null) {
589 | txStartMap.get(chrom).addAll(uniqueStartList);
590 | } else {
591 | txStartMap.put(chrom, uniqueStartList);
592 | }
593 | if (txEndMap.get(chrom) != null) {
594 | txEndMap.get(chrom).addAll(uniqueEndList);
595 | } else {
596 | txEndMap.put(chrom, uniqueEndList);
597 | }
598 | }
599 |
600 | // Sort Unique List
601 | for (String chr : txStartMap.keySet()) {
602 | Collections.sort(txStartMap.get(chr));
603 | }
604 | for (String chr : txEndMap.keySet()) {
605 | Collections.sort(txEndMap.get(chr));
606 | }
607 | }
608 |
609 | private static void assign(CircRna circRna, TreeMap allGene,
610 | TreeMap> chr2StartList, TreeMap> chr2EndList,
611 | TreeMap> txStart2Name, TreeMap> txEnd2Name) {
612 | String chrom = circRna.getChrom();
613 | Long startPoint = circRna.getStartPoint();
614 | Long endPoint = circRna.getEndPoint();
615 | ArrayList txStartList = chr2StartList.get(chrom);
616 | if (txStartList == null) {
617 | CircView.log.info("circRNA_ID [" + circRna.getCircRnaID() + "] can not find related chrom");
618 | return;
619 | }
620 | ArrayList txEndList = chr2EndList.get(chrom);
621 | if (txEndList == null) {
622 | CircView.log.info("circRNA_ID [" + circRna.getCircRnaID() + "] can not find related chrom");
623 | return;
624 | }
625 | // Binary search to find index of txStart
626 | int indexByTxStart = splitHalfByTxStart(txStartList, startPoint.longValue(), 0, txStartList.size() - 1);
627 | // index boundary control
628 | indexByTxStart = (indexByTxStart < 0) ? 0 : indexByTxStart;
629 | indexByTxStart = (indexByTxStart > txStartList.size() - 1) ? txStartList.size() - 1 : indexByTxStart;
630 | // Binary search to find index of txEnd
631 | int indexByTxEnd = splitHalfByTxEnd(txEndList, endPoint.longValue(), 0, txEndList.size() - 1);
632 | // index boundary control
633 | indexByTxEnd = (indexByTxEnd <= 1) ? 0 : indexByTxEnd;
634 | indexByTxEnd = (indexByTxEnd > txEndList.size() - 1) ? txEndList.size() - 1 : indexByTxEnd;
635 |
636 | TreeMap geneNames = new TreeMap();
637 | // Compare indexByTxStart and indexByTxEnd
638 | if ((indexByTxStart + 1) < (txEndList.size() - indexByTxEnd)) {
639 | // Select indexByTxStart
640 | for (int index = 0; index <= indexByTxStart; index++) {
641 | for (String name : txStart2Name.get(txStartList.get(index)).keySet()) {
642 | geneNames.put(name, 1);
643 | }
644 | }
645 | } else {
646 | // Select indexByTxEnd
647 | for (int index = indexByTxEnd; index < txEndList.size(); index++) {
648 | for (String name : txEnd2Name.get(txEndList.get(index)).keySet()) {
649 | geneNames.put(name, 1);
650 | }
651 | }
652 | }
653 |
654 | // gene location, circRNA type, region
655 | TreeMap geneLocation = new TreeMap();
656 | TreeMap region = new TreeMap();
657 | int exonSign = 0;
658 | for (String name : geneNames.keySet()) {
659 | int geneLocationSign = 0;
660 | int mRnaSign = 0;
661 | int lncRnaSign = 0;
662 | Gene gene = allGene.get(name.toUpperCase());
663 | TreeMap transcripts;
664 | if (gene != null) {
665 | transcripts = gene.getGeneTranscripts();
666 | } else {
667 | return;
668 | }
669 | for (String transcriptName : transcripts.keySet()) {
670 | GeneTranscript trans = transcripts.get(transcriptName);
671 | if ((trans.getTxStart().longValue() <= startPoint.longValue())
672 | && (endPoint.longValue() <= trans.getTxEnd().longValue())) {
673 | geneLocationSign++;
674 | geneLocation.put(name + " " + trans.getTranscriptName(), 1);
675 |
676 | if (trans.getCircRnas().get(circRna.getCircRnaID()) == null) {
677 | trans.getCircRnas().put(circRna.getCircRnaID(), circRna);
678 | }
679 | int repeat = 0;
680 | for (String fileName : circRna.getFiles().keySet()) {
681 | repeat += circRna.getFiles().get(fileName);
682 | }
683 | trans.getCircRnasNum().put(circRna.getCircRnaID(), repeat);
684 | trans.setTotalJunctionReads(trans.getTotalJunctionReads() + circRna.getJunctionReads());
685 | }
686 | if (trans.getCdsStart().longValue() < trans.getCdsEnd().longValue()) {
687 | mRnaSign++;
688 | } else {
689 | lncRnaSign++;
690 | }
691 | for (int i = 0; i < trans.getExonCount(); i++) {
692 | Long exonStart = trans.getExonStarts().get(i);
693 | Long exonEnd = trans.getExonEnds().get(i);
694 | if (((exonStart.longValue() - Constant.ASSIGN_TOLERATION <= startPoint.longValue())
695 | && (startPoint.longValue() < exonEnd.longValue() + Constant.ASSIGN_TOLERATION))
696 | || ((exonStart.longValue() - Constant.ASSIGN_TOLERATION < endPoint.longValue())
697 | && (endPoint.longValue() <= exonEnd.longValue() + Constant.ASSIGN_TOLERATION))
698 | || ((startPoint.longValue() < exonStart.longValue() - Constant.ASSIGN_TOLERATION)
699 | && (exonEnd.longValue() < endPoint.longValue() + Constant.ASSIGN_TOLERATION))) {
700 | exonSign++;
701 | }
702 | }
703 | }
704 | if (geneLocationSign > 0) {
705 | if (mRnaSign > 0) {
706 | region.put("mRNA", 1);
707 | } else {
708 | region.put("lncRNA", 1);
709 | }
710 | }
711 | }
712 |
713 | if (geneLocation.size() > 0) {
714 | for (String n : geneLocation.keySet()) {
715 | circRna.getGeneTranscrpits().put(n, n);
716 | }
717 | if (exonSign > 0) {
718 | circRna.setCircRnaType("exon");
719 | } else {
720 | circRna.setCircRnaType("intron");
721 | }
722 | if ((region.get("mRNA") != null) && (region.get("lncRNA") == null)) {
723 | circRna.setRegion("mRNA");
724 | } else if ((region.get("mRNA") == null) && (region.get("lncRNA") != null)) {
725 | circRna.setRegion("lncRNA");
726 | }
727 | if ((region.get("mRNA") != null) && (region.get("lncRNA") != null)) {
728 | circRna.setRegion("mRNA,lncRNA");
729 | }
730 | } else {
731 | circRna.getGeneTranscrpits().put("n/a", "n/a");
732 | circRna.setCircRnaType("intergenic");
733 | circRna.setRegion("Unknown");
734 | }
735 | }
736 |
737 | private static void assignAll(TreeMap allGene, TreeMap allCircRna) {
738 | TreeMap> chr2StartList = new TreeMap>();
739 | TreeMap> chr2EndList = new TreeMap>();
740 | TreeMap> txStart2Name = new TreeMap>();
741 | TreeMap> txEnd2Name = new TreeMap>();
742 |
743 | if (allGene != null && allCircRna != null) {
744 | preAssign(allGene, chr2StartList, chr2EndList, txStart2Name, txEnd2Name);
745 | }
746 | int num = 0;
747 |
748 | for (String circRnaId : allCircRna.keySet()) {
749 | if (0 == (++num % 1000)) {
750 | CircView.log.info("Mapping: [" + num + "|" + allCircRna.size() + "]");
751 | }
752 | CircRna circRna = allCircRna.get(circRnaId);
753 | assign(circRna, allGene, chr2StartList, chr2EndList, txStart2Name, txEnd2Name);
754 | }
755 | }
756 |
757 | private static int splitHalfByTxStart(ArrayList arrayData, Long txStart, int start, int end) {
758 | int index = (start + end) / 2;
759 | Long data = arrayData.get(index);
760 | if (start > end) {
761 | return end;
762 | }
763 | if (data.longValue() == txStart.longValue()) {
764 | return index;
765 | } else {
766 | if (data.longValue() < txStart.longValue()) {
767 | return splitHalfByTxStart(arrayData, txStart, index + 1, end);
768 | } else {
769 | return splitHalfByTxStart(arrayData, txStart, start, index - 1);
770 | }
771 | }
772 | }
773 |
774 | private static int splitHalfByTxEnd(ArrayList arrayData, Long txEnd, int start, int end) {
775 | int index = (start + end) / 2;
776 | Long data = arrayData.get(index);
777 | if (start > end) {
778 | return start;
779 | }
780 | if (data.longValue() == txEnd.longValue()) {
781 | return index;
782 | } else {
783 | if (data.longValue() < txEnd.longValue()) {
784 | return splitHalfByTxEnd(arrayData, txEnd, index + 1, end);
785 | } else {
786 | return splitHalfByTxEnd(arrayData, txEnd, start, index - 1);
787 | }
788 | }
789 | }
790 | }
791 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/Exon.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu;
2 |
3 | public class Exon {
4 | private long startPoint;
5 | private long endPoint;
6 |
7 | public Exon(long startPoint, long endPoint) {
8 | this.startPoint = startPoint;
9 | this.endPoint = endPoint;
10 | }
11 |
12 | public long getStartPoint() {
13 | return startPoint;
14 | }
15 |
16 | public void setStartPoint(long startPoint) {
17 | this.startPoint = startPoint;
18 | }
19 |
20 | public long getEndPoint() {
21 | return endPoint;
22 | }
23 |
24 | public void setEndPoint(long endPoint) {
25 | this.endPoint = endPoint;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/Gene.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu;
2 |
3 | import java.io.Serializable;
4 | import java.util.TreeMap;
5 | import java.util.Vector;
6 |
7 | /**
8 | * Gene class
9 | *
10 | * @author Gene
11 | *
12 | */
13 | public class Gene implements Serializable{
14 |
15 | private static final long serialVersionUID = 1L;
16 | /**
17 | * gene's name
18 | */
19 | private String geneName;
20 | /**
21 | * gene's transcripts
22 | */
23 | private TreeMap geneTranscripts;
24 | /**
25 | * gene's circRNA samples
26 | */
27 |
28 | private Vector allExons;
29 | /**
30 | * gene's reference
31 | */
32 | private GeneTranscript geneReference;
33 |
34 | /**
35 | * Constructor of Gene
36 | *
37 | * @param geneName
38 | */
39 | public Gene(String geneName) {
40 | this.setGeneName(geneName);
41 | geneTranscripts = new TreeMap();
42 | allExons = new Vector();
43 | geneReference = new GeneTranscript(geneName);
44 | }
45 |
46 | /**
47 | * get Gene's name
48 | *
49 | * @return geneName
50 | */
51 | public String getGeneName() {
52 | return geneName;
53 | }
54 |
55 | /**
56 | * set Gene's name
57 | *
58 | * @param geneName
59 | */
60 | public void setGeneName(String geneName) {
61 | this.geneName = geneName;
62 | }
63 |
64 | /**
65 | * get gene's transcripts
66 | *
67 | * @return geneTranscripts
68 | */
69 | public TreeMap getGeneTranscripts() {
70 | return geneTranscripts;
71 | }
72 |
73 | /**
74 | * set gene's transcripts
75 | *
76 | * @param geneTranscripts
77 | */
78 | public void setGeneTranscripts(TreeMap geneTranscripts) {
79 | this.geneTranscripts = geneTranscripts;
80 | }
81 |
82 | /**
83 | * get all exons
84 | *
85 | * @return allExons
86 | */
87 | public Vector getAllExons() {
88 | return allExons;
89 | }
90 |
91 | /**
92 | * set all exons
93 | *
94 | * @param allExons
95 | */
96 | public void setAllExons(Vector allExons) {
97 | this.allExons = allExons;
98 | }
99 |
100 | /**
101 | * get gene's reference
102 | *
103 | * @return geneReference
104 | */
105 | public GeneTranscript getGeneReference() {
106 | return geneReference;
107 | }
108 |
109 | /**
110 | * set gene's reference
111 | *
112 | * @param geneReference
113 | */
114 | public void setGeneReference(GeneTranscript geneReference) {
115 | this.geneReference = geneReference;
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/GeneTranscript.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu;
2 |
3 | import java.io.ByteArrayInputStream;
4 | import java.io.ByteArrayOutputStream;
5 | import java.io.IOException;
6 | import java.io.ObjectInputStream;
7 | import java.io.ObjectOutputStream;
8 | import java.io.Serializable;
9 | import java.util.TreeMap;
10 | import java.util.Vector;
11 |
12 | /**
13 | * GeneTranscript
14 | *
15 | * @author Gene deal refFlat format file
16 | */
17 | public class GeneTranscript implements Serializable {
18 |
19 | private static final long serialVersionUID = 1L;
20 | /**
21 | * Name of gene as it appears in Genome Browser
22 | */
23 | private String geneName;
24 | /**
25 | * Name of gene
26 | */
27 | private String transcriptName;
28 | /**
29 | * Chromosome name
30 | */
31 | private String chrom;
32 | /**
33 | * + or - for strand
34 | */
35 | private String strand;
36 | /**
37 | * Transcription start position
38 | */
39 | private Long txStart;
40 | /**
41 | * Transcription end position
42 | */
43 | private Long txEnd;
44 | /**
45 | * Coding region start
46 | */
47 | private Long cdsStart;
48 | /**
49 | * Coding region end
50 | */
51 | private Long cdsEnd;
52 | /**
53 | * Number of exons
54 | */
55 | private Integer exonCount;
56 | /**
57 | * Exon start postions
58 | */
59 | private Vector exonStarts;
60 | /**
61 | * Exon end positons
62 | */
63 | private Vector exonEnds;
64 |
65 | private TreeMap circRnas;
66 | private TreeMap circRnasNum;
67 | private int totalJunctionReads;
68 |
69 | /**
70 | * Constructor of class GeneTranscript
71 | *
72 | * @param geneName
73 | */
74 | public GeneTranscript(String geneName) {
75 | this.setGeneName(geneName);
76 | exonStarts = new Vector();
77 | exonEnds = new Vector();
78 | setCircRnas(new TreeMap());
79 | setCircRnasNum(new TreeMap());
80 | setTotalJunctionReads(0);
81 | }
82 |
83 | /**
84 | * get gene name
85 | *
86 | * @return geneName
87 | */
88 | public String getGeneName() {
89 | return geneName;
90 | }
91 |
92 | /**
93 | * set gene name
94 | *
95 | * @param geneName
96 | */
97 | public void setGeneName(String geneName) {
98 | this.geneName = geneName;
99 | }
100 |
101 | /**
102 | * get transcript name
103 | *
104 | * @return transcriptName
105 | */
106 | public String getTranscriptName() {
107 | return transcriptName;
108 | }
109 |
110 | /**
111 | * set transcript name
112 | *
113 | * @param transcriptName
114 | */
115 | public void setTranscriptName(String transcriptName) {
116 | this.transcriptName = transcriptName;
117 | }
118 |
119 | /**
120 | * get chrom
121 | *
122 | * @return chrom
123 | */
124 | public String getChrom() {
125 | return chrom;
126 | }
127 |
128 | /**
129 | * set chrom
130 | *
131 | * @param chrom
132 | */
133 | public void setChrom(String chrom) {
134 | this.chrom = chrom;
135 | }
136 |
137 | /**
138 | * get strand
139 | *
140 | * @return strand
141 | */
142 | public String getStrand() {
143 | return strand;
144 | }
145 |
146 | /**
147 | * set strand
148 | *
149 | * @param strand
150 | */
151 | public void setStrand(String strand) {
152 | this.strand = strand;
153 | }
154 |
155 | /**
156 | * get Tx start
157 | *
158 | * @return txStart
159 | */
160 | public Long getTxStart() {
161 | return txStart;
162 | }
163 |
164 | /**
165 | * set Tx start
166 | *
167 | * @param txStart
168 | */
169 | public void setTxStart(Long txStart) {
170 | this.txStart = txStart;
171 | }
172 |
173 | /**
174 | * get Tx end
175 | *
176 | * @return txEnd
177 | */
178 | public Long getTxEnd() {
179 | return txEnd;
180 | }
181 |
182 | /**
183 | * set Tx end
184 | *
185 | * @param txEnd
186 | */
187 | public void setTxEnd(Long txEnd) {
188 | this.txEnd = txEnd;
189 | }
190 |
191 | /**
192 | * get CDS start
193 | *
194 | * @return cdsStart
195 | */
196 | public Long getCdsStart() {
197 | return cdsStart;
198 | }
199 |
200 | /**
201 | * set CDS start
202 | *
203 | * @param cdsStart
204 | */
205 | public void setCdsStart(Long cdsStart) {
206 | this.cdsStart = cdsStart;
207 | }
208 |
209 | /**
210 | * get CDS end
211 | *
212 | * @return cdsEnd
213 | */
214 | public Long getCdsEnd() {
215 | return cdsEnd;
216 | }
217 |
218 | /**
219 | * set CDS end
220 | *
221 | * @param cdsEnd
222 | */
223 | public void setCdsEnd(Long cdsEnd) {
224 | this.cdsEnd = cdsEnd;
225 | }
226 |
227 | /**
228 | * get exon count
229 | *
230 | * @return exonCount
231 | */
232 | public Integer getExonCount() {
233 | return exonCount;
234 | }
235 |
236 | /**
237 | * set exon count
238 | *
239 | * @param exonCount
240 | */
241 | public void setExonCount(Integer exonCount) {
242 | this.exonCount = exonCount;
243 | }
244 |
245 | /**
246 | * get exon starts
247 | *
248 | * @return exonStarts
249 | */
250 | public Vector getExonStarts() {
251 | return exonStarts;
252 | }
253 |
254 | /**
255 | * set exon starts
256 | *
257 | * @param exonStarts
258 | */
259 | public void setExonStarts(Vector exonStarts) {
260 | this.exonStarts = exonStarts;
261 | }
262 |
263 | /**
264 | * get exon ends
265 | *
266 | * @return exonEnds
267 | */
268 | public Vector getExonEnds() {
269 | return exonEnds;
270 | }
271 |
272 | /**
273 | * set exon ends
274 | *
275 | * @param exonEnds
276 | */
277 | public void setExonEnds(Vector exonEnds) {
278 | this.exonEnds = exonEnds;
279 | }
280 |
281 | /**
282 | * @return the circRnaNum
283 | */
284 | public TreeMap getCircRnasNum() {
285 | return circRnasNum;
286 | }
287 |
288 | /**
289 | * @param circRnaNum
290 | * the circRnaNum to set
291 | */
292 | public void setCircRnasNum(TreeMap circRnasNum) {
293 | this.circRnasNum = circRnasNum;
294 | }
295 |
296 | /**
297 | * @return the totalJunctionReads
298 | */
299 | public int getTotalJunctionReads() {
300 | return totalJunctionReads;
301 | }
302 |
303 | /**
304 | * @param totalJunctionReads the totalJunctionReads to set
305 | */
306 | public void setTotalJunctionReads(int totalJunctionReads) {
307 | this.totalJunctionReads = totalJunctionReads;
308 | }
309 |
310 | /**
311 | * @return the circRnas
312 | */
313 | public TreeMap getCircRnas() {
314 | return circRnas;
315 | }
316 |
317 | /**
318 | * @param circRnas
319 | * the circRnas to set
320 | */
321 | public void setCircRnas(TreeMap circRnas) {
322 | this.circRnas = circRnas;
323 | }
324 |
325 | public GeneTranscript deepClone() {
326 | ByteArrayOutputStream byteOut = null;
327 | ObjectOutputStream objOut = null;
328 | ByteArrayInputStream byteIn = null;
329 | ObjectInputStream objIn = null;
330 |
331 | try {
332 | byteOut = new ByteArrayOutputStream();
333 | objOut = new ObjectOutputStream(byteOut);
334 | objOut.writeObject(this);
335 |
336 | byteIn = new ByteArrayInputStream(byteOut.toByteArray());
337 | objIn = new ObjectInputStream(byteIn);
338 |
339 | return (GeneTranscript) objIn.readObject();
340 | } catch (IOException e) {
341 | throw new RuntimeException("Clone Object failed in IO.", e);
342 | } catch (ClassNotFoundException e) {
343 | throw new RuntimeException("Class not found.", e);
344 | } finally {
345 | try {
346 | byteIn = null;
347 | byteOut = null;
348 | if (objOut != null)
349 | objOut.close();
350 | if (objIn != null)
351 | objIn.close();
352 | } catch (IOException e) {
353 | }
354 | }
355 | }
356 |
357 | }
358 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/MainData.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.io.OutputStream;
9 | import java.util.Properties;
10 | import java.util.TreeMap;
11 | import java.util.Vector;
12 |
13 | import cn.edu.whu.util.Constant;
14 | import cn.edu.whu.util.DbConfig;
15 |
16 | public class MainData {
17 | private static TreeMap speciesFile; // SpeciesName - Species
18 | // Data File Path
19 | private static TreeMap> speciesData; // SpeciesName
20 | // -
21 | // Loaded
22 | // Species
23 | // Data
24 | private static Vector speciesNames; // Tool Names
25 | private static Vector circRnaToolNames; // Tool Names
26 | private static Vector> circRnaFilesInfo;
27 | private static Properties properties;
28 | private static DbConfig dbConfig;
29 |
30 | public MainData() {
31 | speciesFile = new TreeMap();
32 | speciesData = new TreeMap>();
33 | speciesNames = new Vector();
34 | circRnaToolNames = new Vector();
35 | circRnaFilesInfo = new Vector>();
36 | properties = new Properties();
37 | dbConfig = new DbConfig();
38 | configure();
39 | }
40 |
41 | private void configure() {
42 | File file = new File(Constant.CONFIG_FILE);
43 | if (file.exists()) {
44 | readDbConfig();
45 | } else {
46 | initDbConfig();
47 | writeDbConfig();
48 | }
49 | initSpeciesFile();
50 | initTools();
51 | }
52 |
53 | private void initSpeciesFile() {
54 | // Init Default Species Config
55 | for (String speciesName : Constant.SPECIES) {
56 | File file = new File(Constant.SPECIES_FILE.get(speciesName));
57 | if (file.exists()) {
58 | speciesNames.add(speciesName);
59 | speciesFile.put(speciesName, Constant.SPECIES_FILE.get(speciesName));
60 | } else {
61 | CircView.log.info("Can not find annotation file " + file.getName());
62 | }
63 | }
64 | }
65 |
66 | private void initTools() {
67 | // Init Default CircRNA Tools Config
68 | for (String circRnaToolName : Constant.CIRCRNA_TOOLS) {
69 | circRnaToolNames.add(circRnaToolName);
70 | }
71 | }
72 |
73 | private void initDbConfig() {
74 | CircView.log.info("Init Default Config");
75 | // Init Default Database Config
76 | dbConfig.setDbServer(Constant.DEFAULT_DB_SERVER);
77 | dbConfig.setDbPort(Constant.DEFAULT_DB_PORT);
78 | dbConfig.setDbUser(Constant.DEFAULT_DB_USER);
79 | dbConfig.setDbPasswd(Constant.DEFAULT_DB_PASSWD);
80 | dbConfig.setDbName(Constant.DEFAULT_DB_NAME);
81 | }
82 |
83 | public static void readDbConfig() {
84 | // Read Configure File
85 | CircView.log.info(Constant.CONFIG_FILE + " is loaded");
86 | try {
87 | InputStream in = new FileInputStream(Constant.CONFIG_FILE);
88 | properties.load(in);
89 | dbConfig.setDbServer(properties.getProperty(Constant.CONFIG_DB_SERVER));
90 | dbConfig.setDbPort(properties.getProperty(Constant.CONFIG_DB_PORT));
91 | dbConfig.setDbUser(properties.getProperty(Constant.CONFIG_DB_USER));
92 | dbConfig.setDbPasswd(properties.getProperty(Constant.CONFIG_DB_PASSWD));
93 | dbConfig.setDbName(properties.getProperty(Constant.CONFIG_DB_NAME));
94 | } catch (IOException e) {
95 | CircView.log.info(e.getMessage());
96 | }
97 | }
98 |
99 | public static void writeDbConfig() {
100 | try {
101 | properties.setProperty(Constant.CONFIG_DB_SERVER, Constant.DEFAULT_DB_SERVER);
102 | properties.setProperty(Constant.CONFIG_DB_PORT, Constant.DEFAULT_DB_PORT);
103 | properties.setProperty(Constant.CONFIG_DB_USER, Constant.DEFAULT_DB_USER);
104 | properties.setProperty(Constant.CONFIG_DB_PASSWD, Constant.DEFAULT_DB_PASSWD);
105 | properties.setProperty(Constant.CONFIG_DB_NAME, Constant.DEFAULT_DB_NAME);
106 | // Write Config File
107 | OutputStream os = new FileOutputStream(Constant.CONFIG_FILE);
108 | properties.store(os, "Save Config File");
109 | } catch (IOException e) {
110 | CircView.log.error(e.getMessage());
111 | }
112 | }
113 |
114 | public static TreeMap> getSpeciesData() {
115 | return speciesData;
116 | }
117 |
118 | public static void setSpeciesData(TreeMap> speciesData) {
119 | MainData.speciesData = speciesData;
120 | }
121 |
122 | public static TreeMap getSpeciesFile() {
123 | return speciesFile;
124 | }
125 |
126 | public static void setSpeciesFile(TreeMap speciesFile) {
127 | MainData.speciesFile = speciesFile;
128 | }
129 |
130 | public static Vector getSpeciesNames() {
131 | return speciesNames;
132 | }
133 |
134 | public static void setSpeciesNames(Vector speciesNames) {
135 | MainData.speciesNames = speciesNames;
136 | }
137 |
138 | public static Vector getCircRnaToolNames() {
139 | return circRnaToolNames;
140 | }
141 |
142 | public static void setCircRnaToolNames(Vector circRnaToolNames) {
143 | MainData.circRnaToolNames = circRnaToolNames;
144 | }
145 |
146 | public static Vector> getCircRnaFilesInfo() {
147 | return circRnaFilesInfo;
148 | }
149 |
150 | public static void setCircRnaFilesInfo(Vector> circRnaFilesInfo) {
151 | MainData.circRnaFilesInfo = circRnaFilesInfo;
152 | }
153 |
154 | public static Properties getProperties() {
155 | return properties;
156 | }
157 |
158 | public static void setProperties(Properties properties) {
159 | MainData.properties = properties;
160 | }
161 |
162 | public static DbConfig getDbConfig() {
163 | return dbConfig;
164 | }
165 |
166 | public static void setDbConfig(DbConfig dbConfig) {
167 | MainData.dbConfig = dbConfig;
168 | }
169 |
170 | }
171 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/exception/FileReadException.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.exception;
2 |
3 | public class FileReadException extends Exception {
4 |
5 | private static final long serialVersionUID = 1L;
6 |
7 | public FileReadException(String message) {
8 | super(message);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/AboutDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.Rectangle;
5 | import java.awt.event.ActionEvent;
6 | import java.awt.event.ActionListener;
7 |
8 | import javax.swing.Box;
9 | import javax.swing.JButton;
10 | import javax.swing.JDialog;
11 | import javax.swing.JLabel;
12 | import javax.swing.JPanel;
13 | import cn.edu.whu.CircView;
14 | import cn.edu.whu.util.Constant;
15 |
16 | public class AboutDialog extends JDialog {
17 |
18 | private static final long serialVersionUID = 1L;
19 |
20 | public AboutDialog() {
21 | super(CircView.frame);
22 | initUi();
23 | setTitle("About CircView");
24 | // setResizable(false);
25 | setSize(250, 150);
26 | centerScreen();
27 | }
28 |
29 | private void centerScreen() {
30 | Dimension dim = getToolkit().getScreenSize();
31 | Rectangle abounds = getBounds();
32 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
33 | super.setVisible(true);
34 | requestFocus();
35 | }
36 |
37 | private void initUi() {
38 | Box b = Box.createVerticalBox();
39 | b.add(Box.createGlue());
40 | b.add(new JLabel(Constant.ABOUT));
41 | b.add(new JLabel(Constant.VERSION));
42 | b.add(new JLabel(Constant.AUTHOR));
43 | b.add(Box.createGlue());
44 | getContentPane().add(b, "Center");
45 |
46 | JPanel p = new JPanel();
47 | JButton btClose = new JButton("Close");
48 | p.add(btClose);
49 | getContentPane().add(p, "South");
50 |
51 | btClose.addActionListener(new ActionListener() {
52 | public void actionPerformed(ActionEvent e) {
53 | AboutDialog.this.dispose();
54 | }
55 | });
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/CircRnaDataClearDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import java.util.Vector;
9 |
10 | import javax.swing.JButton;
11 | import javax.swing.JComboBox;
12 | import javax.swing.JDialog;
13 | import cn.edu.whu.MainData;
14 | import cn.edu.whu.CircView;
15 |
16 | public class CircRnaDataClearDialog extends JDialog {
17 |
18 | private static final long serialVersionUID = 1L;
19 |
20 | public CircRnaDataClearDialog() {
21 | super(CircView.frame);
22 | initUi();
23 | setTitle("Clear CircRNA Data for:");
24 | setResizable(false);
25 | setSize(300, 65);
26 | this.setLayout(new FlowLayout());
27 | centerScreen();
28 | }
29 |
30 | private void centerScreen() {
31 | Dimension dim = getToolkit().getScreenSize();
32 | Rectangle abounds = getBounds();
33 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
34 | super.setVisible(true);
35 | requestFocus();
36 | }
37 |
38 | private void initUi() {
39 | // ComboBox
40 | final JComboBox cbSpecies = new JComboBox();
41 | final JButton btClear = new JButton("Clear");
42 |
43 | cbSpecies.setPreferredSize(new Dimension(160, 28));
44 | for (String speciesName : MainData.getSpeciesData().keySet()) {
45 | cbSpecies.addItem(speciesName);
46 | }
47 |
48 | getContentPane().add(cbSpecies);
49 | getContentPane().add(btClear);
50 |
51 | // Button
52 | btClear.addActionListener(new ActionListener() {
53 | public void actionPerformed(ActionEvent e) {
54 | if (null == cbSpecies.getSelectedItem()) {
55 | return;
56 | }
57 | String delSpecies = cbSpecies.getSelectedItem().toString();
58 | // Delete Species Data
59 | if (null != MainData.getSpeciesData().get(delSpecies)) {
60 | MainData.getSpeciesData().remove(delSpecies);
61 | }
62 | CircView.log.error("CircRNA Data for " + delSpecies + " is CLEARED");
63 | // Delete CircRNA File Info for this Species
64 | for (int i = MainData.getCircRnaFilesInfo().size() - 1; i >= 0; i--) {
65 | Vector rowData = MainData.getCircRnaFilesInfo().get(i);
66 | String sname = rowData.get(0);
67 | if (delSpecies.equalsIgnoreCase(sname)) {
68 | MainData.getCircRnaFilesInfo().remove(i);
69 | }
70 | }
71 | CircView.log.error("CircRNA files for " + delSpecies + " is DELETED");
72 |
73 | CircView.updateSpeciesCombo();
74 | CircView.updateCircRnaToolsCombo();
75 | CircView.updateSamplesCombo();
76 | CircView.updateCbChrom();
77 | CircView.updateGeneTransList();
78 | CircRnaDataClearDialog.this.dispose();
79 | }
80 |
81 | });
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/CircRnaDataLoadDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Dimension;
5 | import java.awt.FlowLayout;
6 | import java.awt.Rectangle;
7 | import java.awt.event.ActionEvent;
8 | import java.awt.event.ActionListener;
9 | import java.io.File;
10 | import java.util.TreeMap;
11 | import java.util.Vector;
12 |
13 | import javax.swing.JButton;
14 | import javax.swing.JComboBox;
15 | import javax.swing.JDialog;
16 | import javax.swing.JFileChooser;
17 | import javax.swing.JOptionPane;
18 | import javax.swing.JPanel;
19 | import javax.swing.JScrollPane;
20 | import javax.swing.JTable;
21 | import javax.swing.table.DefaultTableModel;
22 |
23 | import cn.edu.whu.CircRnaTool;
24 | import cn.edu.whu.CircView;
25 | import cn.edu.whu.Gene;
26 | import cn.edu.whu.MainData;
27 | import cn.edu.whu.exception.FileReadException;
28 |
29 | public class CircRnaDataLoadDialog extends JDialog {
30 | private static final long serialVersionUID = 1L;
31 |
32 | private JTable table;
33 | private Vector> tableData;
34 | private JComboBox cbSpecies;
35 | private JComboBox cbCircRnaTool;
36 |
37 | public CircRnaDataLoadDialog() {
38 | super(CircView.frame);
39 | setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
40 | setLayout(new BorderLayout());
41 | initUi();
42 | setTitle("Load CircRNA files");
43 | setResizable(false);
44 | setSize(600, 400);
45 | centerScreen();
46 | }
47 |
48 | private void centerScreen() {
49 | Dimension dim = getToolkit().getScreenSize();
50 | Rectangle abounds = getBounds();
51 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
52 | super.setVisible(true);
53 | requestFocus();
54 | }
55 |
56 | private void initUi() {
57 | // North
58 | JPanel jpNorth = new JPanel(new FlowLayout());
59 | cbSpecies = new JComboBox();
60 | cbCircRnaTool = new JComboBox();
61 | JButton btAdd = new JButton("Add Files");
62 | cbSpecies.setPreferredSize(new Dimension(200, 28));
63 | cbCircRnaTool.setPreferredSize(new Dimension(200, 28));
64 | jpNorth.add(cbSpecies);
65 | jpNorth.add(cbCircRnaTool);
66 | jpNorth.add(btAdd);
67 | getContentPane().add(jpNorth, BorderLayout.NORTH);
68 |
69 | for (String speciesName : MainData.getSpeciesNames()) {
70 | cbSpecies.addItem(speciesName);
71 | }
72 | for (String circRnaToolName : MainData.getCircRnaToolNames()) {
73 | cbCircRnaTool.addItem(circRnaToolName);
74 | }
75 |
76 | // Center
77 | final Vector colName = new Vector();
78 | colName.addElement("Species");
79 | colName.addElement("CircRNA Tool");
80 | colName.addElement("File Name");
81 | colName.addElement("File Path");
82 | tableData = new Vector>();
83 | final DefaultTableModel model = new DefaultTableModel();
84 | table = new JTable(model);
85 | model.setDataVector(tableData, colName);
86 | JScrollPane jsPane = new JScrollPane(table);
87 | getContentPane().add(jsPane, BorderLayout.CENTER);
88 |
89 | // South
90 | JPanel jpSouth = new JPanel(new FlowLayout());
91 | JButton btOpen = new JButton("Open");
92 | JButton btClear = new JButton("Clear");
93 | jpSouth.add(btOpen);
94 | jpSouth.add(btClear);
95 | getContentPane().add(jpSouth, BorderLayout.SOUTH);
96 |
97 | btAdd.addActionListener(new ActionListener() {
98 | public void actionPerformed(ActionEvent e) {
99 | if(null == cbSpecies.getSelectedItem()) {
100 | JOptionPane.showMessageDialog(CircView.frame, "Species Name is needed");
101 | return;
102 | }
103 | if(null == cbCircRnaTool.getSelectedItem()) {
104 | JOptionPane.showMessageDialog(CircView.frame, "Tool Name is needed");
105 | return;
106 | }
107 | String speciesName = cbSpecies.getSelectedItem().toString();
108 | String circRnaToolName = cbCircRnaTool.getSelectedItem().toString();
109 | String pattern = "\\s+";
110 | if (speciesName.matches(pattern)) {
111 | JOptionPane.showMessageDialog(CircView.frame, "Species Name is needed");
112 | return;
113 | }
114 | if (circRnaToolName.matches(pattern)) {
115 | JOptionPane.showMessageDialog(CircView.frame, "Tool Name is needed");
116 | return;
117 | }
118 |
119 | OpenFileChooser openFile = new OpenFileChooser("Open CircRNA Files");
120 | openFile.setMultiSelectionEnabled(true);
121 | openFile.setFileSelectionMode(JFileChooser.FILES_ONLY);
122 | openFile.setFileHidingEnabled(true);
123 | int returnValue = openFile.showOpenDialog(null);
124 | if (returnValue == JFileChooser.APPROVE_OPTION) {
125 | File[] files = null;
126 | files = openFile.getSelectedFiles();
127 | for (File file : files) {
128 | Vector rowData = new Vector();
129 | rowData.addElement(speciesName);
130 | rowData.addElement(circRnaToolName);
131 | rowData.addElement(file.getName());
132 | rowData.addElement(file.getPath());
133 | tableData.addElement(rowData);
134 | model.setDataVector(tableData, colName);
135 | }
136 | }
137 | }
138 | });
139 |
140 | btClear.addActionListener(new ActionListener() {
141 | public void actionPerformed(ActionEvent e) {
142 | tableData.removeAllElements();
143 | model.setDataVector(tableData, colName);
144 | }
145 | });
146 |
147 | btOpen.addActionListener(new ActionListener() {
148 | public void actionPerformed(ActionEvent e) {
149 | DataLoadingDialog dataLoadingDialog = new DataLoadingDialog(CircView.frame, "Loading CircRNA Data ...");
150 | setVisible(false);
151 | TreeMap uniqSpecies = new TreeMap();
152 | for (Vector rowData : tableData) {
153 | String speciesName = rowData.get(0);
154 | uniqSpecies.put(speciesName, speciesName);
155 | }
156 | boolean hasSpecies = true;
157 | for (String speciesName : uniqSpecies.keySet()) {
158 | if (null == MainData.getSpeciesData().get(speciesName)) {
159 | // Load Species Data
160 | TreeMap genes = new TreeMap();
161 | File speciesFile = new File(MainData.getSpeciesFile().get(speciesName));
162 | if (CircRnaTool.initSpeciesDataFromFile(speciesFile, genes)) {
163 | MainData.getSpeciesData().put(speciesName, genes);
164 | CircView.log.info(speciesName + " Data Loaded");
165 | } else {
166 | hasSpecies = false;
167 | JOptionPane.showMessageDialog(CircView.frame,
168 | "[" + speciesFile.getPath() + "] does NOT EXIST or file FORMAT ERROR!");
169 | CircView.log.error("[" + speciesFile.getPath() + "] does NOT EXIST or file FORMAT ERROR!");
170 | dataLoadingDialog.setVisible(false);
171 | CircRnaDataLoadDialog.this.dispose();
172 | }
173 | }
174 | }
175 | if (hasSpecies) {
176 | for (String speciesName : uniqSpecies.keySet()) {
177 | TreeMap genes = MainData.getSpeciesData().get(speciesName);
178 | try {
179 | // Load CircRNA Data
180 | CircRnaTool.initCircRnaDataFromFiles(tableData, speciesName, genes);
181 | // Save CircRNA File Info
182 | for (Vector rowData : tableData) {
183 | String sname = rowData.get(0);
184 | if (sname.equalsIgnoreCase(speciesName)) {
185 | MainData.getCircRnaFilesInfo().add(rowData);
186 | }
187 | }
188 | // Update UI
189 | CircView.updateSpeciesCombo();
190 | CircView.updateCircRnaToolsCombo();
191 | CircView.updateSamplesCombo();
192 | CircView.updateCbChrom();
193 | CircView.updateGeneTransList();
194 | } catch (FileReadException e1) {
195 | JOptionPane.showMessageDialog(CircView.frame, e1.getMessage());
196 | CircView.log.error(e1.getMessage());
197 | dataLoadingDialog.setVisible(false);
198 | CircRnaDataLoadDialog.this.dispose();
199 | }
200 |
201 | }
202 | }
203 | dataLoadingDialog.setVisible(false);
204 | CircRnaDataLoadDialog.this.dispose();
205 | }
206 | });
207 | }
208 | }
209 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/CircRnaToolAddDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import javax.swing.JButton;
9 | import javax.swing.JComboBox;
10 | import javax.swing.JDialog;
11 | import javax.swing.JLabel;
12 | import javax.swing.JOptionPane;
13 | import javax.swing.JTextField;
14 |
15 | import com.mysql.jdbc.StringUtils;
16 |
17 | import cn.edu.whu.MainData;
18 | import cn.edu.whu.CircView;
19 |
20 | public class CircRnaToolAddDialog extends JDialog {
21 |
22 | private static final long serialVersionUID = 1L;
23 |
24 | public CircRnaToolAddDialog() {
25 | super(CircView.frame);
26 | initUi();
27 | setTitle("Add CircRNA Tools Name");
28 | setResizable(false);
29 | setSize(400, 65);
30 | this.setLayout(new FlowLayout());
31 | centerScreen();
32 | }
33 |
34 | private void centerScreen() {
35 | Dimension dim = getToolkit().getScreenSize();
36 | Rectangle abounds = getBounds();
37 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
38 | super.setVisible(true);
39 | requestFocus();
40 | }
41 |
42 | private void initUi() {
43 | // ComboBox
44 | final JTextField tfTools = new JTextField();
45 | final JLabel lbAdd = new JLabel("->");
46 | final JComboBox cbTools = new JComboBox();
47 | final JButton btAdd = new JButton("Add");
48 |
49 | cbTools.setPreferredSize(new Dimension(150, 28));
50 | for (String toolName : MainData.getCircRnaToolNames()) {
51 | cbTools.addItem(toolName);
52 | }
53 | tfTools.setPreferredSize(new Dimension(120, 28));
54 |
55 | getContentPane().add(tfTools);
56 | getContentPane().add(lbAdd);
57 | getContentPane().add(cbTools);
58 | getContentPane().add(btAdd);
59 |
60 | // Button
61 | btAdd.addActionListener(new ActionListener() {
62 | public void actionPerformed(ActionEvent e) {
63 | String newTool = tfTools.getText();
64 | if (StringUtils.isEmptyOrWhitespaceOnly(newTool)) {
65 | JOptionPane.showMessageDialog(CircRnaToolAddDialog.this, "CircRNA Tool Name is Needed", "warning",
66 | JOptionPane.ERROR_MESSAGE);
67 | return;
68 | }
69 | boolean existed = false;
70 | for (String oldTool : MainData.getCircRnaToolNames()) {
71 | if (newTool.equals(oldTool)) {
72 | existed = true;
73 | }
74 | }
75 | if (existed) {
76 | // Species Name already exists
77 | JOptionPane.showMessageDialog(CircRnaToolAddDialog.this, "CircRNA Tools already exsits", "warning",
78 | JOptionPane.ERROR_MESSAGE);
79 | } else {
80 | MainData.getCircRnaToolNames().add(newTool);
81 | cbTools.addItem(newTool);
82 | tfTools.setText("");
83 | MainData.writeDbConfig();
84 | CircView.log.info("New CircRnaTool [" + newTool + "] Added.");
85 | }
86 | }
87 | });
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/CircRnaToolDelDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import javax.swing.JButton;
9 | import javax.swing.JComboBox;
10 | import javax.swing.JDialog;
11 | import cn.edu.whu.MainData;
12 | import cn.edu.whu.CircView;
13 |
14 | public class CircRnaToolDelDialog extends JDialog {
15 |
16 | private static final long serialVersionUID = 1L;
17 |
18 | public CircRnaToolDelDialog() {
19 | super();
20 | initUi();
21 | setTitle("Del CircRNA Tools Name");
22 | setResizable(false);
23 | setSize(300, 65);
24 | this.setLayout(new FlowLayout());
25 | centerScreen();
26 | }
27 |
28 | private void centerScreen() {
29 | Dimension dim = getToolkit().getScreenSize();
30 | Rectangle abounds = getBounds();
31 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
32 | super.setVisible(true);
33 | requestFocus();
34 | }
35 |
36 | private void initUi() {
37 | // ComboBox
38 | final JComboBox cbTools = new JComboBox();
39 | final JButton btDel = new JButton("Delete");
40 |
41 | cbTools.setPreferredSize(new Dimension(150, 28));
42 | for (String toolName : MainData.getCircRnaToolNames()) {
43 | cbTools.addItem(toolName);
44 | }
45 | getContentPane().add(cbTools);
46 | getContentPane().add(btDel);
47 |
48 | // Button
49 | btDel.addActionListener(new ActionListener() {
50 | public void actionPerformed(ActionEvent e) {
51 | if (null != cbTools.getSelectedItem()) {
52 | String delTool = cbTools.getSelectedItem().toString();
53 | int index = cbTools.getSelectedIndex();
54 | cbTools.removeItemAt(index);
55 | MainData.getCircRnaToolNames().remove(delTool);
56 | MainData.writeDbConfig();
57 | CircView.log.info("CircRna Tool [" + delTool + "] Deleted.");
58 | CircRnaToolDelDialog.this.dispose();
59 | }
60 | }
61 | });
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/ComparisonFrame.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Dimension;
5 | import java.awt.Rectangle;
6 | import java.awt.Toolkit;
7 | import java.awt.event.ActionEvent;
8 | import java.awt.event.ActionListener;
9 | import java.awt.event.ItemEvent;
10 | import java.awt.event.ItemListener;
11 | import java.awt.event.MouseAdapter;
12 | import java.awt.event.MouseEvent;
13 | import java.awt.event.MouseListener;
14 | import java.io.BufferedWriter;
15 | import java.io.File;
16 | import java.io.FileWriter;
17 | import java.io.IOException;
18 | import java.util.TreeMap;
19 | import java.util.Vector;
20 |
21 | import javax.swing.BoxLayout;
22 | import javax.swing.JButton;
23 | import javax.swing.JComboBox;
24 | import javax.swing.JDialog;
25 | import javax.swing.JFileChooser;
26 | import javax.swing.JFrame;
27 | import javax.swing.JLabel;
28 | import javax.swing.JList;
29 | import javax.swing.JOptionPane;
30 | import javax.swing.JPanel;
31 | import javax.swing.JScrollPane;
32 | import javax.swing.JTable;
33 | import javax.swing.ListSelectionModel;
34 | import javax.swing.table.DefaultTableModel;
35 |
36 | import cn.edu.whu.CircRna;
37 | import cn.edu.whu.CircView;
38 | import cn.edu.whu.Gene;
39 | import cn.edu.whu.GeneTranscript;
40 | import cn.edu.whu.MainData;
41 | import cn.edu.whu.util.Constant;
42 | import cn.edu.whu.util.EvenOddRenderer;
43 |
44 | public class ComparisonFrame extends JFrame {
45 | private static final long serialVersionUID = 1L;
46 | private JComboBox cbSpecies;
47 | private JComboBox cbTolerate;
48 | private JList jlUnSelected;
49 | private JList jlSelected;
50 | private Vector unSelected;
51 | private Vector selected;
52 | private JScrollPane scrollUnSelected;
53 | private JScrollPane scrollSelected;
54 | private DefaultTableModel model;
55 | private JTable tbResult;
56 | private Vector colName;
57 | private Vector> tableData;
58 | Dimension screenSize;
59 |
60 | public ComparisonFrame() {
61 | super();
62 | setExtendedState(JFrame.MAXIMIZED_BOTH);
63 | setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
64 | setLayout(new BorderLayout());
65 | setResizable(true);
66 | setTitle("Comparison Setting");
67 |
68 | screenSize = Toolkit.getDefaultToolkit().getScreenSize();
69 | setBounds(0, 100, (int) screenSize.getWidth(), (int) screenSize.getHeight() - 100);
70 | centerScreen();
71 | initUi();
72 | }
73 |
74 | private void centerScreen() {
75 | Dimension dim = getToolkit().getScreenSize();
76 | Rectangle abounds = getBounds();
77 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
78 | super.setVisible(true);
79 | requestFocus();
80 | }
81 |
82 | private void initUi() {
83 | JPanel northPanel = new JPanel();
84 | northPanel.setLayout(new BorderLayout());
85 | JPanel jpWest = new JPanel();
86 | jpWest.setLayout(new BoxLayout(jpWest, BoxLayout.Y_AXIS));
87 | cbSpecies = new JComboBox();
88 | cbSpecies.setPreferredSize(new Dimension(200, 28));
89 | JPanel jpTmp = new JPanel();
90 | JLabel lbTolerate = new JLabel("Compare Overlap");
91 | cbTolerate = new JComboBox();
92 | cbTolerate.setPreferredSize(new Dimension(80, 28));
93 | // cbTolerate.setEditable(true);
94 | JLabel lbBp = new JLabel("bp");
95 | jpTmp.add(lbTolerate);
96 | jpTmp.add(cbTolerate);
97 | jpTmp.add(lbBp);
98 | jpWest.add(new JLabel(" "));
99 | jpWest.add(cbSpecies);
100 | jpWest.add(jpTmp);
101 | northPanel.add(jpWest, BorderLayout.WEST);
102 |
103 | JPanel jpCenter = new JPanel();
104 | jpCenter.setLayout(new BoxLayout(jpCenter, BoxLayout.X_AXIS));
105 | final JLabel lbUnSelected = new JLabel("Sample List");
106 | final JLabel lbSelected = new JLabel("Sample selected");
107 | jlUnSelected = new JList();
108 | jlSelected = new JList();
109 | unSelected = new Vector();
110 | selected = new Vector();
111 | jlUnSelected.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
112 | jlSelected.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
113 | scrollUnSelected = new JScrollPane(jlUnSelected);
114 | scrollSelected = new JScrollPane(jlSelected);
115 | scrollUnSelected.setPreferredSize(new Dimension((int) jpCenter.getWidth() / 2, 100));
116 | scrollSelected.setPreferredSize(new Dimension((int) jpCenter.getWidth() / 2, 100));
117 | JPanel jpLeft = new JPanel();
118 | JPanel jpRight = new JPanel();
119 | jpLeft.setLayout(new BoxLayout(jpLeft, BoxLayout.Y_AXIS));
120 | jpRight.setLayout(new BoxLayout(jpRight, BoxLayout.Y_AXIS));
121 | jpLeft.add(lbUnSelected);
122 | jpLeft.add(scrollUnSelected);
123 | jpRight.add(lbSelected);
124 | jpRight.add(scrollSelected);
125 | jpCenter.add(jpLeft);
126 | jpCenter.add(jpRight);
127 | northPanel.add(jpCenter, BorderLayout.CENTER);
128 |
129 | final JButton btCompare = new JButton("Compare");
130 | JButton btReset = new JButton("Reset");
131 | JButton btSave = new JButton("Save as");
132 | JPanel jpEast = new JPanel();
133 | jpEast.setLayout(new BoxLayout(jpEast, BoxLayout.Y_AXIS));
134 | jpEast.add(new JLabel(" "));
135 | jpEast.add(btCompare);
136 | jpEast.add(btReset);
137 | jpEast.add(btSave);
138 | northPanel.add(jpEast, BorderLayout.EAST);
139 | getContentPane().add(northPanel, BorderLayout.NORTH);
140 |
141 | model = new DefaultTableModel();
142 | tbResult = new JTable(model);
143 | colName = new Vector();
144 | tableData = new Vector>();
145 | JScrollPane jsResult = new JScrollPane(tbResult);
146 | tbResult.setDefaultRenderer(Object.class, new EvenOddRenderer());
147 | tbResult.setAutoCreateRowSorter(true);
148 | tbResult.setAutoscrolls(true);
149 | tbResult.setEnabled(false);
150 | getContentPane().add(jsResult, BorderLayout.CENTER);
151 |
152 | colName.addElement("No.");
153 | colName.addElement("gene name");
154 | colName.addElement("circRNA ID");
155 | colName.addElement("chromosome");
156 | colName.addElement("donor site");
157 | colName.addElement("acceptor site");
158 | colName.addElement("junction reads");
159 | colName.addElement("strand");
160 | colName.addElement("tissue name");
161 | colName.addElement("tissue num");
162 | colName.addElement("sample name");
163 | colName.addElement("sample num");
164 | colName.addElement("tool name");
165 | colName.addElement("tool num");
166 | colName.addElement("circRNA type");
167 | colName.addElement("circRNA region");
168 |
169 | cbSpecies.addItemListener(new ItemListener() {
170 | public void itemStateChanged(ItemEvent e) {
171 | if (e.getStateChange() == ItemEvent.SELECTED) {
172 | unSelected.removeAllElements();
173 | selected.removeAllElements();
174 | if(null == cbSpecies.getSelectedItem()) {
175 | return;
176 | }
177 | String species = cbSpecies.getSelectedItem().toString();
178 | TreeMap tools = new TreeMap();
179 | for(Vector rowData : MainData.getCircRnaFilesInfo()) {
180 | String sname = rowData.get(0);
181 | String fname = rowData.get(2);
182 | if(species.equalsIgnoreCase(sname)) {
183 | tools.put(fname, fname);
184 | }
185 | }
186 | for(String tool : tools.keySet()) {
187 | unSelected.add(tool);
188 | }
189 |
190 | jlUnSelected.setListData(unSelected);
191 | jlSelected.setListData(selected);
192 | }
193 | }
194 | });
195 |
196 | jlUnSelected.addMouseListener(new MouseListener() {
197 | public void mouseClicked(MouseEvent e) {
198 | JList theList = (JList) e.getSource();
199 | int index = theList.locationToIndex(e.getPoint());
200 | if (index >= 0) {
201 | String slct = theList.getModel().getElementAt(index);
202 | for (String name : unSelected) {
203 | if (name.equalsIgnoreCase(slct)) {
204 | unSelected.remove(name);
205 | break;
206 | }
207 | }
208 | selected.addElement(slct);
209 | jlUnSelected.removeAll();
210 | jlSelected.removeAll();
211 | jlUnSelected.setListData(unSelected);
212 | jlSelected.setListData(selected);
213 | }
214 | }
215 |
216 | public void mousePressed(MouseEvent e) {
217 | }
218 |
219 | public void mouseReleased(MouseEvent e) {
220 | }
221 |
222 | public void mouseEntered(MouseEvent e) {
223 | }
224 |
225 | public void mouseExited(MouseEvent e) {
226 | }
227 | });
228 |
229 | jlSelected.addMouseListener(new MouseListener() {
230 | public void mouseClicked(MouseEvent e) {
231 | JList theList = (JList) e.getSource();
232 | int index = theList.locationToIndex(e.getPoint());
233 | if (index >= 0) {
234 | String slct = theList.getModel().getElementAt(index);
235 | for (String name : selected) {
236 | if (name.equalsIgnoreCase(slct)) {
237 | selected.remove(name);
238 | break;
239 | }
240 | }
241 | unSelected.addElement(slct);
242 | jlUnSelected.removeAll();
243 | jlSelected.removeAll();
244 | jlUnSelected.setListData(unSelected);
245 | jlSelected.setListData(selected);
246 | }
247 | }
248 |
249 | public void mousePressed(MouseEvent e) {
250 | }
251 |
252 | public void mouseReleased(MouseEvent e) {
253 | }
254 |
255 | public void mouseEntered(MouseEvent e) {
256 | }
257 |
258 | public void mouseExited(MouseEvent e) {
259 | }
260 | });
261 |
262 | btCompare.addActionListener(new ActionListener() {
263 | public void actionPerformed(ActionEvent e) {
264 | String species = (String) cbSpecies.getSelectedItem();
265 | if (null == species || species.equals("")) {
266 | return;
267 | }
268 | fillTable();
269 | }
270 | });
271 |
272 | btReset.addActionListener(new ActionListener() {
273 | public void actionPerformed(ActionEvent e) {
274 | unSelected.removeAllElements();
275 | selected.removeAllElements();
276 | jlUnSelected.setListData(unSelected);
277 | jlSelected.setListData(selected);
278 | tableData.removeAllElements();
279 | model.setDataVector(tableData, colName);
280 | }
281 | });
282 |
283 | btSave.addActionListener(new ActionListener() {
284 | public void actionPerformed(ActionEvent e) {
285 | CsvSaveFileChooser saveFile = new CsvSaveFileChooser("Save as ...");
286 | saveFile.setFileSelectionMode(JFileChooser.FILES_ONLY);
287 | saveFile.setMultiSelectionEnabled(false);
288 | int returnValue = saveFile.showSaveDialog(null);
289 | if (returnValue == JFileChooser.APPROVE_OPTION) {
290 | File fileOut = saveFile.getSelectedFile();
291 | String type = "csv";
292 | String fileName = fileOut.getAbsolutePath() + "." + type;
293 | try {
294 | BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
295 | for (int i = 0; i < tbResult.getColumnCount(); i++) {
296 | out.write(tbResult.getColumnName(i) + "\t");
297 | }
298 | out.newLine();
299 | for (int i = 0; i < tbResult.getRowCount(); i++) {
300 | for (int j = 0; j < tbResult.getColumnCount(); j++) {
301 | out.write(tbResult.getValueAt(i, j).toString() + "\t");
302 | }
303 | out.newLine();
304 | }
305 | out.close();
306 | JOptionPane.showMessageDialog(null, "Export Data Successfully!");
307 | } catch (IOException e1) {
308 | CircView.log.warn(e1.getMessage());
309 | }
310 | }
311 | }
312 | });
313 |
314 | tbResult.addMouseMotionListener(new MouseAdapter() {
315 | public void mouseMoved(MouseEvent e) {
316 | int row = tbResult.rowAtPoint(e.getPoint());
317 | int col = tbResult.columnAtPoint(e.getPoint());
318 | if (row >= 0 && col >= 0) {
319 | Object value = tbResult.getValueAt(row, col);
320 | if (null != value && !value.equals("")) {
321 | tbResult.setToolTipText(value.toString());
322 | } else {
323 | tbResult.setToolTipText(null);
324 | }
325 | }
326 | }
327 | });
328 |
329 | for (String speciesName : MainData.getSpeciesData().keySet()) {
330 | cbSpecies.addItem(speciesName);
331 | }
332 | for (int i = 0; i <= Constant.BP_MATCH_TOLERATE; i++) {
333 | cbTolerate.addItem(i + "");
334 | }
335 |
336 | }
337 |
338 | private void fillTable() {
339 | tableData.removeAllElements();
340 | if (selected.size() > 0) {
341 | fillTableOr();
342 | }
343 | model.setDataVector(tableData, colName);
344 | }
345 |
346 | private void fillTableOr() {
347 | int tolerate = Integer.parseInt((String) cbTolerate.getSelectedItem());
348 | int num = 0;
349 | String species = (String) cbSpecies.getSelectedItem();
350 | if ((null == species) || (species.equals(""))) {
351 | return;
352 | }
353 | TreeMap genes = MainData.getSpeciesData().get(species);
354 | for (String geneName : genes.keySet()) {
355 | Gene gene = genes.get(geneName);
356 | TreeMap geneTrans = gene.getGeneTranscripts();
357 | for (String geneTransName : geneTrans.keySet()) {
358 | GeneTranscript gt = geneTrans.get(geneTransName);
359 | TreeMap circRnas = gt.getCircRnas();
360 | Vector circIds = new Vector();
361 | for (String circId : circRnas.keySet()) {
362 | circIds.addElement(circId);
363 | }
364 | TreeMap> matched = new TreeMap>();
365 | TreeMap deleted = new TreeMap();
366 | for (int i = 0; i < circIds.size() - 1; i++) {
367 | for (int j = i + 1; j < circIds.size(); j++) {
368 | if ((null != deleted.get(i)) || (null != deleted.get(j))) {
369 | continue;
370 | }
371 | CircRna majorCirc = circRnas.get(circIds.get(i));
372 | CircRna minorCirc = circRnas.get(circIds.get(j));
373 | if ((Math.abs(majorCirc.getStartPoint() - minorCirc.getStartPoint()) <= tolerate)
374 | && (Math.abs(majorCirc.getEndPoint() - minorCirc.getEndPoint()) <= tolerate)) {
375 | if (null != matched.get(majorCirc.getCircRnaID())) {
376 | Vector sameCircs = matched.get(majorCirc.getCircRnaID());
377 | sameCircs.addElement(minorCirc.getCircRnaID());
378 | matched.put(majorCirc.getCircRnaID(), sameCircs);
379 | deleted.put(j, minorCirc.getCircRnaID());
380 | } else {
381 | Vector sameCircs = new Vector();
382 | sameCircs.addElement(minorCirc.getCircRnaID());
383 | matched.put(majorCirc.getCircRnaID(), sameCircs);
384 | deleted.put(j, minorCirc.getCircRnaID());
385 | }
386 | }
387 | }
388 | }
389 |
390 | for (int i = 0; i < circIds.size(); i++) {
391 | if (null != deleted.get(i)) {
392 | continue;
393 | }
394 | String circId = circIds.get(i);
395 | // tissues name, smaples name, tools name from circRNA info
396 | TreeMap files = new TreeMap();
397 | TreeMap tissues = new TreeMap();
398 | TreeMap samples = new TreeMap();
399 | TreeMap tools = new TreeMap();
400 | for (String fileName : gt.getCircRnas().get(circId).getFiles().keySet()) {
401 | files.put(fileName, 1);
402 | }
403 | for (String sampleName : gt.getCircRnas().get(circId).getSamples().keySet()) {
404 | samples.put(sampleName, 1);
405 | }
406 | for (String toolName : gt.getCircRnas().get(circId).getCircTools().keySet()) {
407 | tools.put(toolName, 1);
408 | }
409 | Vector sameCircs = matched.get(circId);
410 | if (null != sameCircs) {
411 | for (String sameCircId : sameCircs) {
412 | for (String fileName : gt.getCircRnas().get(sameCircId).getFiles().keySet()) {
413 | files.put(fileName, 1);
414 | }
415 | for (String sampleName : gt.getCircRnas().get(sameCircId).getSamples().keySet()) {
416 | samples.put(sampleName, 1);
417 | }
418 | for (String toolName : gt.getCircRnas().get(sameCircId).getCircTools().keySet()) {
419 | tools.put(toolName, 1);
420 | }
421 | }
422 | }
423 | for (String sampleName : samples.keySet()) {
424 | String[] tmp = sampleName.split("_");
425 | tissues.put(tmp[0], 1);
426 | }
427 |
428 | // tissues name, smaples name, tools name from file table
429 | TreeMap fTissues = new TreeMap();
430 | TreeMap fSamples = new TreeMap();
431 | TreeMap fTools = new TreeMap();
432 | for (String name : selected) {
433 | for (Vector rowData : MainData.getCircRnaFilesInfo()) {
434 | String sname = rowData.get(0);
435 | String tname = rowData.get(1);
436 | String fname = rowData.get(2);
437 | if(species.equalsIgnoreCase(sname) && fname.equalsIgnoreCase(name)) {
438 | String[] tmp = fname.split("_");
439 | fTissues.put(tmp[0], 1);
440 | tmp = fname.split("\\.");
441 | fSamples.put(tmp[0], 1);
442 | fTools.put(tname, 1);
443 | }
444 | }
445 | }
446 |
447 | boolean hasFile = false;
448 | for (String name : files.keySet()) {
449 | for (String file : selected) {
450 | if (file.equalsIgnoreCase(name)) {
451 | hasFile = true;
452 | break;
453 | }
454 | }
455 | if (hasFile) {
456 | break;
457 | }
458 | }
459 | if (!hasFile) {
460 | continue;
461 | }
462 |
463 | num++;
464 | Vector one = new Vector();
465 | // Number
466 | one.addElement(num + "");
467 | // Gene Name
468 | one.addElement(gene.getGeneName());
469 | // CircRNA ID
470 | String id = circId;
471 | if (null != sameCircs) {
472 | for (int j = 0; j < sameCircs.size(); j++) {
473 | if (0 == j) {
474 | id += "(";
475 | }
476 | id += sameCircs.get(j) + ",";
477 | if ((sameCircs.size() - 1) == j) {
478 | id += ")";
479 | }
480 | }
481 | }
482 | one.addElement(id);
483 | one.addElement(gt.getCircRnas().get(circId).getChrom());
484 | // Start Point
485 | String startP = gt.getCircRnas().get(circId).getStartPoint() + "";
486 | if (null != sameCircs) {
487 | for (int j = 0; j < sameCircs.size(); j++) {
488 | if (0 == j) {
489 | startP += "(";
490 | }
491 | startP += gt.getCircRnas().get(sameCircs.get(j)).getStartPoint() + ",";
492 | if ((sameCircs.size() - 1) == j) {
493 | startP += ")";
494 | }
495 | }
496 | }
497 | one.addElement(startP);
498 | // End Point
499 | String endP = gt.getCircRnas().get(circId).getEndPoint() + "";
500 | if (null != sameCircs) {
501 | for (int j = 0; j < sameCircs.size(); j++) {
502 | if (0 == j) {
503 | endP += "(";
504 | }
505 | endP += gt.getCircRnas().get(sameCircs.get(j)).getEndPoint() + ",";
506 | if ((sameCircs.size() - 1) == j) {
507 | endP += ")";
508 | }
509 | }
510 | }
511 | one.addElement(endP);
512 | // Junction Reads
513 | String reads = gt.getCircRnas().get(circId).getJunctionReads() + "";
514 | if (null != sameCircs) {
515 | for (int j = 0; j < sameCircs.size(); j++) {
516 | if (0 == j) {
517 | reads += "(";
518 | }
519 | reads += gt.getCircRnas().get(sameCircs.get(j)).getJunctionReads() + ",";
520 | if ((sameCircs.size() - 1) == j) {
521 | reads += ")";
522 | }
523 | }
524 | }
525 | one.addElement(reads);
526 | // Strand
527 | one.addElement(gt.getCircRnas().get(circId).getStrand());
528 | // CircRNA Tissues
529 | String tissue = "";
530 | int tissueNum = 0;
531 | for (String tissueName : fTissues.keySet()) {
532 | if (null != tissues.get(tissueName)) {
533 | tissue += tissueName + ",";
534 | tissueNum++;
535 | }
536 | }
537 | one.addElement(tissue);
538 | one.addElement(tissueNum + "");
539 | // CircRNA Sample Name
540 | String sample = "";
541 | int sampleNum = 0;
542 | for (String sampleName : fSamples.keySet()) {
543 | if (null != samples.get(sampleName)) {
544 | sample += sampleName + ",";
545 | sampleNum++;
546 | }
547 |
548 | }
549 | one.addElement(sample);
550 | one.addElement(sampleNum + "");
551 | // CircRNA Tools or Algorithm
552 | String tool = "";
553 | int toolNum = 0;
554 | for (String toolName : fTools.keySet()) {
555 | if (null != tools.get(toolName)) {
556 | tool += toolName + ",";
557 | toolNum++;
558 | }
559 | }
560 | one.addElement(tool);
561 | one.addElement(toolNum + "");
562 | // CircRNA Type
563 | one.addElement(gt.getCircRnas().get(circId).getCircRnaType());
564 | // CircRNA Region
565 | one.addElement(gt.getCircRnas().get(circId).getRegion());
566 | tableData.addElement(one);
567 | }
568 | break;
569 | }
570 | }
571 | }
572 |
573 | }
574 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/CsvSaveFileChooser.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.io.File;
4 |
5 | import javax.swing.JFileChooser;
6 | import javax.swing.filechooser.FileFilter;
7 |
8 | public class CsvSaveFileChooser extends JFileChooser {
9 |
10 | private static final long serialVersionUID = 1L;
11 |
12 | public CsvSaveFileChooser(String title) {
13 | super(title);
14 | addFileFilter();
15 | // Set default Dir
16 | this.setCurrentDirectory(new File(System.getProperty("user.dir")));
17 | }
18 |
19 | private void addFileFilter() {
20 |
21 | addChoosableFileFilter(new FileFilter() {
22 | public boolean accept(File f) {
23 | return f.getName().endsWith("csv");
24 | }
25 |
26 | public String getDescription() {
27 | return "csv";
28 | }
29 | });
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/DataLoadingDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Frame;
6 | import java.awt.Rectangle;
7 |
8 | import javax.swing.JDialog;
9 |
10 | public class DataLoadingDialog extends JDialog {
11 | private static final long serialVersionUID = 1L;
12 |
13 | public DataLoadingDialog(Frame owner, String title) {
14 | super(owner, title);
15 | initUI();
16 | setTitle(title);
17 | setResizable(false);
18 | setSize(300, 1);
19 | this.setLayout(new FlowLayout());
20 | centerScreen();
21 | }
22 |
23 | private void centerScreen() {
24 | Dimension dim = getToolkit().getScreenSize();
25 | Rectangle abounds = getBounds();
26 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
27 | super.setVisible(true);
28 | requestFocus();
29 | }
30 |
31 | private void initUI() {
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/DataLoadingProgressDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Color;
4 | import java.awt.Dimension;
5 | import java.awt.FlowLayout;
6 | import java.awt.Frame;
7 | import java.awt.Rectangle;
8 | import java.awt.event.ActionEvent;
9 | import java.awt.event.ActionListener;
10 |
11 | import javax.swing.JDialog;
12 | import javax.swing.JPanel;
13 | import javax.swing.JProgressBar;
14 | import javax.swing.Timer;
15 | import javax.swing.border.EmptyBorder;
16 |
17 | public class DataLoadingProgressDialog extends JDialog {
18 | private static final long serialVersionUID = 1L;
19 | private Timer timer;
20 | public static JProgressBar process;
21 |
22 | public DataLoadingProgressDialog(Frame owner, String title) {
23 | super(owner, title);
24 | setTitle(title);
25 | setResizable(false);
26 | setSize(300, 300);
27 | this.setLayout(new FlowLayout());
28 | centerScreen();
29 | initUI();
30 | }
31 |
32 | private void centerScreen() {
33 | Dimension dim = getToolkit().getScreenSize();
34 | Rectangle abounds = getBounds();
35 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
36 | super.setVisible(true);
37 | requestFocus();
38 | }
39 |
40 | private void initUI() {
41 | JPanel panel = new JPanel();
42 | panel.setBorder(new EmptyBorder(5, 5, 5, 5));
43 | panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
44 | getContentPane().add(panel);
45 | process = new JProgressBar(0, 100);
46 | process.setStringPainted(true);
47 | process.setBackground(Color.GREEN);
48 | process.setPreferredSize(new Dimension(200, 40));
49 | process.setValue(0);
50 | panel.add(process);
51 |
52 | timer = new Timer(100, new ActionListener() {
53 | public void actionPerformed(ActionEvent e) {
54 | int loadingValue = process.getValue();
55 | if (loadingValue < 100) {
56 | process.setValue(loadingValue);
57 | } else {
58 | timer.stop();
59 | }
60 | }
61 | });
62 | timer.start();
63 | }
64 |
65 | public static JProgressBar getProcess() {
66 | return process;
67 | }
68 |
69 | public static void setProcess(JProgressBar process) {
70 | DataLoadingProgressDialog.process = process;
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/DetailsResultDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.Rectangle;
5 |
6 | import javax.swing.JDialog;
7 | import javax.swing.JScrollPane;
8 | import javax.swing.JTextArea;
9 |
10 | import cn.edu.whu.CircView;
11 |
12 | public class DetailsResultDialog extends JDialog {
13 | private static final long serialVersionUID = 1L;
14 |
15 | public DetailsResultDialog(String contents) {
16 | super(CircView.frame);
17 | setTitle("Details");
18 | setResizable(true);
19 | setSize(600, 400);
20 | centerScreen();
21 |
22 | JTextArea detailsTextArea = new JTextArea();
23 | detailsTextArea.setSize(new Dimension(this.getContentPane().getWidth(), this.getContentPane().getWidth()));
24 | detailsTextArea.setEditable(false);
25 | detailsTextArea.setText(contents);
26 | JScrollPane sp = new JScrollPane(detailsTextArea);
27 | sp.setPreferredSize(new Dimension(this.getContentPane().getWidth(), this.getContentPane().getWidth()));
28 | this.getContentPane().add(sp);
29 | this.setVisible(true);
30 | this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
31 | }
32 |
33 | private void centerScreen() {
34 | Dimension dim = getToolkit().getScreenSize();
35 | Rectangle abounds = getBounds();
36 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
37 | super.setVisible(true);
38 | requestFocus();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/ImageSaveFileChooser.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.io.File;
4 |
5 | import javax.swing.JFileChooser;
6 | import javax.swing.filechooser.FileFilter;
7 |
8 | public class ImageSaveFileChooser extends JFileChooser {
9 |
10 | private static final long serialVersionUID = 1L;
11 |
12 | public ImageSaveFileChooser(String title) {
13 | super(title);
14 | addFileFilter();
15 | // Set default Dir
16 | this.setCurrentDirectory(new File(System.getProperty("user.dir")));
17 | }
18 |
19 | private void addFileFilter() {
20 |
21 | addChoosableFileFilter(new FileFilter() {
22 | public boolean accept(File f) {
23 | return f.getName().endsWith("png");
24 | }
25 |
26 | public String getDescription() {
27 | return "png";
28 | }
29 | });
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/MreClearDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import java.awt.event.ItemEvent;
9 | import java.awt.event.ItemListener;
10 | import java.sql.Connection;
11 | import java.sql.SQLException;
12 | import javax.swing.JButton;
13 | import javax.swing.JComboBox;
14 | import javax.swing.JDialog;
15 | import javax.swing.JOptionPane;
16 |
17 | import cn.edu.whu.MainData;
18 | import cn.edu.whu.CircView;
19 | import cn.edu.whu.util.DbUtil;
20 |
21 | public class MreClearDialog extends JDialog {
22 |
23 | private static final long serialVersionUID = 1L;
24 | Connection conn;
25 |
26 | public MreClearDialog(Connection conn) {
27 | super(CircView.frame);
28 | this.conn = conn;
29 | initUi();
30 | setTitle("Clear MRE Data");
31 | setResizable(false);
32 | setSize(300, 65);
33 | this.setLayout(new FlowLayout());
34 | centerScreen();
35 | }
36 |
37 | private void centerScreen() {
38 | Dimension dim = getToolkit().getScreenSize();
39 | Rectangle abounds = getBounds();
40 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
41 | super.setVisible(true);
42 | requestFocus();
43 | }
44 |
45 | private void initUi() {
46 | // ComboBox
47 | final JComboBox cbSpecies = new JComboBox();
48 | cbSpecies.setPreferredSize(new Dimension(150, 28));
49 | getContentPane().add(cbSpecies);
50 | // Add ItemListener to Speicies
51 | cbSpecies.addItemListener(new ItemListener() {
52 | public void itemStateChanged(ItemEvent e) {
53 | if (e.getStateChange() == ItemEvent.SELECTED) {
54 | }
55 | }
56 | });
57 | for (String speciesName : MainData.getSpeciesNames()) {
58 | cbSpecies.addItem(speciesName);
59 | }
60 | // Button
61 | JButton btOpen = new JButton("Clear MRE Data");
62 | getContentPane().add(btOpen);
63 | btOpen.addActionListener(new ActionListener() {
64 | public void actionPerformed(ActionEvent e) {
65 | setVisible(false);
66 | int dialogButton = JOptionPane.showConfirmDialog(CircView.frame,
67 | "All MRE Data for " + cbSpecies.getSelectedItem() + " WILL BE ERASE!");
68 | if (dialogButton == JOptionPane.YES_OPTION) {
69 | DataLoadingDialog clearDialog = new DataLoadingDialog(CircView.frame, "Erasing MRE ...");
70 | // Delete MRE data for selected Species
71 | String species = cbSpecies.getSelectedItem().toString();
72 | try {
73 | String tableName = "mre_" + DbUtil.species2TableName(species);
74 | DbUtil.dropTable(conn, tableName);
75 | } catch (ClassNotFoundException | SQLException ex) {
76 | JOptionPane.showMessageDialog(CircView.frame, "MRE Data Clear Failed!");
77 | CircView.log.warn(ex.getMessage());
78 | }
79 | CircView.log.info("MRE Data for " + species + " Deleted");
80 | CircView.updateRbpMreStatus();
81 | clearDialog.setVisible(false);
82 | }
83 | MreClearDialog.this.dispose();
84 | }
85 | });
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/MreLoadDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import java.awt.event.ItemEvent;
9 | import java.awt.event.ItemListener;
10 | import java.io.File;
11 | import java.sql.Connection;
12 | import java.sql.SQLException;
13 | import javax.swing.JButton;
14 | import javax.swing.JComboBox;
15 | import javax.swing.JDialog;
16 | import javax.swing.JFileChooser;
17 | import javax.swing.JOptionPane;
18 |
19 | import cn.edu.whu.MainData;
20 | import cn.edu.whu.CircView;
21 | import cn.edu.whu.util.DbUtil;
22 |
23 | public class MreLoadDialog extends JDialog {
24 |
25 | private static final long serialVersionUID = 1L;
26 |
27 | private File[] files;
28 | Connection conn;
29 |
30 | public MreLoadDialog(Connection conn) {
31 | super(CircView.frame);
32 | this.conn = conn;
33 | initUi();
34 | setTitle("Load MRE files");
35 | setResizable(false);
36 | setSize(300, 65);
37 | this.setLayout(new FlowLayout());
38 | centerScreen();
39 | }
40 |
41 | private void centerScreen() {
42 | Dimension dim = getToolkit().getScreenSize();
43 | Rectangle abounds = getBounds();
44 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
45 | super.setVisible(true);
46 | requestFocus();
47 | }
48 |
49 | private void initUi() {
50 | // ComboBox
51 | final JComboBox cbSpecies = new JComboBox();
52 | cbSpecies.setPreferredSize(new Dimension(150, 28));
53 | getContentPane().add(cbSpecies);
54 | // Add ItemListener to Speicies
55 | cbSpecies.addItemListener(new ItemListener() {
56 | public void itemStateChanged(ItemEvent e) {
57 | if (e.getStateChange() == ItemEvent.SELECTED) {
58 | }
59 | }
60 | });
61 | for (String speciesName : MainData.getSpeciesNames()) {
62 | cbSpecies.addItem(speciesName);
63 | }
64 | // Button
65 | JButton btOpen = new JButton("Open MRE files");
66 | getContentPane().add(btOpen);
67 | btOpen.addActionListener(new ActionListener() {
68 | public void actionPerformed(ActionEvent e) {
69 | MreLoadDialog.this.setVisible(false);
70 | OpenFileChooser openFile = new OpenFileChooser("Open MRE Files");
71 | openFile.setMultiSelectionEnabled(true);
72 | openFile.setFileSelectionMode(JFileChooser.FILES_ONLY);
73 | openFile.setFileHidingEnabled(true);
74 | int returnValue = openFile.showOpenDialog(null);
75 | if (returnValue == JFileChooser.APPROVE_OPTION) {
76 | String species = cbSpecies.getSelectedItem().toString();
77 | files = openFile.getSelectedFiles();
78 | DataLoadingDialog dataLoadingDialog = new DataLoadingDialog(CircView.frame, "Loading MRE Data ...");
79 | save2Db(species, files);
80 | CircView.updateRbpMreStatus();
81 | dataLoadingDialog.setVisible(false);
82 | }
83 | MreLoadDialog.this.dispose();
84 | }
85 | });
86 | }
87 |
88 | private void save2Db(String species, File[] files) {
89 | if (null == conn) {
90 | try {
91 | conn = DbUtil.connectDb();
92 | } catch (ClassNotFoundException | SQLException e) {
93 | CircView.log.warn(e.getMessage());
94 | JOptionPane.showConfirmDialog(CircView.frame, "Can't Connect to the Database!");
95 | return;
96 | }
97 | }
98 | try {
99 | String tableName = "mre_" + DbUtil.species2TableName(species);
100 | if (!DbUtil.existTable(conn, tableName)) {
101 | DbUtil.createMreTable(conn, tableName);
102 | }
103 | for (int i = 0; i < files.length; i++) {
104 | DbUtil.file2Db(conn, files[i].getAbsolutePath(), tableName);
105 | }
106 | } catch (ClassNotFoundException | SQLException e) {
107 | CircView.log.warn(e.getMessage());
108 | JOptionPane.showMessageDialog(CircView.frame, "File FORMAT ERROR!");
109 | }
110 | CircView.log.info("MRE Data for " + species + " Loaded");
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/OpenFileChooser.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.io.File;
4 |
5 | import javax.swing.JFileChooser;
6 |
7 | public class OpenFileChooser extends JFileChooser {
8 | private static final long serialVersionUID = 1L;
9 |
10 | public OpenFileChooser(String title) {
11 | super(title);
12 | // addFileFilter();
13 | setAcceptAllFileFilterUsed(false);
14 |
15 | // Set default Dir
16 | this.setCurrentDirectory(new File(System.getProperty("user.dir")));
17 | }
18 |
19 | // private void addFileFilter() {
20 | //
21 | // for (final String circRnaTool : Constant.CIRCRNA_TOOLS.keySet()) {
22 | // for (final String species : Constant.SPECIES.keySet()) {
23 | // addChoosableFileFilter(new FileFilter() {
24 | // public boolean accept(File f) {
25 | // return f.getName().endsWith("");
26 | // }
27 | //
28 | // public String getDescription() {
29 | // return circRnaTool + " in " + species;
30 | // }
31 | // });
32 | // }
33 | // }
34 | // }
35 | }
36 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/ProgressDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.BorderLayout;
4 | import java.awt.Dimension;
5 | import java.awt.Rectangle;
6 | import javax.swing.JDialog;
7 | import javax.swing.JPanel;
8 | import javax.swing.JProgressBar;
9 | import cn.edu.whu.CircView;
10 |
11 | public class ProgressDialog extends JDialog {
12 | private static final long serialVersionUID = 1L;
13 | private static JProgressBar progressBar;
14 |
15 | public ProgressDialog() {
16 | super(CircView.frame);
17 | setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
18 | setLayout(new BorderLayout());
19 | setSize(600, 400);
20 | setResizable(false);
21 | setTitle("Load Data ...");
22 | centerScreen();
23 | progressBar = new JProgressBar(0, 100);
24 | progressBar.setValue(0);
25 | progressBar.setStringPainted(true);
26 | JPanel panel = new JPanel();
27 | panel.add(progressBar);
28 | this.getContentPane().add(panel);
29 | start();
30 | }
31 |
32 | public void start() {
33 | while (progressBar.getValue() < 100) {
34 | try {
35 | Thread.sleep(500);
36 | repaint();
37 | } catch (InterruptedException e) {
38 | CircView.log.info(e.getMessage());
39 | }
40 | }
41 | }
42 |
43 | private void centerScreen() {
44 | Dimension dim = getToolkit().getScreenSize();
45 | Rectangle abounds = getBounds();
46 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
47 | super.setVisible(true);
48 | requestFocus();
49 | }
50 |
51 | public static JProgressBar getProgressBar() {
52 | return progressBar;
53 | }
54 |
55 | public static void setProgressBar(JProgressBar progressBar) {
56 | ProgressDialog.progressBar = progressBar;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/RbpClearDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import java.awt.event.ItemEvent;
9 | import java.awt.event.ItemListener;
10 | import java.sql.Connection;
11 | import java.sql.SQLException;
12 | import javax.swing.JButton;
13 | import javax.swing.JComboBox;
14 | import javax.swing.JDialog;
15 | import javax.swing.JOptionPane;
16 |
17 | import cn.edu.whu.MainData;
18 | import cn.edu.whu.CircView;
19 | import cn.edu.whu.util.DbUtil;
20 |
21 | public class RbpClearDialog extends JDialog {
22 |
23 | private static final long serialVersionUID = 1L;
24 | Connection conn;
25 |
26 | public RbpClearDialog(Connection conn) {
27 | super(CircView.frame);
28 | this.conn = conn;
29 | initUi();
30 | setTitle("Clear RBP Data");
31 | setResizable(false);
32 | setSize(300, 65);
33 | this.setLayout(new FlowLayout());
34 | centerScreen();
35 | }
36 |
37 | private void centerScreen() {
38 | Dimension dim = getToolkit().getScreenSize();
39 | Rectangle abounds = getBounds();
40 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
41 | super.setVisible(true);
42 | requestFocus();
43 | }
44 |
45 | private void initUi() {
46 | // ComboBox
47 | final JComboBox cbSpecies = new JComboBox();
48 | cbSpecies.setPreferredSize(new Dimension(150, 28));
49 | getContentPane().add(cbSpecies);
50 | // Add ItemListener to Speicies
51 | cbSpecies.addItemListener(new ItemListener() {
52 | public void itemStateChanged(ItemEvent e) {
53 | if (e.getStateChange() == ItemEvent.SELECTED) {
54 | }
55 | }
56 | });
57 | for (String speciesName : MainData.getSpeciesNames()) {
58 | cbSpecies.addItem(speciesName);
59 | }
60 | // Button
61 | JButton btOpen = new JButton("Clear RBP Data");
62 | getContentPane().add(btOpen);
63 | btOpen.addActionListener(new ActionListener() {
64 | public void actionPerformed(ActionEvent e) {
65 | RbpClearDialog.this.setVisible(false);
66 | int dialogButton = JOptionPane.showConfirmDialog(CircView.frame,
67 | "All RBP Data for " + cbSpecies.getSelectedItem() + " WILL BE ERASE!");
68 | if (dialogButton == JOptionPane.YES_OPTION) {
69 | DataLoadingDialog clearDialog = new DataLoadingDialog(CircView.frame, "Erasing RBP ...");
70 | // Delete RBP data for selected Species
71 | String species = cbSpecies.getSelectedItem().toString();
72 | try {
73 | String tableName = "rbp_" + DbUtil.species2TableName(species);
74 | DbUtil.dropTable(conn, tableName);
75 | } catch (ClassNotFoundException | SQLException ex) {
76 | JOptionPane.showMessageDialog(CircView.frame, "RBP Data Clear Failed!");
77 | CircView.log.warn(ex.getMessage());
78 | }
79 | CircView.log.info("RBP Data for " + species + " Deleted");
80 | CircView.updateRbpMreStatus();
81 | clearDialog.setVisible(false);
82 | }
83 | RbpClearDialog.this.dispose();
84 | }
85 | });
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/RbpLoadDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import java.awt.event.ItemEvent;
9 | import java.awt.event.ItemListener;
10 | import java.io.File;
11 | import java.sql.Connection;
12 | import java.sql.SQLException;
13 | import javax.swing.JButton;
14 | import javax.swing.JComboBox;
15 | import javax.swing.JDialog;
16 | import javax.swing.JFileChooser;
17 | import javax.swing.JOptionPane;
18 |
19 | import cn.edu.whu.MainData;
20 | import cn.edu.whu.CircView;
21 | import cn.edu.whu.util.DbUtil;
22 |
23 | public class RbpLoadDialog extends JDialog {
24 |
25 | private static final long serialVersionUID = 1L;
26 |
27 | private File[] files;
28 | Connection conn;
29 |
30 | public RbpLoadDialog(Connection conn) {
31 | super(CircView.frame);
32 | this.conn = conn;
33 | initUi();
34 | setTitle("Load RBP files");
35 | setResizable(false);
36 | setSize(300, 65);
37 | this.setLayout(new FlowLayout());
38 | centerScreen();
39 | }
40 |
41 | private void centerScreen() {
42 | Dimension dim = getToolkit().getScreenSize();
43 | Rectangle abounds = getBounds();
44 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
45 | super.setVisible(true);
46 | requestFocus();
47 | }
48 |
49 | private void initUi() {
50 | // ComboBox
51 | final JComboBox cbSpecies = new JComboBox();
52 | cbSpecies.setPreferredSize(new Dimension(150, 28));
53 | getContentPane().add(cbSpecies);
54 | // Add ItemListener to Speicies
55 | cbSpecies.addItemListener(new ItemListener() {
56 | public void itemStateChanged(ItemEvent e) {
57 | if (e.getStateChange() == ItemEvent.SELECTED) {
58 | }
59 | }
60 | });
61 | for (String speciesName : MainData.getSpeciesNames()) {
62 | cbSpecies.addItem(speciesName);
63 | }
64 | // Button
65 | JButton btOpen = new JButton("Open RBP files");
66 | getContentPane().add(btOpen);
67 | btOpen.addActionListener(new ActionListener() {
68 | public void actionPerformed(ActionEvent e) {
69 | RbpLoadDialog.this.setVisible(false);
70 | OpenFileChooser openFile = new OpenFileChooser("Open RBP Files");
71 | openFile.setMultiSelectionEnabled(true);
72 | openFile.setFileSelectionMode(JFileChooser.FILES_ONLY);
73 | openFile.setFileHidingEnabled(true);
74 | int returnValue = openFile.showOpenDialog(null);
75 | if (returnValue == JFileChooser.APPROVE_OPTION) {
76 | String species = cbSpecies.getSelectedItem().toString();
77 | files = openFile.getSelectedFiles();
78 | DataLoadingDialog dataLoadingDialog = new DataLoadingDialog(CircView.frame, "Loading RBP Data ...");
79 | save2Db(species, files);
80 | CircView.updateRbpMreStatus();
81 | dataLoadingDialog.setVisible(false);
82 | }
83 | RbpLoadDialog.this.dispose();
84 | }
85 | });
86 | }
87 |
88 | private void save2Db(String species, File[] files) {
89 | if (null == conn) {
90 | try {
91 | conn = DbUtil.connectDb();
92 | } catch (ClassNotFoundException | SQLException e) {
93 | CircView.log.warn(e.getMessage());
94 | JOptionPane.showConfirmDialog(CircView.frame, "Can't Connect to the Database!");
95 | return;
96 | }
97 | }
98 | try {
99 | String tableName = "rbp_" + DbUtil.species2TableName(species);
100 | if (!DbUtil.existTable(conn, tableName)) {
101 | DbUtil.createRbpTable(conn, tableName);
102 | }
103 | for (int i = 0; i < files.length; i++) {
104 | DbUtil.file2Db(conn, files[i].getAbsolutePath(), tableName);
105 | }
106 | } catch (ClassNotFoundException | SQLException e) {
107 | CircView.log.warn(e.getMessage());
108 | JOptionPane.showMessageDialog(CircView.frame, "File FORMAT ERROR!");
109 | }
110 | CircView.log.info("RBP Data for " + species + " Loaded");
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/SaveImageDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import java.io.File;
9 | import javax.swing.JButton;
10 | import javax.swing.JDialog;
11 | import javax.swing.JFileChooser;
12 | import javax.swing.JLabel;
13 | import javax.swing.JOptionPane;
14 | import javax.swing.JTextField;
15 |
16 | import cn.edu.whu.CircView;
17 |
18 | public class SaveImageDialog extends JDialog {
19 |
20 | private static final long serialVersionUID = 1L;
21 | private static CircRnaImagePanel circRnaImage;
22 |
23 | public SaveImageDialog(CircRnaImagePanel image) {
24 | super(CircView.frame);
25 | circRnaImage = image;
26 | initUi();
27 | setTitle("Save Image as File");
28 | setResizable(false);
29 | setSize(450, 65);
30 | this.setLayout(new FlowLayout());
31 | centerScreen();
32 | }
33 |
34 | private void centerScreen() {
35 | Dimension dim = getToolkit().getScreenSize();
36 | Rectangle abounds = getBounds();
37 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
38 | super.setVisible(true);
39 | requestFocus();
40 | }
41 |
42 | private void initUi() {
43 | // ComboBox
44 | final JLabel lbWidth = new JLabel("Width");
45 | final JTextField tfWidth = new JTextField();
46 | final JLabel lbHeight = new JLabel("Height");
47 | final JTextField tfHeight = new JTextField();
48 | final JLabel lbpx = new JLabel("px");
49 | JButton btSave = new JButton("Save as");
50 |
51 | tfWidth.setPreferredSize(new Dimension(100, 28));
52 | tfHeight.setPreferredSize(new Dimension(100, 28));
53 | getContentPane().add(lbWidth);
54 | getContentPane().add(tfWidth);
55 | getContentPane().add(lbHeight);
56 | getContentPane().add(tfHeight);
57 | getContentPane().add(lbpx);
58 | getContentPane().add(btSave);
59 |
60 | tfWidth.setText(circRnaImage.getWidth() * 2 + "");
61 | tfHeight.setText(circRnaImage.getHeight() * 2 + "");
62 |
63 | // Button
64 | btSave.addActionListener(new ActionListener() {
65 | public void actionPerformed(ActionEvent e) {
66 | int w = Integer.parseInt(tfWidth.getText());
67 | int h = Integer.parseInt(tfHeight.getText());
68 | if (w * h > 20000 * 10000) {
69 | JOptionPane.showMessageDialog(CircView.frame, "Image Size MUST Be Smaller than 20000 * 10000");
70 | } else if (w > 0 && h > 0) {
71 | SaveImageDialog.this.setVisible(false);
72 | ImageSaveFileChooser saveFile = new ImageSaveFileChooser("Save Image as ...");
73 | saveFile.setFileSelectionMode(JFileChooser.FILES_ONLY);
74 | saveFile.setMultiSelectionEnabled(false);
75 | int returnValue = saveFile.showSaveDialog(null);
76 | if (returnValue == JFileChooser.APPROVE_OPTION) {
77 | File fileOut = saveFile.getSelectedFile();
78 | String type = "png";
79 | String fileName = fileOut.getAbsolutePath() + "." + type;
80 | circRnaImage.saveImage(circRnaImage.getGt(), new File(fileName), type, w, h);
81 | }
82 | SaveImageDialog.this.dispose();
83 | }
84 | }
85 | });
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/SpeciesAddDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import java.io.File;
9 | import javax.swing.JButton;
10 | import javax.swing.JDialog;
11 | import javax.swing.JFileChooser;
12 | import javax.swing.JLabel;
13 | import javax.swing.JOptionPane;
14 | import javax.swing.JTextField;
15 |
16 | import cn.edu.whu.MainData;
17 | import cn.edu.whu.CircView;
18 |
19 | public class SpeciesAddDialog extends JDialog {
20 | private static final long serialVersionUID = 1L;
21 | private File speciesFile;
22 |
23 | public SpeciesAddDialog() {
24 | super(CircView.frame);
25 | initUi();
26 | setTitle("Add Species");
27 | setResizable(false);
28 | setSize(600, 65);
29 | this.setLayout(new FlowLayout());
30 | centerScreen();
31 | }
32 |
33 | private void centerScreen() {
34 | Dimension dim = getToolkit().getScreenSize();
35 | Rectangle abounds = getBounds();
36 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
37 | super.setVisible(true);
38 | requestFocus();
39 | }
40 |
41 | private void initUi() {
42 | // ComboBox
43 | final JLabel lbName = new JLabel("Name:");
44 | final JTextField tfSpecies = new JTextField();
45 | final JLabel lbFile = new JLabel("");
46 | final JTextField tfFile = new JTextField();
47 | tfFile.setEditable(false);
48 | final JButton btChoose = new JButton("Choose File");
49 | final JButton btAdd = new JButton("Add");
50 |
51 | tfSpecies.setPreferredSize(new Dimension(100, 28));
52 | tfFile.setPreferredSize(new Dimension(150, 28));
53 |
54 | getContentPane().add(lbName);
55 | getContentPane().add(tfSpecies);
56 | getContentPane().add(lbFile);
57 | getContentPane().add(tfFile);
58 | getContentPane().add(btChoose);
59 | getContentPane().add(btAdd);
60 |
61 | // Button
62 | btChoose.addActionListener(new ActionListener() {
63 | public void actionPerformed(ActionEvent e) {
64 | OpenFileChooser openFile = new OpenFileChooser("Select Gene Annotation File");
65 | openFile.setMultiSelectionEnabled(false);
66 | openFile.setFileSelectionMode(JFileChooser.FILES_ONLY);
67 | openFile.setFileHidingEnabled(true);
68 | int returnValue = openFile.showOpenDialog(null);
69 | if (returnValue == JFileChooser.APPROVE_OPTION) {
70 | tfFile.setText(openFile.getSelectedFile().getName());
71 | speciesFile = openFile.getSelectedFile();
72 | }
73 | }
74 | });
75 | btAdd.addActionListener(new ActionListener() {
76 | public void actionPerformed(ActionEvent e) {
77 | String speciesName = tfSpecies.getText();
78 | String pattern = "\\s+";
79 | if (speciesName.matches(pattern)) {
80 | JOptionPane.showMessageDialog(CircView.frame, "Species Name is needed");
81 | return;
82 | }
83 | if (null == speciesFile || speciesFile.getPath().matches(pattern)) {
84 | JOptionPane.showMessageDialog(CircView.frame,
85 | "Annotation file for [" + speciesName + "] is needed");
86 | return;
87 | }
88 |
89 | if (null != MainData.getSpeciesFile().get(speciesName)) {
90 | JOptionPane.showMessageDialog(CircView.frame, "Species [" + speciesName + "] already exists");
91 | return;
92 | } else {
93 | MainData.getSpeciesNames().add(speciesName);
94 | MainData.getSpeciesFile().put(speciesName, speciesFile.getPath());
95 | CircView.log.error(speciesName + " " + speciesFile.getPath() + " is added.");
96 | JOptionPane.showMessageDialog(CircView.frame,
97 | speciesName + " " + speciesFile.getName() + " is added.");
98 | SpeciesAddDialog.this.dispose();
99 | }
100 | }
101 | });
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/ui/SpeciesDelDialog.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.ui;
2 |
3 | import java.awt.Dimension;
4 | import java.awt.FlowLayout;
5 | import java.awt.Rectangle;
6 | import java.awt.event.ActionEvent;
7 | import java.awt.event.ActionListener;
8 | import javax.swing.JButton;
9 | import javax.swing.JComboBox;
10 | import javax.swing.JDialog;
11 | import cn.edu.whu.MainData;
12 | import cn.edu.whu.CircView;
13 |
14 | public class SpeciesDelDialog extends JDialog {
15 |
16 | private static final long serialVersionUID = 1L;
17 |
18 | public SpeciesDelDialog() {
19 | super(CircView.frame);
20 | initUi();
21 | setTitle("Delete Species");
22 | setResizable(false);
23 | setSize(300, 65);
24 | this.setLayout(new FlowLayout());
25 | centerScreen();
26 | }
27 |
28 | private void centerScreen() {
29 | Dimension dim = getToolkit().getScreenSize();
30 | Rectangle abounds = getBounds();
31 | setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);
32 | super.setVisible(true);
33 | requestFocus();
34 | }
35 |
36 | private void initUi() {
37 | // ComboBox
38 | final JComboBox cbSpecies = new JComboBox();
39 | final JButton btDel = new JButton("Delete");
40 |
41 | cbSpecies.setPreferredSize(new Dimension(160, 28));
42 | for (String speciesName : MainData.getSpeciesNames()) {
43 | cbSpecies.addItem(speciesName);
44 | }
45 |
46 | getContentPane().add(cbSpecies);
47 | getContentPane().add(btDel);
48 |
49 | // Button
50 | btDel.addActionListener(new ActionListener() {
51 | public void actionPerformed(ActionEvent e) {
52 | if (null == cbSpecies.getSelectedItem()) {
53 | return;
54 | }
55 | String delSpecies = cbSpecies.getSelectedItem().toString();
56 | // Delete Species and its File
57 | if (null != MainData.getSpeciesFile().get(delSpecies)) {
58 | MainData.getSpeciesFile().remove(delSpecies);
59 | }
60 | for(int i = MainData.getSpeciesNames().size() - 1; i>=0; i--) {
61 | if(MainData.getSpeciesNames().get(i).equalsIgnoreCase(delSpecies)) {
62 | MainData.getSpeciesNames().remove(i);
63 | }
64 | }
65 | CircView.log.error(delSpecies + " is DELETED");
66 | SpeciesDelDialog.this.dispose();
67 | }
68 |
69 | });
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/util/CloneUtils.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.util;
2 |
3 | import java.io.ByteArrayInputStream;
4 | import java.io.ByteArrayOutputStream;
5 | import java.io.ObjectInputStream;
6 | import java.io.ObjectOutputStream;
7 | import java.io.Serializable;
8 |
9 | public class CloneUtils {
10 | @SuppressWarnings("unchecked")
11 | public static T clone(T obj) {
12 | T cloneObj = null;
13 | try {
14 | // 写入字节流
15 | ByteArrayOutputStream out = new ByteArrayOutputStream();
16 | ObjectOutputStream obs = new ObjectOutputStream(out);
17 | obs.writeObject(obj);
18 | obs.close();
19 |
20 | // 分配内存,写入原始对象,生成新对象
21 | ByteArrayInputStream ios = new ByteArrayInputStream(out.toByteArray());
22 | ObjectInputStream ois = new ObjectInputStream(ios);
23 | // 返回生成的新对象
24 | cloneObj = (T) ois.readObject();
25 | ois.close();
26 | } catch (Exception e) {
27 | e.printStackTrace();
28 | }
29 | return cloneObj;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/util/Constant.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.util;
2 |
3 | import java.io.File;
4 | import java.util.TreeMap;
5 | import java.util.Vector;
6 |
7 | public class Constant {
8 | public final static String TOOL_CIRCEXPLORER = "CIRCexplorer";
9 | public final static String TOOL_CIRCRNAFINDER = "circRNA_finder";
10 | public final static String TOOL_CIRI = "CIRI";
11 | public final static String TOOL_FIND_CIRC = "find_circ";
12 | public final static String TOOL_MAPSPLICE = "Mapsplice";
13 | public final static String TOOL_UROBORUS = "UROBORUS";
14 | public final static Vector CIRCRNA_TOOLS = new Vector() {
15 | private static final long serialVersionUID = 1L;
16 |
17 | {
18 | add(TOOL_CIRCEXPLORER);
19 | add(TOOL_CIRCRNAFINDER);
20 | add(TOOL_CIRI);
21 | add(TOOL_FIND_CIRC);
22 | add(TOOL_MAPSPLICE);
23 | add(TOOL_UROBORUS);
24 | }
25 | };
26 |
27 | public final static String HUMAN_HG38 = "human (hg38)";
28 | public final static String HUMAN_HG19 = "human (hg19)";
29 | public final static String MOUSE_MM10 = "mouse (mm10)";
30 | public final static String MOUSE_MM9 = "mouse (mm9)";
31 | public final static String ZEBRAFISH = "zebrafish (zv9)";
32 | public final static String FLY = "fly (dm6)";
33 | public final static String C_ELEGANS = "c.elegans (ce10)";
34 | public final static Vector SPECIES = new Vector() {
35 | private static final long serialVersionUID = 1L;
36 | {
37 | add(HUMAN_HG38);
38 | add(HUMAN_HG19);
39 | add(MOUSE_MM10);
40 | add(MOUSE_MM9);
41 | add(ZEBRAFISH);
42 | add(FLY);
43 | add(C_ELEGANS);
44 | }
45 | };
46 |
47 | public final static String HUMAN_HG38_FILE = "annotation" + File.separator + "Human_hg38.txt";
48 | public final static String HUMAN_HG19_FILE = "annotation" + File.separator + "Human_hg19.txt";
49 | public final static String MOUSE_MM10_FILE = "annotation" + File.separator + "Mouse_mm10.txt";
50 | public final static String MOUSE_MM9_FILE = "annotation" + File.separator + "Mouse_mm9.txt";
51 | public final static String ZEBRAFISH_FILE = "annotation" + File.separator + "Zebrafish_zv9.txt";
52 | public final static String FLY_FILE = "annotation" + File.separator + "Fly_dm6.txt";
53 | public final static String C_ELEGANS_FILE = "annotation" + File.separator + "C_elegans_ce10.txt";
54 | public final static TreeMap SPECIES_FILE = new TreeMap() {
55 | private static final long serialVersionUID = 1L;
56 | {
57 | put(HUMAN_HG38, HUMAN_HG38_FILE);
58 | put(HUMAN_HG19, HUMAN_HG19_FILE);
59 | put(MOUSE_MM10, MOUSE_MM10_FILE);
60 | put(MOUSE_MM9, MOUSE_MM9_FILE);
61 | put(ZEBRAFISH, ZEBRAFISH_FILE);
62 | put(FLY, FLY_FILE);
63 | put(C_ELEGANS, C_ELEGANS_FILE);
64 | }
65 | };
66 |
67 | public final static String SEPERATER = "==>";
68 | public final static int ASSIGN_TOLERATION = 2;
69 | public final static int BP_MATCH_TOLERATE = 10;
70 | // RBP tables;
71 | public final static String RBP_TABLE_STRUCTS = "(chr varchar(10), start int, end int, rbp varchar(512), detail varchar(1024))";
72 |
73 | // MRE tables;
74 | public static final String MRE_TABLE_STRUCTS = "(chr varchar(10), start int, end int, mre varchar(512), detail varchar(1024))";
75 |
76 | // Default Database Configure
77 | public final static String DEFAULT_DB_SERVER = "127.0.0.1";
78 | public final static String DEFAULT_DB_PORT = "3306";
79 | public final static String DEFAULT_DB_USER = "root";
80 | public final static String DEFAULT_DB_PASSWD = "12345";
81 | public final static String DEFAULT_DB_NAME = "mre_rbp";
82 |
83 | // Data Configure
84 | public final static String CONFIG_FILE = "config.properties";
85 | public final static String CONFIG_DB_SERVER = "dbserver";
86 | public final static String CONFIG_DB_PORT = "dbport";
87 | public final static String CONFIG_DB_USER = "dbuser";
88 | public final static String CONFIG_DB_PASSWD = "dbpasswd";
89 | public final static String CONFIG_DB_NAME = "dbname";
90 | public final static String CONFIG_SPECIES = "species";
91 | public final static String CONFIG_CIRCRNA_TOOLS = "circrnatools";
92 |
93 | // Logfile Configure
94 | public final static String LOG_FILE = "log4j.properties";
95 | public final static String LOG4J_ROOTLOGGER = "log4j.rootLogger";
96 | public final static String LOG4J_APPENDER_CONSOLE = "log4j.appender.Console";
97 | public final static String LOG4J_APPENDER_CONSOLE_TARGET = "log4j.appender.Console.Target";
98 | public final static String LOG4J_APPENDER_CONSOLE_LAYOUT = "log4j.appender.Console.layout";
99 | public final static String LOG4J_APPENDER_CONSOLE_LAYOUT_CONV_PATT = "log4j.appender.Console.layout.ConversionPattern";
100 | public final static String LOG4J_APPENDER_FILE = "log4j.appender.File";
101 | public final static String LOG4J_APPENDER_FILE_FILE = "log4j.appender.File.File";
102 | public final static String LOG4J_APPENDER_FILE_MAXFILESIZE = "log4j.appender.File.MaxFileSize";
103 | public final static String LOG4J_APPENDER_FILE_THRESHOLD = "log4j.appender.File.Threshold";
104 | public final static String LOG4J_APPENDER_FILE_LAYOUT = "log4j.appender.File.layout";
105 | public final static String LOG4J_APPENDER_FILE_LAYOUT_CONV_PATT = "log4j.appender.File.layout.ConversionPattern";
106 |
107 | public final static String LOG4J_ROOTLOGGER_VALUE = "INFO,Console,File";
108 | public final static String LOG4J_APPENDER_CONSOLE_VALUE = "org.apache.log4j.ConsoleAppender";
109 | public final static String LOG4J_APPENDER_CONSOLE_TARGET_VALUE = "System.out";
110 | public final static String LOG4J_APPENDER_CONSOLE_LAYOUT_VALUE = "org.apache.log4j.PatternLayout";
111 | public final static String LOG4J_APPENDER_CONSOLE_LAYOUT_CONV_PATT_VALUE = "[%c] - %m%n";
112 | public final static String LOG4J_APPENDER_FILE_VALUE = "org.apache.log4j.RollingFileAppender";
113 | public final static String LOG4J_APPENDER_FILE_FILE_VALUE = "logs/circview.log";
114 | public final static String LOG4J_APPENDER_FILE_MAXFILESIZE_VALUE = "10MB";
115 | public final static String LOG4J_APPENDER_FILE_THRESHOLD_VALUE = "ALL";
116 | public final static String LOG4J_APPENDER_FILE_LAYOUT_VALUE = "org.apache.log4j.PatternLayout";
117 | public final static String LOG4J_APPENDER_FILE_LAYOUT_CONV_PATT_VALUE = "[%p] [%d{yyyy-MM-dd HH:mm:ss}][%c]%m%n";
118 |
119 | // About Content
120 | public static final String ABOUT = "Circular RNAs Viewer";
121 | public static final String VERSION = "version 1.0.0";
122 | public static final String AUTHOR = "Report bug to: gfeng@whu.edu.cn";
123 | }
124 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/util/DbConfig.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.util;
2 |
3 | public class DbConfig {
4 | public String dbServer;
5 | public String dbPort;
6 | public String dbUser;
7 | public String dbPasswd;
8 | public String dbName;
9 |
10 | public String getDbServer() {
11 | return dbServer;
12 | }
13 |
14 | public void setDbServer(String dbServer) {
15 | this.dbServer = dbServer;
16 | }
17 |
18 | public String getDbPort() {
19 | return dbPort;
20 | }
21 |
22 | public void setDbPort(String dbPort) {
23 | this.dbPort = dbPort;
24 | }
25 |
26 | public String getDbUser() {
27 | return dbUser;
28 | }
29 |
30 | public void setDbUser(String dbUser) {
31 | this.dbUser = dbUser;
32 | }
33 |
34 | public String getDbPasswd() {
35 | return dbPasswd;
36 | }
37 |
38 | public void setDbPasswd(String dbPasswd) {
39 | this.dbPasswd = dbPasswd;
40 | }
41 |
42 | public String getDbName() {
43 | return dbName;
44 | }
45 |
46 | public void setDbName(String dbName) {
47 | this.dbName = dbName;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/util/DbUtil.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.util;
2 |
3 | import java.sql.Connection;
4 | import java.sql.DriverManager;
5 | import java.sql.ResultSet;
6 | import java.sql.SQLException;
7 | import java.sql.Statement;
8 | import java.util.Vector;
9 | import java.util.regex.Matcher;
10 | import java.util.regex.Pattern;
11 |
12 | import cn.edu.whu.MainData;
13 | import cn.edu.whu.CircView;
14 |
15 | public class DbUtil {
16 | public static Connection connectDb() throws ClassNotFoundException, SQLException {
17 | String server = MainData.getDbConfig().getDbServer();
18 | String port = MainData.getDbConfig().getDbPort();
19 | String user = MainData.getDbConfig().getDbUser();
20 | String passwd = MainData.getDbConfig().getDbPasswd();
21 |
22 | String url = "jdbc:mysql://" + server + ":" + port + "?" + "user=" + user + "&password=" + passwd;
23 | CircView.log.info(url);
24 | Class.forName("com.mysql.jdbc.Driver");
25 | return (DriverManager.getConnection(url));
26 | }
27 |
28 | public static void createDb(Connection conn) throws SQLException, ClassNotFoundException {
29 | if (null == conn || conn.isClosed()) {
30 | conn = connectDb();
31 | }
32 | String sql = "create database if not exists " + MainData.getDbConfig().getDbName();
33 | CircView.log.info(sql);
34 | Statement st = conn.createStatement();
35 | st.executeUpdate(sql);
36 | }
37 |
38 | public static void useDb(Connection conn) throws ClassNotFoundException, SQLException {
39 | if (null == conn || conn.isClosed()) {
40 | conn = connectDb();
41 | }
42 | String sql = "use " + MainData.getDbConfig().getDbName();
43 | CircView.log.info(sql);
44 | Statement st = conn.createStatement();
45 | st.executeUpdate(sql);
46 | }
47 |
48 | public static void createRbpTable(Connection conn, String table) throws SQLException, ClassNotFoundException {
49 | if (null == conn || conn.isClosed()) {
50 | conn = connectDb();
51 | }
52 | String sql = "create table " + table + " " + Constant.RBP_TABLE_STRUCTS;
53 | CircView.log.info(sql);
54 | Statement st = conn.createStatement();
55 | st.executeUpdate(sql);
56 | }
57 |
58 | public static void createMreTable(Connection conn, String table) throws SQLException, ClassNotFoundException {
59 | if (null == conn || conn.isClosed()) {
60 | conn = connectDb();
61 | }
62 | String sql = "create table " + table + " " + Constant.MRE_TABLE_STRUCTS;
63 | CircView.log.info(sql);
64 | Statement st = conn.createStatement();
65 | st.executeUpdate(sql);
66 | }
67 |
68 | public static Vector selectRbp(Connection conn, String table, String chrom, Vector starts,
69 | Vector ends) throws SQLException {
70 | if (0 == starts.size()) {
71 | CircView.log.info("There is no results from " + table);
72 | return null;
73 | }
74 | Vector result = new Vector();
75 | // Sql Statement
76 | String sql = "select chr, start, end, rbp, detail from " + table + " where ";
77 | for (int i = 0; i < starts.size(); i++) {
78 | sql += "chr='" + chrom + "' and " + starts.get(i) + "<=start and end<=" + ends.get(i) + " or ";
79 | }
80 | sql = sql.substring(0, sql.length() - 3);
81 | CircView.log.info(sql);
82 | Statement stmt = conn.createStatement();
83 | ResultSet rs = stmt.executeQuery(sql);
84 | while (rs.next()) {
85 | String chr = rs.getString(1);
86 | long start = rs.getInt(2);
87 | long end = rs.getInt(3);
88 | String rbp = rs.getString(4);
89 | String detail = rs.getString(5);
90 | result.addElement(chr + "\t" + start + "\t" + end + "\t" + rbp + "\t" + detail);
91 | CircView.log.info(chr + "\t" + start + "\t" + end + "\t" + rbp + "\t" + detail);
92 | }
93 | return result;
94 | }
95 |
96 | public static Vector selectMre(Connection conn, String table, String chrom, Vector starts,
97 | Vector ends) throws SQLException {
98 | if (0 == starts.size()) {
99 | CircView.log.info("There is no results from " + table);
100 | return null;
101 | }
102 | Vector result = new Vector();
103 | // Sql Statement
104 | String sql = "select chr, start, end, mre, detail from " + table + " where ";
105 | for (int i = 0; i < starts.size(); i++) {
106 | sql += "chr='" + chrom + "' and " + starts.get(i) + "<=start and end<=" + ends.get(i) + " or ";
107 | }
108 | sql = sql.substring(0, sql.length() - 3);
109 | CircView.log.info(sql);
110 | Statement stmt = conn.createStatement();
111 | ResultSet rs = stmt.executeQuery(sql);
112 | while (rs.next()) {
113 | String chr = rs.getString(1);
114 | long start = rs.getInt(2);
115 | long end = rs.getInt(3);
116 | String rbp = rs.getString(4);
117 | String detail = rs.getString(5);
118 | result.addElement(chr + "\t" + start + "\t" + end + "\t" + rbp + "\t" + detail);
119 | CircView.log.info(chr + "\t" + start + "\t" + end + "\t" + rbp + "\t" + detail);
120 | }
121 | return result;
122 | }
123 |
124 | public static void file2Db(Connection conn, String fileName, String table) throws SQLException {
125 | if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) {
126 | CircView.log.info("Running under Windows Operating System.");
127 | fileName = fileName.replaceAll("\\\\", "\\\\\\\\");
128 | }
129 | Statement st = conn.createStatement();
130 | String sql = "load data local infile '" + fileName + "' into table " + table
131 | + " fields terminated by '\t' lines terminated by '\n'";
132 | CircView.log.info(sql);
133 | st.execute(sql);
134 |
135 | // Statement st = conn.createStatement();
136 | // File file = new File(fileName);
137 | // if (file.isFile() && file.exists()) {
138 | // try {
139 | // InputStreamReader rd = new InputStreamReader(new
140 | // FileInputStream(file));
141 | // BufferedReader reader = new BufferedReader(rd);
142 | // String lineTxt = null;
143 | // while ((lineTxt = reader.readLine()) != null) {
144 | // String[] item = lineTxt.split("\t");
145 | // String chr = item[0];
146 | // long start = Long.parseLong(item[1]);
147 | // long end = Long.parseLong(item[2]);
148 | // String miRna = item[3];
149 | // String others = item[4];
150 | // String sql = "insert into " + table + " values ('" + chr + "'," +
151 | // start + "," + end + ",'" + miRna
152 | // + "','" + others + "')";
153 | // CircView.log.info(sql);
154 | // st.execute(sql);
155 | // }
156 | // } catch (IOException e) {
157 | // CircView.log.warn(e.getMessage());
158 | // }
159 | // } else {
160 | // CircView.log.info("Can not find the file");
161 | // }
162 | }
163 |
164 | public static void dropTable(Connection conn, String table) throws ClassNotFoundException, SQLException {
165 | if (null == conn || conn.isClosed()) {
166 | conn = connectDb();
167 | }
168 | String sql = "drop table " + table;
169 | CircView.log.info(sql);
170 | Statement st = conn.createStatement();
171 | st.execute(sql);
172 | }
173 |
174 | public static void closeDb(Connection conn) throws SQLException {
175 | CircView.log.info("Database Closed");
176 | conn.close();
177 | }
178 |
179 | public static String species2TableName(String species) {
180 | String regex = "[\\W]+";
181 | Pattern pattern = Pattern.compile(regex);
182 | Matcher matcher = pattern.matcher(species);
183 | return matcher.replaceAll("_").trim();
184 | }
185 |
186 | public static boolean existTable(Connection conn, String tableName) throws ClassNotFoundException, SQLException {
187 | boolean ret = false;
188 | if (null == conn || conn.isClosed()) {
189 | conn = connectDb();
190 | }
191 | String sql = "show tables like '" + tableName + "'";
192 | // CircView.log.info(sql);
193 | Statement stmt = conn.createStatement();
194 | ResultSet rs = stmt.executeQuery(sql);
195 | while (rs.next()) {
196 | ret = true;
197 | }
198 | return ret;
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/util/EvenOddRenderer.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.util;
2 |
3 | import java.awt.Color;
4 | import java.awt.Component;
5 |
6 | import javax.swing.JTable;
7 | import javax.swing.table.DefaultTableCellRenderer;
8 | import javax.swing.table.TableCellRenderer;
9 |
10 | public class EvenOddRenderer implements TableCellRenderer {
11 |
12 | public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();
13 |
14 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
15 | int row, int column) {
16 | Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
17 | column);
18 | Color foreground, background;
19 | if (isSelected) {
20 | foreground = Color.YELLOW;
21 | background = Color.GREEN;
22 | } else {
23 | if (row % 2 == 0) {
24 | foreground = Color.GRAY;
25 | background = Color.WHITE;
26 | } else {
27 | foreground = Color.WHITE;
28 | background = Color.GRAY;
29 | }
30 | }
31 | renderer.setForeground(foreground);
32 | renderer.setBackground(background);
33 | return renderer;
34 | }
35 | }
--------------------------------------------------------------------------------
/src/cn/edu/whu/util/MyMath.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.util;
2 |
3 | import java.util.Vector;
4 |
5 | public class MyMath {
6 | public static void main(String[] args) {
7 | String[] a = { "A", "B", "C", "D", "E" };
8 | String[] res = new String[10];
9 | combine(a, 0, res, 0, 2);
10 | // for (int i = 1; i <= a.length; i++) {
11 | // System.out.println(a.length + "选" + i);
12 | // String[] res = new String[i];
13 | // combine(a, 0, res, 0, 1);
14 | // }
15 | }
16 |
17 | final static public void combine(final Object src[], final int srcIndex, final Object des[], final int desIndex,
18 | final int num) {
19 | if (desIndex >= num) {
20 | for (int i = 0; i < num; i++)
21 | System.out.print(des[i] + " ");
22 | System.out.println();
23 | } else
24 | for (int ap = srcIndex; ap < src.length; ap++) {
25 | des[desIndex] = src[ap];
26 | combine(src, ap + 1, des, desIndex + 1, num);
27 | }
28 | }
29 |
30 | final static public void getNfromM(final Vector src, final int srcIndex, final Vector des,
31 | final int desIndex, final int num) {
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/util/RuntimeUtils.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.util;
2 |
3 | public class RuntimeUtils {
4 | public static long getAvailableMemory() {
5 | Runtime runtime = Runtime.getRuntime();
6 | long maxMemory = runtime.maxMemory();
7 | long allocatedMemory = runtime.totalMemory();
8 | long freeMemory = runtime.freeMemory();
9 | return freeMemory + (maxMemory - allocatedMemory);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/cn/edu/whu/util/TextAreaCellRenderer.java:
--------------------------------------------------------------------------------
1 | package cn.edu.whu.util;
2 |
3 | import java.awt.Color;
4 | import java.awt.Component;
5 | import javax.swing.JTable;
6 | import javax.swing.JTextArea;
7 | import javax.swing.table.DefaultTableCellRenderer;
8 | import javax.swing.table.TableCellRenderer;
9 |
10 | public class TextAreaCellRenderer extends JTextArea implements TableCellRenderer {
11 |
12 | private static final long serialVersionUID = 1L;
13 | public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();
14 |
15 | public TextAreaCellRenderer() {
16 | setLineWrap(true);
17 | setWrapStyleWord(true);
18 | }
19 |
20 | public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
21 | int row, int column) {
22 |
23 | // Component renderer =
24 | // DEFAULT_RENDERER.getTableCellRendererComponent(table, value,
25 | // isSelected, hasFocus, row,
26 | // column);
27 | // Color foreground, background;
28 | // if (isSelected) {
29 | // foreground = Color.YELLOW;
30 | // background = Color.GREEN;
31 | // } else {
32 | // if (row % 2 == 0) {
33 | // foreground = Color.GRAY;
34 | // background = Color.WHITE;
35 | // } else {
36 | // foreground = Color.WHITE;
37 | // background = Color.GRAY;
38 | // }
39 | // }
40 | // renderer.setForeground(foreground);
41 | // renderer.setBackground(background);
42 |
43 | // 计算当下行的最佳高度
44 | int maxPreferredHeight = 0;
45 | for (int i = 0; i < table.getColumnCount(); i++) {
46 | setText("" + table.getValueAt(row, i));
47 | setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
48 | maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
49 | }
50 |
51 | if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙
52 | table.setRowHeight(row, maxPreferredHeight);
53 | setText(value == null ? "" : value.toString());
54 |
55 | return this;
56 | // return renderer;
57 | }
58 | }
--------------------------------------------------------------------------------
/testdata/human.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GeneFeng/CircView/299fde303bdde161bcf9f0cb0248d5c5faec9812/testdata/human.tar.gz
--------------------------------------------------------------------------------