unsigned char *mv_vectorB (int ne) { /** Allocates a vector of unsigned char elements @param[in] ne - number of elements @return the vector */ unsigned char *v; v = (unsigned char *)hlr_malloc (ne * sizeof (unsigned char)); return v; }
int *mv_vectorI (int ne) { /** Allocates a vector of int elements @param[in] ne - number of elements @return the vector */ int *v; v = (int *)hlr_malloc (ne * sizeof (int)); return v; }
double *mv_vectorD (int ne) { /** Allocates a vector of double elements @param[in] ne - number of elements @return the vector */ double *v; v = (double *)hlr_malloc (ne * sizeof (double)); return v; }
float *mv_vectorF (int ne) { /** Allocates a vector of float elements @param[in] ne - number of elements @return the vector */ float *v; v = (float *)hlr_malloc (ne * sizeof (float)); return v; }
Seqspec seqspec_create (void) { /** Create an empty Seqspec object Postcondition: the user of this routine is responsible for freeing the object returned @return the Seqspec object */ Seqspec this1 = (Seqspec)hlr_malloc (sizeof (struct Seqspec_struct)); this1->dbname = NULL; this1->seqname = NULL; this1->dbseqname = NULL; this1->begin = 0; this1->end = 0; this1->revcompF = 0; return this1; }
Seqspec seqspec_clone (Seqspec this1) { /** Create a fully independent copy of the 'this1' (including subfields)<br> Note: the user of this routine is responsible for freeing the object returned @param[in] this1 - the Seqspec object */ Seqspec seqspecp = (Seqspec)hlr_malloc (sizeof (struct Seqspec_struct)); seqspecp->dbname = hlr_strdup0 (this1->dbname); seqspecp->seqname = hlr_strdup0 (this1->seqname); seqspecp->dbseqname = hlr_strdup0 (this1->dbseqname); seqspecp->begin = this1->begin; seqspecp->end = this1->end; seqspecp->revcompF = this1->revcompF; return seqspecp; }
int main(int argc, char *argv[]) { Array breakPoints; BreakPoint *currBP; BreakPointRead *currBPR; int minNumReads, minNumUniqueOffsets, minNumReadsForKS,numPossibleOffsets; double pValueCutoffForKS; Array offsets; Array randomNumbers; double *observedOffsets; double *randomOffsets; if (argc != 6) { usage((char*) "%s <minNumReads> <minNumUniqueOffsets> " "<minNumReadsForKS> <pValueCutoffForKS> <numPossibleOffsets>", argv[0]); } minNumReads = std::atoi(argv[1]); minNumUniqueOffsets = std::atoi(argv[2]); minNumReadsForKS = std::atoi(argv[3]); pValueCutoffForKS = std::atof(argv[4]); numPossibleOffsets = std::atoi(argv[5]); bp_init("-"); offsets = arrayCreate(100, int); randomNumbers = arrayCreate(100, int); breakPoints = bp_getBreakPoints(); for (int i = 0; i < arrayMax(breakPoints); i++) { currBP = arrp(breakPoints, i, BreakPoint); arrayClear(offsets); for (int j = 0; j < arrayMax(currBP->breakPointReads); j++) { currBPR = arrp(currBP->breakPointReads, j, BreakPointRead); array(offsets, arrayMax(offsets), int) = currBPR->offset; } arraySort(offsets, (ARRAYORDERF) arrayIntcmp); arrayUniq(offsets, NULL, (ARRAYORDERF) arrayIntcmp); if (arrayMax(currBP->breakPointReads) >= minNumReads && arrayMax(currBP->breakPointReads) < minNumReadsForKS) { if (arrayMax(offsets) >= minNumUniqueOffsets) std::puts(bp_writeBreakPoint(currBP)); } else if (arrayMax(currBP->breakPointReads) >= minNumReads && arrayMax(currBP->breakPointReads) >= minNumReadsForKS) { arrayClear(randomNumbers); for (int j = 0; j < arrayMax(offsets); j++) array(randomNumbers, arrayMax(randomNumbers), int) = std::rand() % numPossibleOffsets; arraySort(randomNumbers, (ARRAYORDERF) arrayIntcmp); observedOffsets = (double *) hlr_malloc(arrayMax(offsets) * sizeof(double)); randomOffsets = (double *) hlr_malloc(arrayMax(offsets) * sizeof(double)); for (int j = 0; j < arrayMax(offsets); j++) { observedOffsets[j] = arru(offsets, j, int); randomOffsets[j] = arru(randomNumbers, j, int); } if (pValueCutoffForKS < TMath::KolmogorovTest(arrayMax(offsets), observedOffsets, arrayMax(offsets), randomOffsets, "")) std::puts(bp_writeBreakPoint(currBP)); hlr_free(observedOffsets); hlr_free(randomOffsets); } }