extract_str_inter.cpp 35.6 KB
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620

#include <fstream>
#include <iostream>
#include <regex>
#include <sys/stat.h>
#include <boost/algorithm/string.hpp>

#include "extract_user_ct.h"
#include "utils.h"


void extract_str(std::string STRfile, const std::vector < Rna >& rnaList_,
                 std::vector< Structure >& strs_,
                 const std::vector< std::tuple < std::pair < uint, uint >, std::pair < uint, uint >, uint > >& ctAppTwo,
                 const std::vector< std::tuple < uint, uint, uint > >& ctApp,
                 const std::vector< std::tuple < uint, uint, uint > >& ctSingle,
                 const std::vector < Interloop * >& ctIntLoop,
                 const std::vector < Hairpinloop * >& ctHairLoop,
                 const std::vector < Helix * >& ctHelix,
                 const std::vector < Multiloop * >& ctMultiLoop,
                 const std::vector < Pseudoknot * >& ctPseudo,
                 uint energyModel, uint &nbHardCT,
                 float lowerThresProbing, float upperThresProbing)
{


    std::string name = "", structure ="", energyS ="", ctString ="", line = "";
    std::vector< std::string > elements;
    std::vector < Motif * > motifs;
    //size_t tab, pos;
    std::vector < std::pair < unsigned int, unsigned int > > listBp;
    int ct = 0;
    int nbCt = 0;
    float IC = 0;
    float energy; // ADDED
    size_t j, size, k , size3;
    int nLine = 0;

    int i; // the RNA index

    struct stat buf;
    if( (stat(STRfile.c_str(), &buf) == 0))
    {
        nLine = 1;
        std::ifstream ifs(STRfile);
        while (std::getline(ifs, line))
        {
            if (line[0] != '\n' and line != "") // No header
            {
                // check the format
                elements.clear();
                boost::split( elements, line, boost::is_any_of(" \t"), boost::token_compress_on );

                if((int(elements.size()) >= 2 and (energyModel == 1 or energyModel == 2)) or (int(elements.size()) >= 3 and energyModel == 0)) // Name \space Structure \space (CT optional) -OR- Name \space Structure \space Energy \space (CT optional)
                {
                    energyS = "";
                    ctString = "";
                    // Recover RNA index
                    name = elements[0];
                    i = -1;
                    for (j = 0, size = rnaList_.size(); j != size; j++)
                        if (name.compare(rnaList_[j].get_name_()) == 0)
                            i = j;
                    if ( i != -1 ) { // RNA index is ok
                        structure = elements[1];
                        if(energyModel == 0) {
                            energyS = elements[2];
                            if (uint(elements.size()) >= 4) {
                                ctString = elements[3];
                            }
                        }
                        else if (uint(elements.size()) >= 3) {
                            ctString = elements[2];
                        }

                        // Check length structure
                        if(uint(structure.size()) == rnaList_[i].get_n_()) {
                            // Check if the structure is not empty
                            if(structure.compare(std::string(rnaList_[i].get_seq_().size(), '.')) != 0) {
                                // Check base pair A-U, G-C, G-U
                                try {
                                    Structure::checkStructure(structure);
                                    listBp.clear();
                                    Structure::makeListBp(structure, listBp);
                                    std::sort(listBp.begin(), listBp.end());
                                    Structure::checkListBp(rnaList_[i].get_seq_(), listBp);
                                } catch (std::string e) {
                                    throw (std::string("Secondary structure in line " + std::to_string(nLine) +
                                            " is not valid. Please correct this input.\n" + e));
                                }

                                if (energyModel == 0) {
                                    try {
                                      energy = std::stof(energyS);
                                    }
                                    catch (std::string e) {
                                      throw (std::string("Energy of structure line " + std::to_string(nLine) +
                                      " is not valid. Please correct this input.\n"));
                                    }
                                }

                                nbCt = 0;
                                ct = 0;
                                IC = 0;
                                Structure str = Structure(int(i), rnaList_[i].get_seq_(), listBp,
                                                          ct, nbCt, int(strs_.size()), energyModel, energy,
                                                          rnaList_[i].get_probingData_(), lowerThresProbing, upperThresProbing);


                                if((energyModel == 0 and elements.size() >= 4) or (energyModel != 0 and elements.size() >= 3)) {
                                    try {
                                        if (checkIC(ctString)) {
                                            ct = std::stoi(ctString);
                                            IC += ct;
                                            nbCt++;
                                            if (ct == 100)
                                                nbHardCT++;
                                        } else {
                                            throw (std::string("Constraint of structure line " + std::to_string(nLine) +
                                                       " is not valid. Please correct this input.\n"));
                                        }
                                    } catch (std::string e) {
                                        throw (std::string("Constraint of structure line " + std::to_string(nLine) +
                                                   " is not valid. Please correct this input.\n" + e));
                                    }
                                }

                                //std::cout << "ctAppTwo"<< std::endl;
                                // Count the number of constraint the structure corresponds
                                // and count the number of hard constraint the structure doesn't correspond
                                bool hardCT = true;
                                for(j = 0, size = ctAppTwo.size(); j != size; j++) {
                                    if(std::get<0>(ctAppTwo[j]).first == uint(i) // the structure corresponds to the ct
                                            and std::get<1>(ctAppTwo[j]).first == uint(i)
                                            and std::find(listBp.begin(), listBp.end(),
                                                          std::make_pair(std::get<0>(ctAppTwo[j]).second, std::get<1>(ctAppTwo[j]).second))
                                                            != listBp.end())
                                    {
                                        IC += std::get<2>(ctAppTwo[j]);
                                        nbCt++;
                                        if (std::get<2>(ctAppTwo[j]) == 100)
                                            ct = 100;
                                    } else if (hardCT and std::get<2>(ctAppTwo[j]) == 100 // the structure corresponds to the ct and it's a hardCT
                                               and (
                                               // if same RNAs and we don't find the base pair
                                               (std::get<0>(ctAppTwo[j]).first == uint(i)
                                               and std::get<1>(ctAppTwo[j]).first == uint(i)
                                               and std::find(listBp.begin(), listBp.end(),
                                                        std::make_pair(std::get<0>(ctAppTwo[j]).second, std::get<1>(ctAppTwo[j]).second))
                                                        == listBp.end())
                                               or // if one RNA is the same and the secondary structure is in conflict with the ct
                                               (std::get<0>(ctAppTwo[j]).first == uint(i)
                                               and std::get<1>(ctAppTwo[j]).first != uint(i)
                                               and !find_bp_with_i(listBp, std::get<0>(ctAppTwo[j]).second).empty())
                                               or // same but other rna
                                               (std::get<0>(ctAppTwo[j]).first != uint(i)
                                               and std::get<1>(ctAppTwo[j]).first == uint(i)
                                               and !find_bp_with_i(listBp, std::get<1>(ctAppTwo[j]).second).empty())
                                               )){
                                        hardCT = false;
                                    }
                                }
                                //std::cout << "ctAppS"<< std::endl;
                                for(j = 0, size = ctApp.size(); j != size; j++) {
                                    if(std::get<0>(ctApp[j]) == uint(i)
                                        and !find_bp_with_i(listBp, std::get<1>(ctApp[j])).empty())
                                    {
                                        IC += std::get<2>(ctApp[j]);
                                        nbCt++;
                                        if (std::get<2>(ctApp[j]) == 100)
                                            ct = 100;
                                    } else if(hardCT and std::get<2>(ctApp[j]) == 100
                                                // same RNA but the base is single
                                                and (std::get<0>(ctApp[j]) == uint(i)
                                                   and find_bp_with_i(listBp, std::get<1>(ctApp[j])).empty())
                                              ){
                                         hardCT = false;
                                    }
                                }
                                //std::cout << "ctSingleS"<< std::endl;
                                for(j = 0, size = ctSingle.size(); j != size; j++){
                                    if((std::get<0>(ctSingle[j]) == uint(i) and !find_i_at_first(listBp, std::get<1>(ctSingle[j])))
                                            or (std::get<0>(ctSingle[j]) == uint(i) and !find_i_at_second(listBp, std::get<1>(ctSingle[j]))))
                                    {
                                        IC += std::get<2>(ctSingle[j]);
                                        nbCt++;
                                        if (std::get<2>(ctSingle[j]) == 100)
                                            ct = 100;
                                    } else if (hardCT and std::get<2>(ctSingle[j]) == 100
                                               // same RNA and the base isn't single
                                               and (std::get<0>(ctSingle[j]) == uint(i)
                                                    and !find_bp_with_i(listBp, std::get<1>(ctSingle[j])).empty())) {
                                        hardCT = false;
                                    }
                                }
                                // Determine motifs
                                //std::cout << "Motif"<< std::endl;
                                motifs = str.get_motifs_();
                                for(k = 0, size3 = motifs.size(); k != size3; k++) {
                                    if (Helix * S = dynamic_cast < Helix * > (motifs[k])) {
                                        //std::cout << "Helix"<< std::endl;
                                        for(j = 0, size = ctHelix.size(); j != size; j++) {
                                            if (S->compCt(ctHelix[j])) {
                                                IC += ctHelix[j]->getIc_();
                                                nbCt++;
                                                if (ctHelix[j]->getIc_() == 100)
                                                    ct = 100;
                                            } else if(hardCT and ctHelix[j]->getIc_() == 100) {
                                                hardCT = false;
                                            }
                                        }
                                    }
                                    else if (Interloop * I = dynamic_cast < Interloop * > (motifs[k])) {
                                        //std::cout << "Interloop"<< std::endl;
                                        for(j = 0, size = ctIntLoop.size(); j != size; j++) {
                                            if (I->compCt(ctIntLoop[j])) {
                                                IC += ctIntLoop[j]->getIc_();
                                                nbCt++;
                                                if (ctIntLoop[j]->getIc_() == 100)
                                                    ct = 100;
                                            } else if(hardCT and ctIntLoop[j]->getIc_() == 100) {
                                                hardCT = false;
                                            }
                                        }
                                    }
                                    else if (Hairpinloop * H = dynamic_cast < Hairpinloop * > (motifs[k])) {
                                        //std::cout << "Hairpin"<< std::endl;
                                        for(j = 0, size = ctHairLoop.size(); j != size; j++) {
                                            if (H->compCt(ctHairLoop[j])) {
                                                IC += ctHairLoop[j]->getIc_();
                                                nbCt++;
                                                if (ctHairLoop[j]->getIc_() == 100)
                                                    ct = 100;
                                            } else if(hardCT and ctHairLoop[j]->getIc_() == 100) {
                                                hardCT = false;
                                            }
                                        }
                                    }
                                    else if (Pseudoknot * P = dynamic_cast < Pseudoknot * > (motifs[k])) {
                                        //std::cout << "Pseudonoeud"<< std::endl;
                                        for(j = 0, size = ctPseudo.size(); j != size; j++) {
                                            if (P->compCt(ctPseudo[j])) {
                                                IC += ctPseudo[j]->getIc_();
                                                nbCt++;
                                                if (ctPseudo[j]->getIc_() == 100)
                                                    ct = 100;
                                            } else if(hardCT and ctPseudo[j]->getIc_() == 100) {
                                                hardCT = false;
                                            }
                                        }
                                    }
                                    else if (Multiloop * M = dynamic_cast < Multiloop * > (motifs[k])) {
                                        //std::cout << "Multiloop"<< std::endl;
                                        for(j = 0, size = ctMultiLoop.size(); j != size; j++) {
                                            if (M->compCt(ctMultiLoop[j])) {
                                                IC += ctMultiLoop[j]->getIc_();
                                                nbCt++;
                                                if (ctMultiLoop[j]->getIc_() == 100)
                                                    ct = 100;
                                            }  else if(hardCT and ctMultiLoop[j]->getIc_() == 100) {
                                                hardCT = false;
                                            }
                                        }
                                    }
                                }

                                // Compute IC
/*#ifdef _DEBUG
                                std::cout << "IC " << IC << " nbCt " << nbCt << std::endl;
#endif*/
                                if (nbCt != 0)
                                    IC = IC; // / float(nbCt);
                                else
                                    IC = 0; // Default confidence index is equal to 0

/*#ifdef _DEBUG
                                std::cout << "STR " << nLine << " " << IC << " " << str.get_probing_() << " " << str.get_obj1_() << std::endl;
#endif*/

                                hardCT = true; // TO IGNORE THE HARD CONSTRAINTS ASPECT, REMOVE TO GO BACK TO ORIGINAL

                                if (hardCT) {
                                    str.set_ct_(ct);
                                    str.set_nbCt_(nbCt);
                                    str.set_ic_(IC);
                                    strs_.push_back(str);
                                }
                            }
                        }
                        else
                        {
                            throw (std::string("The length of RNA " + std::to_string(i) + " is not the same of the secondary structures in line " +
                                    std::to_string(nLine) + "."));
                        }
                    } else {
                        throw (std::string("The RNA " + name + " does not exist in the fasta file. Found in structure file line " +
                                std::to_string(nLine) + "."));
                    }
                }
                else
                {
                    throw (std::string("The format of the secondary structure line " + std::to_string(nLine) +
                            " is not correct. Please look at the example inputs."));
                }
            }
            nLine++;
        }
    }
    else
    {
        throw(std::string("The file " + STRfile + " doesn't exist."));
    }
}


