Skip to content

Commit

Permalink
update to fix PAM length related issue (any length PAM now supported)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelecancellieri committed Mar 21, 2022
1 parent 38c2518 commit f173b0d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@

*.xlsx
*.txt
*.fa
*.bin
searchBruteForce
14 changes: 9 additions & 5 deletions sourceCode/CRISPR-Cas-Tree/mainParallel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,15 @@ void saveTST(int inizio, int fine, int part)
*ppp++;
if (!*ppp || k == 2)
{
if (counter % 3 == 0 && counter != 0)
bitNuc <<= 4;
//save two nt in each char then reset the char and k (k keep track of how many nt are already saved in the char [0/1])
fileTree.put(bitNuc);
bitNuc = 0;
k = 0;
}

bitNuc <<= 4;
// cout << "print PAM char to check dopo (" << *ppp << ")" << endl;
if (bitNuc)
bitNuc <<= 4; //if bitnuc already has one nt written, shift to write the second one

} while (*ppp);

if (targetOnDNA[i].next)
Expand Down Expand Up @@ -498,7 +498,7 @@ int main(int argc, char **argv)

int pamlen = pam.length(); //length of the total PAM: (NNNNNNNNNNNNNNNNNNNNNGG) is 23

len_guide_used = pamlen - pamlimit;

if (!pam_at_start)
{
pamRNA = pam.substr(pamlen - pamlimit, pamlimit);
Expand All @@ -508,6 +508,10 @@ int main(int argc, char **argv)
pamRNA = pam.substr(0, pamlimit); // if pam_at_start is set, then PAM = TTTNNNNNNNNNNNNNNNNNNNNN -4, i select the first 4 chars
}

pamlen=pam.length()*2; //force to input longer sequence, so it's possible to search longer guide without recreating the index
// cout<<"pamlen is "<<pamlen<<endl;
len_guide_used = pamlen - pamlimit;

// cout << "arrivo a generate\n";
// all_pam = generatePam(pamRNA); // generate a vector of each possible input pam
// cout << "faccio generate\n";
Expand Down
26 changes: 16 additions & 10 deletions sourceCode/CRISPR-Cas-Tree/searchOnTST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,20 +318,24 @@ void loadTST(string path, vector<Tnode> &albero, ifstream &fileTree, int &numNod
unsigned char mask = 0;
int k = 0;

// cout << "bit dna " << targetOnDNA[thr][i].guideDNA_bit << endl;

//read first char of PAM seq before entering the for cycle
fileTree.get(in);

for (int j = pamRNA.size() - 1; j > -1; j--)
{
if (k == 2)
if (k == 2) //when 2, one PAM char was read entirely
{
fileTree.get(in);
k = 0;
}

//if PAM size is uneven, necessary to shift the last char to read the last nt of PAM seq
if (j==0 && (pamRNA.size()%2))
in <<= 4;

mask = in & 0xF0;
in <<= 4;
//mask to read each time the correct 4bits of the char containing the PAM nt
mask = in & 0xF0;//mask with 11110000
in <<= 4;//shift to read the correct 4 bits

switch (mask)
{
Expand All @@ -341,22 +345,22 @@ void loadTST(string path, vector<Tnode> &albero, ifstream &fileTree, int &numNod
case 0x10:
targetOnDNA[thr][i].guideDNA[j] = 'A';
targetOnDNA[thr][i].guideDNA_bit[j] = bitset<4>("0001");
//cout << "A" ;
// cout << "A" <<endl;
break;
case 0x20:
targetOnDNA[thr][i].guideDNA[j] = 'C';
targetOnDNA[thr][i].guideDNA_bit[j] = bitset<4>("0010");
//cout << "C";
// cout << "C"<<endl;
break;
case 0x40:
targetOnDNA[thr][i].guideDNA[j] = 'G';
targetOnDNA[thr][i].guideDNA_bit[j] = bitset<4>("0100");
//cout << "G" ;
// cout << "G" <<endl;
break;
case 0x80:
targetOnDNA[thr][i].guideDNA[j] = 'T';
targetOnDNA[thr][i].guideDNA_bit[j] = bitset<4>("1000");
// cout << "T" ;
// cout << "T" <<endl;
break;
case 0x50: //R
targetOnDNA[thr][i].guideDNA[j] = 'R';
Expand Down Expand Up @@ -415,7 +419,9 @@ void loadTST(string path, vector<Tnode> &albero, ifstream &fileTree, int &numNod
k++;
}

// cout << "pam rna read " << targetOnDNA[thr][i].guideDNA << endl;

// std::string str(targetOnDNA[thr][i].guideDNA);
// cout << "pam rna read " << str << endl;

fileTree.get(in); // read index of next PAM with same guide

Expand Down

0 comments on commit f173b0d

Please sign in to comment.