-
Notifications
You must be signed in to change notification settings - Fork 9
/
Auxiliary.cpp
107 lines (92 loc) · 1.71 KB
/
Auxiliary.cpp
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
/*
Authors:
Haoyu Cheng
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
///#include <zlib.h>
#include <string.h>
#include "Auxiliary.h"
//SEQ_LENGTH记录的是read的长度
unsigned short SEQ_LENGTH = 0;
/**********************************************/
double Get_T(void)
{
struct timeval t;
gettimeofday(&t, NULL);
return t.tv_sec+t.tv_usec/1000000.0;
}
/**********************************************/
char reverseComplementChar(char c)
{
char ret;
switch (c)
{
case 'A':
ret = 'T';
break;
case 'T':
ret = 'A';
break;
case 'C':
ret = 'G';
break;
case 'G':
ret = 'C';
break;
default:
ret = 'N';
break;
}
return ret;
}
/**********************************************/
void reverseComplement (char *seq, char *rcSeq , int length)
{
int i;
for (i=0; i<length; i++)
{
rcSeq[i]=reverseComplementChar (seq[length-1-i]) ;
}
rcSeq[length] = 0;
}
/**********************************************/
void reverse (char *seq, char *rcSeq , int length)
{
int i;
int l = length;
if(l != strlen(seq))
l = strlen(seq);
for (i=0; i<l; i++)
{
rcSeq[i]=seq[l-1-i] ;
}
rcSeq[l] = '\0';
}
/**********************************************/
void stripPath(char *full, char **path, char **fileName)
{
int i;
int pos = -1;
for (i=strlen(full)-1; i>=0; i--)
{
if (full[i]=='/')
{
pos = i;
break;
}
}
if (pos != -1)
{
sprintf(*fileName, "%s%c", (full+pos+1), '\0');
full[pos+1]='\0';
sprintf(*path,"%s%c", full, '\0');
}
else
{
sprintf(*fileName, "%s%c", full, '\0');
sprintf(*path,"%c", '\0');
}
}