bool sortHelix (Helix i, Helix j) {
    return i.getI1_() < j.getI1_();
}


void extract_inter(const std::string INTfile, const std::vector < Rna >& rnaList_,
                   std::vector< SolInteraction >& inters_,
                   std::vector< std::vector < Helix > >& helices_,
                   const std::vector< std::tuple < std::pair < uint, uint >, std::pair < uint, uint >, uint > >& ctAppTwo,
                   const std::vector < Helix * >& ctHelix,
                   const std::vector < Pseudoknot * >& ctPseudo,
                   unsigned int energyModel, uint &nbHardCT,
                   float lowerThresProbing, float upperThresProbing)
{
    std::string seq = "", name1 = "", name2 = "", line = "", structure = "", energyS = "", ctString = "";
    std::vector < std::string > elements;
    std::vector < Motif * > motifs;
    unsigned int nbCt = 0;
    int rna1 = -1, rna2 = -1;
    int ct = 0;
    float IC = 0;
    float energy;
    size_t j, size, k, size2;
    std::vector< std::vector < Helix > > helicesBis;

    // Initialize helices_ vector for G2 graph
    std::vector < std::vector < uint > > combis;
    uint counter = 0;
    for(size_t rna1 = 0, size = rnaList_.size(); rna1 != size; rna1++)
        for (size_t rna2 = 0, size2 = rnaList_.size(); rna2 != size2; rna2++) {
            combis.push_back(std::vector < uint > (rnaList_.size()));
            if (rna1 < rna2) {
                helices_.push_back(std::vector < Helix > ());
                helicesBis.push_back(std::vector < Helix > ());
                combis[rna1][rna2] = counter;
                counter++;
            }
        }

    // Extract data
    struct stat buf;
    if( (stat(INTfile.c_str(), &buf) == 0))
    {
        int nLine = 1;
        std::ifstream ifs(INTfile);
        while (std::getline(ifs, line))
        {
            if (line[0] != '\n' and line != "") // No header
            {
                // Check the format
                elements = std::vector < std::string > ();
                boost::split(elements, line, boost::is_any_of(" \t"), boost::token_compress_on );

                if((energyModel == 0 and int(elements.size()) >= 4) or (energyModel != 0 and int(elements.size()) >= 3)) // Name1 \space Name2 \space Structure \space Energy \space (CT optional) -OR- Name1 \space Name2 \space Structure \space (CT optional)
                {
                    // Check RNA indexes
                    name1 = "";
                    name2 = "";
                    name1 = elements[0];
                    name2 = elements[1];
                    rna1 = -1;
                    rna2 = -1;
                    for (j = 0, size = rnaList_.size(); j != size; j++)
                        if (name1.compare(rnaList_[j].get_name_()) == 0)
                            rna1 = j;
                    for (j = 0, size = rnaList_.size(); j != size; j++)
                        if (name2.compare(rnaList_[j].get_name_()) == 0)
                            rna2 = j;

                    if ( rna1 != -1 and rna2 != -1 ) { // RNA indexes are ok

                        structure = "";
                        energyS = "";
                        ctString = "";
                        structure = elements[2];
                        if(energyModel == 0) {
                            energyS = elements[3];
                            if (elements.size() >= 5) {
                                ctString = elements[5];
                            }
                        }
                        else if (elements.size() >= 4) {
                            ctString = elements[3];
                        }

                        seq = rnaList_[rna1].get_seq_() + "&" + rnaList_[rna2].get_seq_();

                        if(int(structure.size()) == int(seq.size())) {
                            if(ctString.compare("U") != 0 and
                              structure.compare(
                              std::string(rnaList_[rna1].get_seq_().size(), '.') + "&" +
                              std::string(rnaList_[rna2].get_seq_().size(), '.')) != 0) {

                                std::vector < std::pair < unsigned int, unsigned int > > listBp;

                                try {
                                    SolInteraction::checkStructure(structure);
                                    listBp = SolInteraction::convToBP(std::string(structure));
                                    SolInteraction::checkListBp(rnaList_[rna1].get_seq_(), rnaList_[rna2].get_seq_(), listBp);
                                } catch (std::string e) {
                                    throw (std::string("Interaction in line " + std::to_string(nLine) +
                                               " is not valid. Please correct this input.\n" + e));
                                }

                                if (energyModel == 0) {
                                    try {
                                      energy = std::stof(energyS);
                                    }
                                    catch (std::string e) {
                                      throw (std::string("Energy of interaction line " + std::to_string(nLine) +
                                      " is not valid. Please correct this input.\n"));
                                    }
                                }


                                if( int(listBp.size()) > 0 ) {

                                    nbCt = 0; //nb de contrainte
                                    ct = 0; // indice de confiance de l'interaction seule
                                    IC = 0; // indice de confiance de l'interaction seule + ct du fichier utilisateur

                                    //std::cout << "Création SolInteraction" << std::endl;
                                    SolInteraction sol = SolInteraction(rna1, rna2, rnaList_[rna1].get_seq_(),
                                                                        rnaList_[rna2].get_seq_(), listBp,
                                                                        ct, nbCt, uint(inters_.size()),
                                                                        energyModel, energy,
                                                                        rnaList_[rna1].get_probingData_(),
                                                                        rnaList_[rna2].get_probingData_(),
                                                                        lowerThresProbing, upperThresProbing);
                                    //std::cout << "Fin création SolInteraction" << std::endl;

                                    // If constraint
                                    if((energyModel == 0 and elements.size() >= 5) or (energyModel != 0 and elements.size() >= 4)) {
                                        try {
                                            if (checkIC(ctString)) {
                                                ct = std::stoi(ctString);
                                                IC += ct;
                                                nbCt++;
                                                if (ct == 100)
                                                    nbHardCT++;
                                            } else {
                                                throw (std::string("Constraint of interaction line " + std::to_string(nLine) +
                                                           " is not valid. Please correct this input.\n"));
                                            }
                                        } catch (std::string e) {
                                            throw (std::string("Constraint of interaction line " + std::to_string(nLine) +
                                                       " is not valid. Please correct this input.\n" + e));
                                        }
                                    }

                                    //std::cout << "Apres If constraint" << std::endl;
                                    // Count the number of constraint the solInteraction corresponds
                                    // and count the number of hard constraint the structure doesn't correspond
                                    bool hardCT = true;
                                    for(j = 0, size = ctAppTwo.size(); j != size; j++) {
                                        if(std::get<0>(ctAppTwo[j]).first == rna1
                                                and std::get<1>(ctAppTwo[j]).first == rna2
                                                and std::find(listBp.begin(), listBp.end(),
                                                              std::make_pair(std::get<0>(ctAppTwo[j]).second,
                                                                             std::get<1>(ctAppTwo[j]).second)) != listBp.end())
                                        {
                                            //std::cout << "ctAppTwo add dans inter" << std::endl;
                                            IC += std::get<2>(ctAppTwo[j]);
                                            nbCt++;
                                            if (std::get<2>(ctAppTwo[j]) == 100)
                                                ct = 100;
                                        } else if (hardCT and std::get<2>(ctAppTwo[j]) == 100
                                                   and (
                                                       // if same RNAs and we don't find the base pair
                                                       (std::get<0>(ctAppTwo[j]).first == rna1
                                                       and std::get<1>(ctAppTwo[j]).first == rna2
                                                       and std::find(listBp.begin(), listBp.end(),
                                                                std::make_pair(std::get<0>(ctAppTwo[j]).second, std::get<1>(ctAppTwo[j]).second))
                                                                == listBp.end())
                                                       or // if one RNA is the same and the secondary structure is in conflict with the ct
                                                       (std::get<0>(ctAppTwo[j]).first == rna1
                                                       and std::get<1>(ctAppTwo[j]).first != rna2
                                                       and find_i_at_first(listBp, std::get<0>(ctAppTwo[j]).second))
                                                       or // same but other rna
                                                       (std::get<0>(ctAppTwo[j]).first != rna1
                                                       and std::get<1>(ctAppTwo[j]).first == rna2
                                                       and find_i_at_second(listBp, std::get<1>(ctAppTwo[j]).second))
                                                       )){
                                                hardCT = false;
                                            }
                                    }

                                    //std::cout << "Determine the number of motifs" << std::endl;
                                    // Determine the number of motifs
                                    motifs = sol.get_motifs_();
                                    int nbHelices = 0;
                                    for(k = 0, size = motifs.size(); k != size; k++)
                                    {
                                        if (Helix * S = dynamic_cast < Helix * > (motifs[k]))
                                        {
                                            Helix s = (*S);
                                            // Recover the helices for graph G2
                                            s.setIdSolInter_(inters_.size());
                                            s.setId_(helicesBis[combis[rna1][rna2]].size());
                                            helicesBis[combis[rna1][rna2]].push_back(s);
                                            nbHelices++;
                                            //std::cout << "Inter line " << nLine << " rna1 " << rna1 << " rna2 " << rna2 << " combi "
                                              //        << combis[rna1][rna2] << " " << s.convToDP() << std::endl;
                                            // constraints
                                            for(j = 0, size2 = ctHelix.size(); j != size2; j++) {
                                                if (S->compCt(ctHelix[j])) {
                                                    IC += ctHelix[j]->getIc_();
                                                    nbCt++;
                                                    if (ctHelix[j]->getIc_() == 100)
                                                        ct = 100;
                                                } else if(hardCT and ctHelix[j]->getIc_() == 100) {
                                                    hardCT = false;
                                                }
                                            }
                                        }
                                        else if (Pseudoknot * P = dynamic_cast < Pseudoknot * > (motifs[k]))
                                        {
                                            for(j = 0, size2 = ctPseudo.size(); j != size2; j++) {
                                                if (P->compCt(ctPseudo[j]))
                                                {
                                                    IC += ctPseudo[j]->getIc_();
                                                    nbCt++;
                                                    if (ctPseudo[j]->getIc_() == 100)
                                                        ct = 100;
                                                } else if(hardCT and ctPseudo[j]->getIc_() == 100) {
                                                    hardCT = false;
                                                }
                                            }
                                        }
                                    }

                                    // Compute IC
                                    if (nbCt != 0)
                                        IC = IC;// / float(nbCt);
                                    else
                                        IC = 0; // Default confidence index is equal to 0

                                    //std::cout << "apres determine motifs" << std::endl;
#ifdef _DEBUG
                                    std::cout << "INTER " << nLine << " " << IC << " " << sol.get_probing_() << " " << sol.get_score_() << " " << sol.get_ct_() << std::endl;
                                    std::cout << sol.to_string() << std::endl;
#endif
                                    hardCT = true; // TO IGNORE THE HARD CONSTRAINTS ASPECT, REMOVE TO GO BACK TO ORIGINAL

                                    if (hardCT) { // s'il y a des hardCT et que la structure/inter ne correspond à aucune alors elle est pas dans le graphe
                                        helices_[combis[rna1][rna2]] = helicesBis[combis[rna1][rna2]];
                                        sol.set_ct_(ct);
                                        sol.set_nbCt_(nbCt);
                                        sol.set_ic_(IC);
                                        inters_.push_back(sol);
                                    } else {
                                        for(j = 0; j != nbHelices; j++)
                                            helicesBis[combis[rna1][rna2]].pop_back();
                                    }
                                    //std::cout << "Num vertex " << inters_.size() << std::endl;
                                }
                            }
                        }
                        else
                        {
                            throw (std::string("The length of the interaction of RNA " + name1 +
                                    " and RNA " + name2 + " does not correspond with the fasta file. Found line "
                                    + std::to_string(nLine) + "."));
                        }
                    } else if (rna1 == -1 and rna2 == -1) {
                        throw (std::string("The RNAs " + name1 + " and " + name2 + " do not exist in the fasta file. Found in interaction file line " +
                                std::to_string(nLine) + "."));
                    } else if (rna1 == -1) {
                        throw (std::string("The RNA " + name1 + " does not exist in the fasta file. Found in interaction file line " +
                                std::to_string(nLine) + "."));
                    } else {
                        throw (std::string("The RNA " + name2 + " does not exist in the fasta file. Found in interaction file line " +
                                std::to_string(nLine) + "."));
                    }
                }
                else
                {
                    throw (std::string("The format of the interaction file " + INTfile + " is not correct. Please look at the example inputs."));
                }

            }
            nLine++;
        }
#ifdef _DEBUG
        std::cout << "avant sort helices" << std::endl;
#endif

        // Sort Helices_ for G2 graph
        for(uint i = 0, size = helices_.size(); i != size; i++) {
#ifdef _DEBUG
            std::cout << "combi " << i << " : ";
#endif
            std::sort(helices_[i].begin(), helices_[i].end(), sortHelix);
#ifdef _DEBUG
            for (uint j = 0, size2 = helices_[i].size(); j != size2; j++)
                std::cout << helices_[i][j].getId_() << " ";
            std::cout << std::endl;
#endif
        }
    }
    else
    {
        throw (std::string("The file " + INTfile + " doesn't exist."));
    }
}