22 |
|
char resIDstr[6]; |
23 |
|
char buf[150]; |
24 |
|
double pos[3]; |
25 |
< |
char aType[4]; |
25 |
> |
char aType[5]; |
26 |
> |
char aBase[2]; |
27 |
|
char resName[3]; |
28 |
|
int id, resID, ta; |
29 |
|
VDWAtom* atom; |
57 |
|
|
58 |
|
atom->setPos(pos); |
59 |
|
|
60 |
< |
memset(aType, 0, 4 * sizeof(char)); |
61 |
< |
strncpy(aType, buf + 12, 3); |
62 |
< |
printf("string in aType = %s\n", aType); |
63 |
< |
atom->setType(aType); |
60 |
> |
memset(aType, 0, 5 * sizeof(char)); |
61 |
> |
strncpy(aType, buf + 12, 4); |
62 |
> |
memset(aBase, 0, 2 * sizeof(char)); |
63 |
> |
strncpy(aBase, buf + 13, 1); |
64 |
> |
|
65 |
> |
atom->setType(TrimSpaces(aType)); |
66 |
> |
atom->setBase(TrimSpaces(aBase)); |
67 |
|
|
68 |
|
memset(resName, 0, 3 * sizeof(char)); |
69 |
|
strncpy(resName, buf + 17, 2); |
76 |
|
|
77 |
|
theAtoms.push_back(atom); |
78 |
|
|
75 |
– |
printf("%s\t%lf\t%lf\t%lf\n", atom->getType(), pos[0], pos[1], pos[2]); |
76 |
– |
|
79 |
|
} |
80 |
|
} // while |
81 |
|
return theAtoms; |
96 |
|
} |
97 |
|
return ta; |
98 |
|
} |
99 |
+ |
|
100 |
+ |
/** |
101 |
+ |
* Removes left and right spaces from a string |
102 |
+ |
* |
103 |
+ |
* @param str String to trim |
104 |
+ |
* |
105 |
+ |
* @return char* to the trimed string |
106 |
+ |
*/ |
107 |
+ |
char * PDBReader::TrimSpaces(char *str) { |
108 |
+ |
size_t len; |
109 |
+ |
char *right, *left; |
110 |
+ |
|
111 |
+ |
/* Trim whitespace from left side */ |
112 |
+ |
for (left = str; isspace(*left); left++); |
113 |
+ |
|
114 |
+ |
/* Trim whitespace from right side */ |
115 |
+ |
if ((len = strlen(left))) |
116 |
+ |
{ |
117 |
+ |
right = left + (len - 1); |
118 |
+ |
|
119 |
+ |
while (isspace(*right)) |
120 |
+ |
{ |
121 |
+ |
*right = '\0'; |
122 |
+ |
right--; |
123 |
+ |
} |
124 |
+ |
} |
125 |
+ |
|
126 |
+ |
/* Only do the str copy if their was spaces to the left */ |
127 |
+ |
if (left != str) |
128 |
+ |
strcpy(str, left); |
129 |
+ |
|
130 |
+ |
return (str); |
131 |
+ |
} |