Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 137 additions & 116 deletions ms2pip/_cython_modules/ms2pip_features_c.c
Original file line number Diff line number Diff line change
@@ -1,128 +1,149 @@
// Compute feature vectors from peptide
unsigned int* get_v_ms2pip(int peplen, unsigned short* peptide, unsigned short* modpeptide, int charge)
{
int i,j,k;
unsigned int *get_v_ms2pip(int peplen, unsigned short *peptide, unsigned short *modpeptide, int charge)
{
int i, j, k;

int fnum = 1; //first value in v is its length
int fnum = 1; // first value in v is its length

for (i=0; i < 19; i++) {
count_n[i] = 0;
count_c[i] = 0;
}
for (i = 0; i < 19; i++)
{
count_n[i] = 0;
count_c[i] = 0;
}

//I need this for Omega
//important for sptms!!
peptide_buf[0] = peptide[0];
for (i=0; i < peplen; i++) {
if (peptide[i+1] > 18) {
peptide_buf[i+1] = sptm_mapper[peptide[i+1]];
}
else {
peptide_buf[i+1] = peptide[i+1];
}
count_c[peptide_buf[i+1]]++;
}
// I need this for Omega
// important for sptms!!
peptide_buf[0] = peptide[0];
for (i = 0; i < peplen; i++)
{
if (peptide[i + 1] > 18)
{
peptide_buf[i + 1] = sptm_mapper[peptide[i + 1]];
}
else
{
peptide_buf[i + 1] = peptide[i + 1];
}
count_c[peptide_buf[i + 1]]++;
}

int num_shared = 0;
int num_shared = 0;

shared_features[num_shared++] = peplen;
shared_features[num_shared++] = charge;
shared_features[num_shared++] = peplen;
shared_features[num_shared++] = charge;

shared_features[num_shared] = 0;
if (charge == 1) {
shared_features[num_shared] = 1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge == 2) {
shared_features[num_shared] =1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge == 3) {
shared_features[num_shared] =1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge == 4) {
shared_features[num_shared] =1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge >= 5) {
shared_features[num_shared] =1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge == 1)
{
shared_features[num_shared] = 1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge == 2)
{
shared_features[num_shared] = 1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge == 3)
{
shared_features[num_shared] = 1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge == 4)
{
shared_features[num_shared] = 1;
}
num_shared++;
shared_features[num_shared] = 0;
if (charge >= 5)
{
shared_features[num_shared] = 1;
}
num_shared++;

for (j=0; j < num_props; j++) {
for (i=0; i < peplen; i++) {
props_buffer[i] = props[j][peptide_buf[i+1]];
}
qsort(props_buffer,peplen,sizeof(unsigned int),cmpfunc);
shared_features[num_shared++] = props_buffer[0];
shared_features[num_shared++] = props_buffer[(int)(0.25*(peplen-1))];
shared_features[num_shared++] = props_buffer[(int)(0.5*(peplen-1))];
shared_features[num_shared++] = props_buffer[(int)(0.75*(peplen-1))];
shared_features[num_shared++] = props_buffer[peplen-1];
}
for (j = 0; j < num_props; j++)
{
for (i = 0; i < peplen; i++)
{
props_buffer[i] = props[j][peptide_buf[i + 1]];
}
qsort(props_buffer, peplen, sizeof(unsigned int), cmpfunc);
shared_features[num_shared++] = props_buffer[0];
shared_features[num_shared++] = props_buffer[(int)(0.25 * (peplen - 1))];
shared_features[num_shared++] = props_buffer[(int)(0.5 * (peplen - 1))];
shared_features[num_shared++] = props_buffer[(int)(0.75 * (peplen - 1))];
shared_features[num_shared++] = props_buffer[peplen - 1];
}

for (i=0; i < peplen-1; i++) {
for (j=0; j<num_shared; j++) {
v[fnum++] = shared_features[j];
}
v[fnum++] = i+1; // length of N-term ion
v[fnum++] = peplen-i; // length of C-term ion
count_n[peptide_buf[i+1]]++;
count_c[peptide_buf[peplen-i]]--;
for (i = 0; i < peplen - 1; i++)
{
for (j = 0; j < num_shared; j++)
{
v[fnum++] = shared_features[j];
}
v[fnum++] = i + 1; // length of N-term ion
v[fnum++] = peplen - i; // length of C-term ion
count_n[peptide_buf[i + 1]]++;
count_c[peptide_buf[peplen - i]]--;

for (j=0; j < 19; j++) {
v[fnum++] = count_n[j]; // amino acid count in N-term ion
v[fnum++] = count_c[j]; // amino acid count in C-term ion
}
for (j = 0; j < 19; j++)
{
v[fnum++] = count_n[j]; // amino acid count in N-term ion
v[fnum++] = count_c[j]; // amino acid count in C-term ion
}

for (j=0; j < num_props; j++) {
v[fnum++] = props[j][peptide_buf[1]];
v[fnum++] = props[j][peptide_buf[peplen]];
if (i==0) {
v[fnum++] = 0;
}
else {
v[fnum++] = props[j][peptide_buf[i-1]];
}
v[fnum++] = props[j][peptide_buf[i]];
v[fnum++] = props[j][peptide_buf[i+1]];
if (i==(peplen-1)) {
v[fnum++] = 0;
}
else {
v[fnum++] = props[j][peptide_buf[i+2]];
}
unsigned int s = 0;
for (k=0; k <= i; k++) {
props_buffer[k] = props[j][peptide_buf[k+1]];
s+= props_buffer[k];
}
v[fnum++] = s;
qsort(props_buffer,i+1,sizeof(unsigned int),cmpfunc);
v[fnum++] = props_buffer[0];
v[fnum++] = props_buffer[(int)(0.25*i)];
v[fnum++] = props_buffer[(int)(0.5*i)];
v[fnum++] = props_buffer[(int)(0.75*i)];
v[fnum++] = props_buffer[i];
s = 0;
for (k=i+1; k < peplen; k++) {
props_buffer[k-i-1] = props[j][peptide_buf[k+1]];
s+= props_buffer[k-i-1];
}
v[fnum++] = s;
qsort(props_buffer,peplen-i-1,sizeof(unsigned int),cmpfunc);
v[fnum++] = props_buffer[0];
v[fnum++] = props_buffer[(int)(0.25*(peplen-i-1))];
v[fnum++] = props_buffer[(int)(0.5*(peplen-i-1))];
v[fnum++] = props_buffer[(int)(0.75*(peplen-i-1))];
v[fnum++] = props_buffer[peplen-i-2];
}
}
v[0] = fnum-1;
return v;
for (j = 0; j < num_props; j++)
{
v[fnum++] = props[j][peptide_buf[1]];
v[fnum++] = props[j][peptide_buf[peplen]];
if (i == 0)
{
v[fnum++] = 0;
}
else
{
v[fnum++] = props[j][peptide_buf[i - 1]];
}
v[fnum++] = props[j][peptide_buf[i]];
v[fnum++] = props[j][peptide_buf[i + 1]];
if (i == (peplen - 1))
{
v[fnum++] = 0;
}
else
{
v[fnum++] = props[j][peptide_buf[i + 2]];
}
unsigned int s = 0;
for (k = 0; k <= i; k++)
{
props_buffer[k] = props[j][peptide_buf[k + 1]];
s += props_buffer[k];
}
v[fnum++] = s;
qsort(props_buffer, i + 1, sizeof(unsigned int), cmpfunc);
v[fnum++] = props_buffer[0];
v[fnum++] = props_buffer[(int)(0.25 * i)];
v[fnum++] = props_buffer[(int)(0.5 * i)];
v[fnum++] = props_buffer[(int)(0.75 * i)];
v[fnum++] = props_buffer[i];
s = 0;
for (k = i + 1; k < peplen; k++)
{
props_buffer[k - i - 1] = props[j][peptide_buf[k + 1]];
s += props_buffer[k - i - 1];
}
v[fnum++] = s;
qsort(props_buffer, peplen - i - 1, sizeof(unsigned int), cmpfunc);
v[fnum++] = props_buffer[0];
v[fnum++] = props_buffer[(int)(0.25 * (peplen - i - 1))];
v[fnum++] = props_buffer[(int)(0.5 * (peplen - i - 1))];
v[fnum++] = props_buffer[(int)(0.75 * (peplen - i - 1))];
v[fnum++] = props_buffer[peplen - i - 2];
}
}
v[0] = fnum - 1;
return v;
}
Loading