1 /* Copyright (c) 2009 Peter Troshin
\r
2 * Copyright (c) 2013 Alexander Sherstnev
\r
4 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
6 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
7 * Apache License version 2 as published by the Apache Software Foundation
\r
9 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
11 * License for more details.
\r
13 * A copy of the license is in apache_license.txt. It is also available here:
\r
14 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
16 * Any republication or derived work distributed in source code form
\r
17 * must include this copyright and license notice.
\r
20 package compbio.data.sequence;
\r
22 import java.util.List;
\r
23 import java.util.ArrayList;
\r
25 import javax.xml.bind.annotation.XmlAccessType;
\r
26 import javax.xml.bind.annotation.XmlAccessorType;
\r
28 import compbio.util.annotation.Immutable;
\r
29 import compbio.data.sequence.Alignment;
\r
31 * Multiple sequence alignment and Jpred prediction.
\r
33 * Does not give any guarantees on the content of individual FastaSequece
\r
34 * records. It does not guarantee neither the uniqueness of the names of
\r
35 * sequences nor it guarantees the uniqueness of the sequences.
\r
37 * @see FastaSequence
\r
38 * @see AlignmentMetadata
\r
42 * @version 1.0 September 2009
\r
45 @XmlAccessorType(XmlAccessType.FIELD)
\r
46 public final class JpredAlignment extends Alignment{
\r
48 private JpredAlignment() {
\r
49 // This has to has a default constructor for JaxB
\r
57 public JpredAlignment(List<FastaSequence> sequences, Program program, char gapchar) {
\r
58 this.sequences = sequences;
\r
59 this.metadata = new AlignmentMetadata(Program.Jpred, gapchar);
\r
67 public JpredAlignment(List<FastaSequence> sequences, AlignmentMetadata metadata) {
\r
68 this.sequences = sequences;
\r
69 this.metadata = metadata;
\r
72 private List<FastaSequence> getRealSeqs() {
\r
73 List<FastaSequence> realsequences = new ArrayList<FastaSequence>();
\r
74 for (FastaSequence s : this.sequences) {
\r
75 if (s.getId().equals("jnetpred") ||
\r
76 s.getId().equals("JNETCONF") ||
\r
77 s.getId().equals("JNETSOL25") ||
\r
78 s.getId().equals("JNETSOL5") ||
\r
79 s.getId().equals("JNETSOL0") ||
\r
80 s.getId().equals("JNETHMM") ||
\r
81 s.getId().equals("JNETHMM") ||
\r
82 s.getId().equals("JNETSOL0") ||
\r
83 s.getId().equals("JNETHMM")) {
\r
86 realsequences.add(s);
\r
89 return realsequences;
\r
93 public List<FastaSequence> getJpredSequences() {
\r
94 List<FastaSequence> realsequences = new ArrayList<FastaSequence>();
\r
95 for (FastaSequence s : this.sequences) {
\r
96 if (s.getId().equals("jnetpred") ||
\r
97 s.getId().equals("JNETCONF") ||
\r
98 s.getId().equals("JNETSOL25") ||
\r
99 s.getId().equals("JNETSOL5") ||
\r
100 s.getId().equals("JNETSOL0") ||
\r
101 s.getId().equals("JNETHMM") ||
\r
102 s.getId().equals("JNETHMM") ||
\r
103 s.getId().equals("JNETSOL0") ||
\r
104 s.getId().equals("JNETSOL0") ||
\r
105 s.getId().equals("QUERY")) {
\r
106 realsequences.add(s);
\r
109 return realsequences;
\r
113 * @return Jpred prediction
\r
115 public String getJpredPrediction() {
\r
116 for (FastaSequence s : this.sequences) {
\r
117 if (s.getId().equals("jnetpred")) {
\r
118 return s.getSequence();
\r
121 return new String("");
\r
126 * @return Jpred JNETSOL25 line
\r
128 public String getJpredSOL25() {
\r
129 for (FastaSequence s : this.sequences) {
\r
130 if (s.getId().equals("JNETSOL25")) {
\r
131 return s.getSequence();
\r
134 return new String("");
\r
139 * @return Jpred JNETSOL5 line
\r
141 public String getJpredSOL5() {
\r
142 for (FastaSequence s : this.sequences) {
\r
143 if (s.getId().equals("JNETSOL5")) {
\r
144 return s.getSequence();
\r
147 return new String("");
\r
151 * @return Jpred JNETSOL0 line
\r
153 public String getJpredSOL0() {
\r
154 for (FastaSequence s : this.sequences) {
\r
155 if (s.getId().equals("JNETSOL0")) {
\r
156 return s.getSequence();
\r
159 return new String("");
\r
163 * @return Jpred JNETCONF line
\r
165 public String getJpredJNETCONF() {
\r
166 for (FastaSequence s : this.sequences) {
\r
167 if (s.getId().equals("JNETCONF")) {
\r
168 return s.getSequence();
\r
171 return new String("");
\r
176 * @return list of FastaSequence records
\r
179 public List<FastaSequence> getSequences() {
\r
180 return this.getRealSeqs();
\r
185 * @return a number of sequence in the alignment
\r
188 public int getSize() {
\r
189 return this.getRealSeqs().size();
\r
193 * Please note that this implementation does not take the order of sequences
\r
197 public boolean equals(Object obj) {
\r
201 if (!(obj instanceof JpredAlignment)) {
\r
204 JpredAlignment al = (JpredAlignment) obj;
\r
205 if (this.getSize() != al.getSize()) {
\r
208 if (!this.getMetadata().equals(al.getMetadata())) {
\r
211 int outerCounter = 0;
\r
212 int matchCounter = 0;
\r
213 for (FastaSequence fs : getSequences()) {
\r
215 for (FastaSequence fs1 : al.getSequences()) {
\r
216 if (fs.equals(fs1)) {
\r
221 // Match for at lease one element was not found!
\r
222 if (outerCounter != matchCounter) {
\r