File: mutationtag.cpp

package info (click to toggle)
staden 2.0.0%2Bb11-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,584 kB
  • sloc: ansic: 240,605; tcl: 65,360; cpp: 12,854; makefile: 11,203; sh: 3,023; fortran: 2,033; perl: 63; awk: 46
file content (119 lines) | stat: -rw-r--r-- 2,888 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Copyright (c) Medical Research Council 2000. All rights reserved.
 *
 * Permission to use, copy, modify and distribute this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * this copyright and notice appears in all copies.
 *
 * This file was written as part of the Staden Package at the MRC Laboratory
 * of Molecular Biology, Hills Road, Cambridge, CB2 2QH, United Kingdom.
 *
 * MRC disclaims all warranties with regard to this software.
 *
 */


#include <cassert>
#include <cstring>           // For strcpy(), strlen(), ...
#include <cstdio>            // For sprintf()
#include <mutationtag.hpp>



//-------------
// Constructor
//-------------

MutationTag::MutationTag( const char* name )
{
   assert(name != NULL);
   assert(std::strlen(name)<5);
   m_cBaseRef      = '-';
   m_cBaseInp[0]   = '-';
   m_cBaseInp[1]   = '-';
   m_cBaseInp[2]   = '-';
   m_nStrand       = MUTLIB_STRAND_FORWARD;
   m_nSNR          = 0.0;
   m_nPosition[0]  = 0;
   m_nPosition[1]  = 0;
   m_nPosition[2]  = 0;
   m_nPosition[3]  = 0;
   m_nAmplitude[0] = 0.0;
   m_nAmplitude[1] = 0.0;
   m_nAmplitude[2] = 0.0;
   m_pComment[0]   = 0;
   m_bMarked       = false;
   m_nRow          = 0;
   m_nCol          = 0;
   Name( name );
}



//-------
// Clone
//-------

void MutationTag::Clone( const MutationTag& rhs )
{
   // Ensures proper copy of list item pointers and contained strings
   Copy( rhs );
   m_cBaseRef      = rhs.m_cBaseRef;
   m_cBaseInp[0]   = rhs.m_cBaseInp[0];
   m_cBaseInp[1]   = rhs.m_cBaseInp[1];
   m_cBaseInp[2]   = rhs.m_cBaseInp[2];
   m_nStrand       = rhs.m_nStrand;
   m_nSNR          = rhs.m_nSNR;
   m_nPosition[0]  = rhs.m_nPosition[0];
   m_nPosition[1]  = rhs.m_nPosition[1];
   m_nPosition[2]  = rhs.m_nPosition[2];
   m_nPosition[3]  = rhs.m_nPosition[3];
   m_nAmplitude[0] = rhs.m_nAmplitude[0];
   m_nAmplitude[1] = rhs.m_nAmplitude[1];
   m_nAmplitude[2] = rhs.m_nAmplitude[2];
   m_bMarked       = rhs.m_bMarked;
   m_nRow          = rhs.m_nRow;
   m_nCol          = rhs.m_nCol;
   std::strcpy( m_pName, rhs.m_pName );
   std::strcpy( m_pComment, rhs.m_pComment );
}



//---------
// Comment
//---------

const char* MutationTag::Comment()
{
    if( std::strcmp(m_pName,"HETE") == 0 )
    {
        std::sprintf( m_pComment, "%c->%c, SNR=%0.2fdB, PKD=%0.2f",
                      m_cBaseRef, m_cBaseInp[0], m_nSNR, m_nAmplitude[2] );
    }


    if( std::strcmp(m_pName,"MUTA") == 0 )
    {
        std::sprintf( m_pComment, "%c->%c, SNR=%0.2fdB",
                      m_cBaseRef, m_cBaseInp[0], m_nSNR );
    }


    // Check for overflow!
    assert(std::strlen(m_pComment)<MAX_STRING);
    return m_pComment;
}



//------
// Name
//------

void MutationTag::Name( const char* newname )
{
    assert(newname != NULL);
    assert(std::strlen(newname)==4);
    std::strcpy( m_pName, newname );
}