Skip to content

Commit

Permalink
BLAST
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon committed Nov 17, 2024
1 parent c9dc2d8 commit d75bef9
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 57 deletions.
7 changes: 1 addition & 6 deletions algo/BLAST/BLAST_Neighborhood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

#include <string>
#include <vector>
//#include <omp.h> // not needed here, but in .cpp


#include "a4_util.h"
#include "blst_util.h"

// ... more includes here...
#include <iostream> // DEBUG
#include <stdexcept>

Expand Down Expand Up @@ -36,7 +34,6 @@ struct NHResult

class BLAST_Neighborhood
{
// do NOT change the public interface
public:
/**
Berechnet die BLAST Nachbarschaft fuer eine Query.
Expand All @@ -59,8 +56,6 @@ class BLAST_Neighborhood


private:
// your private member _functions_ go here <> (if needed)
// hint: private member _variables_ are probably not required
std::vector<char> amino_acids = {'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V'};

void generateWords(const std::string& query, int word_size, std::vector<std::string>& output);
Expand Down
12 changes: 6 additions & 6 deletions algo/BLAST/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ INC =
CXXFLAGS = -std=c++17 -Wall -pedantic -O2 -D_GLIBCXX_ASSERTIONS -g -fsanitize=address -fopenmp
# -D_GLIBCXX_DEBUG // bad for openmp performance

%.o: %.cpp a4_util.h BLAST_Neighborhood.hpp
%.o: %.cpp blst_util.h BLAST_Neighborhood.hpp
${CXX} ${CXXFLAGS} -I . -c $*.cpp


aufgabe4_main: BLAST_Neighborhood.o aufgabe4_main.o a4_util.o
${CXX} ${CXXFLAGS} -I . $^ -o aufgabe4_main
blst_main: BLAST_Neighborhood.o blst_main.o blst_util.o
${CXX} ${CXXFLAGS} -I . $^ -o blst_main

aufgabe4_test: BLAST_Neighborhood.o aufgabe4_test.o a4_util.o
${CXX} ${CXXFLAGS} -I . $^ -o aufgabe4_test

blst_test: BLAST_Neighborhood.o blst_test.o blst_util.o
${CXX} ${CXXFLAGS} -I . $^ -o blst_test

19 changes: 19 additions & 0 deletions algo/BLAST/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# BLAST

To compile and run the program:

```bash
make blst_main
./blst_main <SEQ> <SCORE_MATRIX> <WORD_SIZE> <THRESHOLD> <THREADS>
```

To test the program:

```bash
make blst_test
./blst_test
```

> [!NOTE]
> The compilation uses `-fopenmp` to enable parallelization.
> This is not supported by all compilers, e.g. by Mac's GCC.
2 changes: 1 addition & 1 deletion algo/BLAST/aufgabe4_main.cpp → algo/BLAST/blst_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, char** argv) {
int threads;

if (argc != 6) {
std::cout << "Usage: ./aufgabe4_main <SEQ> <SCORE_MATRIX> <WORD_SIZE> <THRESHOLD> <THREADS>\n";
std::cout << "Usage: ./blst_main <SEQ> <SCORE_MATRIX> <WORD_SIZE> <THRESHOLD> <THREADS>\n";
return 1;
}
query = argv[1];
Expand Down
2 changes: 1 addition & 1 deletion algo/BLAST/aufgabe4_test.cpp → algo/BLAST/blst_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <omp.h>

#include "BLAST_Neighborhood.hpp"
#include "a4_util.h"
#include "blst_util.h"

using namespace std;

Expand Down
86 changes: 43 additions & 43 deletions algo/BLAST/a4_util.cpp → algo/BLAST/blst_util.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "a4_util.h"
#include "blst_util.h"

IOException::IOException() : std::exception(), message("Failed!"), errorState(8)
{}
Expand Down Expand Up @@ -30,48 +30,48 @@ unsigned IOException::getErrorState() const
return errorState;
}


/*
* @var TranslationTableAminoAcids::CHAR_TO_INT
* @brief Mapping from residue to index.
* @signature const unsigned TranslationTableAminoAcids::CHAR_TO_INT[256];
* @note Defintion of static array must be outside of class. Use the functions toId and toAminoAcid respectively.
* @see toId();
* @see toAminoAcid();
*/
const unsigned TranslationTableAminoAcids::CHAR_TO_INT[256] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 0,
// A, B, C, D, E, F, G, H, I, J, K, L, M, N, O
12, 13, 14, 15, 16, 0, 17, 18, 0, 19, 0, 0, 0, 0, 0, 0,
// P, Q, R, S, T, U, V, W, X, Y, Z
0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 0,
// a, b, c, d, e, f, g, h, i, j, k, l, m, n, o
12, 13, 14, 15, 16, 0, 17, 18, 0, 19, 0, 0, 0, 0, 0, 0,
// p, q, r, s, t, u, v, w, x, y, z
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };


/*
* @var TranslationTableAminoAcids::INT_TO_CHAR
* @brief Mapping from index to residue.
* @signature const char TranslationTableAminoAcids::INT_TO_CHAR[TranslationTableAminoAcids::ALPHABET_SIZE];
* @note Defintion of static array must be outside of class. Use the functions toId and toAminoAcid respectively.
* @see toId();
* @see toAminoAcid();
*/
const char TranslationTableAminoAcids::INT_TO_CHAR[TranslationTableAminoAcids::ALPHABET_SIZE] =
{ 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'Y' };

/*
* @var TranslationTableAminoAcids::CHAR_TO_INT
* @brief Mapping from residue to index.
* @signature const unsigned TranslationTableAminoAcids::CHAR_TO_INT[256];
* @note Defintion of static array must be outside of class. Use the functions toId and toAminoAcid respectively.
* @see toId();
* @see toAminoAcid();
*/
const unsigned TranslationTableAminoAcids::CHAR_TO_INT[256] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 0,
// A, B, C, D, E, F, G, H, I, J, K, L, M, N, O
12, 13, 14, 15, 16, 0, 17, 18, 0, 19, 0, 0, 0, 0, 0, 0,
// P, Q, R, S, T, U, V, W, X, Y, Z
0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 8, 9, 10, 11, 0,
// a, b, c, d, e, f, g, h, i, j, k, l, m, n, o
12, 13, 14, 15, 16, 0, 17, 18, 0, 19, 0, 0, 0, 0, 0, 0,
// p, q, r, s, t, u, v, w, x, y, z
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };


/*
* @var TranslationTableAminoAcids::INT_TO_CHAR
* @brief Mapping from index to residue.
* @signature const char TranslationTableAminoAcids::INT_TO_CHAR[TranslationTableAminoAcids::ALPHABET_SIZE];
* @note Defintion of static array must be outside of class. Use the functions toId and toAminoAcid respectively.
* @see toId();
* @see toAminoAcid();
*/
const char TranslationTableAminoAcids::INT_TO_CHAR[TranslationTableAminoAcids::ALPHABET_SIZE] =
{ 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'Y' };

//==================================================================
// Member functions.
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions algo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ organization. Look at Readme's and comments in the code for more details.
- [Horspool Algorithm](./horspool)
- [Suffix Array](./suftab)
- [Alignment Challenge](./align)
- [BLAST](./BLAST)

## Languages
- Python
Expand Down

0 comments on commit d75bef9

Please sign in to comment.