1 /* $Id: Na_strand.hpp 153146 2009-02-24 16:54:29Z grichenk $
2  * ===========================================================================
3  *
4  *                            PUBLIC DOMAIN NOTICE
5  *               National Center for Biotechnology Information
6  *
7  *  This software/database is a "United States Government Work" under the
8  *  terms of the United States Copyright Act.  It was written as part of
9  *  the author's official duties as a United States Government employee and
10  *  thus cannot be copyrighted.  This software/database is freely available
11  *  to the public for use. The National Library of Medicine and the U.S.
12  *  Government have not placed any restriction on its use or reproduction.
13  *
14  *  Although all reasonable efforts have been taken to ensure the accuracy
15  *  and reliability of the software and data, the NLM and the U.S.
16  *  Government do not and cannot warrant the performance or results that
17  *  may be obtained by using this software or data. The NLM and the U.S.
18  *  Government disclaim all warranties, express or implied, including
19  *  warranties of performance, merchantability or fitness for any particular
20  *  purpose.
21  *
22  *  Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author:  Aaron Ucko, NCBI
27  *
28  * File Description:
29  *   Simple utilities for deducing directions
30  *
31  * Remark:
32  *   This code was originally generated by application DATATOOL
33  *   using specifications from the data definition file
34  *   'seqloc.asn'.
35  */
36 
37 #ifndef OBJECTS_SEQLOC_NA_STRAND_HPP
38 #define OBJECTS_SEQLOC_NA_STRAND_HPP
39 
40 
41 // generated includes
42 #include <objects/seqloc/Na_strand_.hpp>
43 
44 // generated classes
45 
46 BEGIN_NCBI_SCOPE
47 
48 BEGIN_objects_SCOPE // namespace ncbi::objects::
49 
50 /// Flag used by IsSetStrand() to switch between any/all modes.
51 enum EIsSetStrand {
52     eIsSetStrand_Any, ///< Check if any part has strand
53     eIsSetStrand_All  ///< Check if all parts have strand
54 };
55 
56 /// Used to determine the meaning of a location's Start/Stop positions.
57 /// On the minus strand the numerical values are different than the
58 /// biological ones.
59 /// @sa
60 ///   CSeq_loc::GetStart(), CSeq_loc::GetStop()
61 enum ESeqLocExtremes {
62     eExtreme_Biological,   ///< 5' and 3'
63     eExtreme_Positional    ///< numerical value
64 };
65 
66 
67 inline
IsForward(ENa_strand s)68 bool IsForward(ENa_strand s)
69 {
70     return (s == eNa_strand_plus  ||  s == eNa_strand_both);
71 }
72 
73 
74 inline
IsReverse(ENa_strand s)75 bool IsReverse(ENa_strand s)
76 {
77     // treat unknown as forward
78     return (s == eNa_strand_minus  ||  s == eNa_strand_both_rev);
79 }
80 
81 
82 inline
SameOrientation(ENa_strand a,ENa_strand b)83 bool SameOrientation(ENa_strand a, ENa_strand b)
84 {
85     return IsReverse(a) == IsReverse(b);
86 }
87 
88 
89 inline
Reverse(ENa_strand s)90 ENa_strand Reverse(ENa_strand s)
91 {
92     switch ( s ) {
93     case eNa_strand_unknown:  // defaults to plus
94     case eNa_strand_plus:
95         return eNa_strand_minus;
96     case eNa_strand_minus:
97         return eNa_strand_plus;
98     case eNa_strand_both:
99         return eNa_strand_both_rev;
100     case eNa_strand_both_rev:
101         return eNa_strand_both;
102     default:
103         return s;
104     }
105 }
106 
107 
108 END_objects_SCOPE // namespace ncbi::objects::
109 
110 END_NCBI_SCOPE
111 
112 #endif // OBJECTS_SEQLOC_NA_STRAND_HPP
113 /* Original file checksum: lines: 63, chars: 1928, CRC32: 1071d9d3 */
114