View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2009 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-core Project
18  //
19  // SAMRead.java
20  // Since: 2010/03/15
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.bio;
26  
27  import org.utgenome.gwt.utgb.client.util.Properties;
28  
29  /**
30   * Genome Read data
31   * 
32   * @author yoshimura
33   * 
34   */
35  public class SAMRead extends SAMReadLight {
36  	private static final long serialVersionUID = 1L;
37  
38  	//schema record(qname, flag, rname, start, end, mapq, cigar, mrnm, mpos, isize, seq, qual, tag*)
39  	public String rname;
40  	public int mapq; // Mapping Quality
41  	public String mrnm; // mate reference name
42  	public int mStart; // mate start (new parameter!) 
43  	public int iSize;
44  	public String seq;
45  	public String qual;
46  	public Properties tag;
47  
48  	public String refSeq;
49  
50  	public SAMRead() {
51  		super();
52  	}
53  
54  	public SAMRead(int start, int end) {
55  		super(start, end);
56  	}
57  
58  	@Override
59  	public String toString() {
60  		StringBuilder sb = new StringBuilder();
61  
62  		sb.append("name=" + qname);
63  		sb.append(", flag=" + flag);
64  		sb.append(", start=" + start);
65  		sb.append(", mapq=" + mapq);
66  		sb.append(", cigar=" + cigar);
67  		sb.append(", iSize=" + iSize);
68  		sb.append(", tag=" + tag);
69  
70  		return sb.toString();
71  	}
72  
73  	public boolean isMate(SAMRead other) {
74  		if (this.isFirstRead()) {
75  			if (other.isSecondRead())
76  				return qname != null && qname.equals(other.qname);
77  		}
78  		else {
79  			if (other.isFirstRead())
80  				return qname != null && qname.equals(other.qname);
81  		}
82  		return false;
83  	}
84  
85  	@Override
86  	public String getSequence() {
87  		return seq;
88  	}
89  
90  	@Override
91  	public String getQV() {
92  		return qual;
93  	}
94  
95  	@Override
96  	public String getName() {
97  		return qname;
98  	}
99  
100 	@Override
101 	public boolean isSense() {
102 		return (flag & SAMReadFlag.FLAG_STRAND_OF_QUERY) == 0;
103 	}
104 
105 	@Override
106 	public boolean isAntiSense() {
107 		return !isSense();
108 	}
109 
110 	@Override
111 	public void accept(OnGenomeDataVisitor visitor) {
112 		visitor.visitSAMRead(this);
113 	}
114 
115 	public boolean mateIsMappedToTheSameChr() {
116 		return rname != null && rname.equals(mrnm);
117 	}
118 
119 }