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  // SAMReadFlag.java
20  // Since: May 6, 2010
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.bio;
26  
27  /**
28   * Flag bits of SAM reads
29   * 
30   * @author leo
31   * 
32   */
33  public class SAMReadFlag {
34  
35  	public static final int FLAG_PAIRED_READ = 0x001;
36  	public static final int FLAG_MAPPED_IN_A_PROPER_PAIR = 0x002;
37  	public static final int FLAG_QUERY_IS_UNMAPPED = 0x004;
38  	public static final int FLAG_MATE_IS_UNMAPPED = 0x008;
39  	public static final int FLAG_STRAND_OF_QUERY = 0x0010;
40  	public static final int FLAG_STRAND_OF_MATE = 0x0020;
41  	public static final int FLAG_IS_FIRST_READ = 0x0040;
42  	public static final int FLAG_IS_SECOND_READ = 0x0080;
43  	public static final int FLAG_NOT_PRIMARY = 0x0100;
44  	public static final int FLAG_FAILS_QUALITY_CHECK = 0x0200;
45  	public static final int FLAG_PCR_OR_OPTICAL_DUPLICATE = 0x0400;
46  
47  	public static boolean isPairedRead(int flag) {
48  		return (flag & FLAG_PAIRED_READ) != 0;
49  	}
50  
51  	public static boolean isMappedInProperPair(int flag) {
52  		return (flag & FLAG_MAPPED_IN_A_PROPER_PAIR) != 0;
53  	}
54  
55  	public static boolean isQueryUnmapped(int flag) {
56  		return (flag & FLAG_QUERY_IS_UNMAPPED) != 0;
57  	}
58  
59  	public static boolean isMateUnmapped(int flag) {
60  		return (flag & FLAG_MATE_IS_UNMAPPED) != 0;
61  	}
62  
63  	public static boolean isQueryForwardStrand(int flag) {
64  		return (flag & FLAG_STRAND_OF_QUERY) == 0;
65  	}
66  
67  	public static boolean isMateForwardStrand(int flag) {
68  		return (flag & FLAG_STRAND_OF_MATE) == 0;
69  	}
70  
71  	public static boolean isFirstRead(int flag) {
72  		return (flag & FLAG_IS_FIRST_READ) != 0;
73  	}
74  
75  	public static boolean isSecondRead(int flag) {
76  		return (flag & FLAG_IS_SECOND_READ) != 0;
77  	}
78  
79  }