Bio-informatics

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Bio-informatics

Bio-informatics for NEUB students
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

  1. Tutorial Question
  2. Bio-Informatics Lab
  3. Contributing
  4. License
  5. Contact
  6. Acknowledgments

Tutorial Question

Set-A

SET-A Question 1 ans:

a)False
b)True
c)True
d)True
e)false


Set-B

Set-B Question 1 ans

a)True
b)true
c)false
d)True
e)false

Bio Informatics Lab

DNA Counting

#include <bits/stdc++.h>
using namespace std;

int main(void) {
    string str;
    cin >> str;

    int len = str.size();
    int a = 0, c = 0, g = 0, t = 0;
    for(int i = 0; i<len; i++) {
        if(str[i] == 'A') a++;
        else if (str[i] == 'C') c++;
        else if (str[i] == 'G') g++;
        else if (str[i] == 'T') t++;
    }
    cout << "A: " << a << " C: " << c << " G: " << g << " T: " << t << endl;
    return 0;
}
// Sample input: ACGTATTC
//        Ouput: A: 2 C: 2 G: 1 T: 3

(back to top)

DNA complementary

#include <bits/stdc++.h>
using namespace std;

void dnaComplementary(string str) {
    int len = str.length();
    for (int i = 0; i<len; i++) {
        if(str[i] == 'A'){
            str[i] = 'T';
        }
        else if(str[i] == 'T'){
            str[i] = 'A';
        }
        else if(str[i] == 'C'){
            str[i] = 'G';
        }
        else if(str[i] == 'G'){
            str[i] = 'C';
        }
    }
    for(int i =0; i<len; i++) {
        cout << str[i];
    }
}

int main() {
    string str;
    cin >> str;
    dnaComplementary(str);

}


/*
Sample input-output:
ACGTATTC
TGCATAAG
*/

(back to top)

RNA Complementary

#include <bits/stdc++.h>
using namespace std;

void rnaComplementary(string str) {
    int len = str.length();
    for (int i = 0; i<len; i++) {
        if(str[i] == 'A'){
            str[i] = 'U';
        }
        else if(str[i] == 'U'){
            str[i] = 'A';
        }
        else if(str[i] == 'C'){
            str[i] = 'G';
        }
        else if(str[i] == 'G'){
            str[i] = 'C';
        }
    }
    for(int i =0; i<len; i++) {
        cout << str[i];
    }
}

int main() {
    string str;
    cin >> str;
    rnaComplementary(str);

}

/*
Sample input:AACGUAGGCUC
    output  :UUGCAUCCGAG
*/

(back to top)

DNA Reversal

#include <bits/stdc++.h>
using namespace std;

void dnaReversal(string str) {
    int len = str.length();
    for (int i = len; i>=0; i--){
        if(str[i] == 'A'){
            str[i] = 'T';
        }
        else if(str[i] == 'T'){
            str[i] = 'A';
        }
        else if(str[i] == 'C'){
            str[i] = 'G';
        }
        else if(str[i] == 'G'){
            str[i] = 'C';
        }
    }
    for(int i = len; i>=0; i--) {
        cout << str[i];
    }
}

int main() {
    string str;
    cin >> str;
    dnaReversal(str);

}
/*

Sample input  : AACGTAGGCTC
        output: GAGCCTACGTT
*/

(back to top)

DNA Transcription

#include <bits/stdc++.h>
using namespace std;

void transcriptDNA(string str) {
    int len = str.length();
    for (int i = 0; i<len; i++) {
                if(str[i] == 'T'){
            str[i] = 'U';
        }
    }
    for(int i =0; i<len; i++) {
        cout << str[i];
    }
}

int main() {
    string str;
    cin >> str;
    transcriptDNA(str);

}
/*

Sample input: AACGTAGGCTC
    output  : AACGUAGGCUC
*/

(back to top)

Smith WaterMan Algorithm

#include <bits/stdc++.h>
using namespace std;

int main() {
    string ls="AGCT", rs="ATGCT";
    //cin >> ls >> rs;

    int row, col;
    row = ls.length()+1;
    col = rs.length()+1;

    int data[row][col];

    for (int i = 0; i<row; i++) {
        for (int j = 0; j<col; j++) {
            data[i][j] = 0;
        }
    }
    int match = 1 ,misMatch = -1,gap = -2;
    int lef_adj = 0, up_adj = 0, dia_adj = 0;

    for (int i = 1; i<row; i++) {
        for (int j = 1; j<col; j++) {
            lef_adj = data[i-1][j] + gap;
            if(lef_adj < 0) {
                lef_adj =0;
            }

            up_adj = data[i][j-1] + gap;
            if (up_adj < 0) {
                up_adj = 0;
            }

            if(ls[i-1] == rs[j-1]) {
                dia_adj = data[i-1][j-1]+match;
            }
            else {
                dia_adj = data[i-1][j-1]+misMatch;
            }

            data[i][j] = max(lef_adj, up_adj);
            data[i][j] = max(data[i][j], dia_adj);
        }
    }

     for (int i = 0; i<row; i++) {
        for (int j = 0; j<col; j++) {
            cout << data[i][j] << " ";
        }

        cout << "\n";
    }
    return 0;
}

(back to top)

Needleman Algorithm

#include <bits/stdc++.h>
using namespace std;

int main() {
    string ls="AGCT", rs="ATGCT";

    int row, col;
    row = ls.length()+1;
    col = rs.length()+1;

    int data[row][col];

    for (int i = 0; i<row; i++) {
        for (int j = 0; j<col; j++) {
            data[i][j] = 0;
        }
    }

    for (int i = 0; i<1; i++) {
        for (int j = 1; j<col; j++) {
            data[i][j] = -j*2;
        }
    }
    for (int i = 0; i<row; i++) {
        for (int j = 0; j<1; j++) {
            data[i][j] = -i*2;
        }
    }


     for (int i = 0; i<row; i++) {
        for (int j = 0; j<col; j++) {
            cout << data[i][j] << " " ;
        }
        cout << endl;
    }


    int match = 1 ,misMatch = -1,gap = -2, lef_adj = 0, up_adj = 0, dia_adj = 0;

    for (int i = 1; i<row; i++) {
        for (int j = 1; j<col; j++) {

            lef_adj = data[i-1][j] + gap;

            up_adj = data[i][j-1] + gap;

            if(ls[i-1] == rs[j-1]) {
                 dia_adj = data[i-1][j-1]+match;
            }
            else {
                dia_adj = data[i-1][j-1]+misMatch;
            }

            data[i][j] = max(lef_adj, up_adj);
            data[i][j] = max(data[i][j], dia_adj);
        }
    }


    cout << endl;

     for (int i = 0; i<row; i++) {
        for (int j = 0; j<col; j++) {
            cout << data[i][j] << " ";
        }

        cout << "\n";
    }


    return 0;
}

(back to top)

Edit Distance

#include <bits/stdc++.h>
using namespace std;

int main(void) {

    string str1,str2;
    int row,col;

    cin >> str1>> str2;

    row = str1.length()+1;
    col = str2.length()+1;
    int data[row][col];

    for(int i=0; i<row; i++){
        data[i][0] = i;
    }

    for( int j=0; j<col; j++){
        data[0][j] = j;
    }

    int up_adj, lft_adj, dig_adj;

    for( int i=1; i<row; i++)
    {
        for(int j=1; j<col; j++)
        {
            lft_adj = data[i-1][j] ;
            up_adj = data[i][j-1];
            dig_adj = data[i-1][j-1];

            if(str1[i-1] == str2[j-1])
            {
                data[i][j]= dig_adj;
            }
            else
            {
                data[i][j] = min(lft_adj+1 ,up_adj+1 );
                data[i][j] = min(data[i][j], dig_adj+1 );
            }
        }
    }

    for(int i = 0; i<row; i++) {
        for(int j = 0; j<col; j++) {
            cout << data[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Partial Digest Problem

#include<bits/stdc++.h>
using namespace std;

int arr[100];

vector<int>delX , X, vec;

void checking(int num)
{
    int i=0, diff=0, cnt = 0;

    int lenX = X.size();

    while(i < lenX)
    {
        //compute subtraction
        diff = abs(X[i] - num);

        if(arr[diff] > 0)
        {
            cnt += 1;

            vec.push_back(diff);
        }

        i++;
    }

    if(cnt == lenX)
    {
        for(i=0; i<vec.size(); i++)
        {
            arr[vec[i]]--;
        }

        X.push_back(num);
    }

    vec.clear();
}

int main()
{
    delX = {2, 2, 3, 3, 4, 5, 6, 7, 8, 10}; // the given multi set

    int i, j, diff=0, len = delX.size();

    sort(delX.begin(), delX.end()); // sorted the multi set

    X.push_back(0);
    X.push_back(delX[len-1]); // taken X and push back first two elements

    //count each number in the del X
    for(i=0; i<len; i++)
    {
        arr[delX[i]]++;
    }

//    for(i=0; i<len; i++)
//    {
//        cout << delX[i] << " " << arr[delX[i]] << "\n";
//    }

    i = 0 , j = 0;

    while(i < delX.size())
    {
        //checked the conditions
        checking(delX[i]);

        i++;
    }

    //sort the elements of the X
    sort(X.begin(), X.end());

    for(int i=0; i<X.size(); i++)
    {
        cout << X[i] << " ";
    }

    return 0;
}

HomoMetric

#include <bits/stdc++.h>

using namespace std;

typedef long long lg;

const lg N = 9; // BIG LOOOOOOOOOL 7

// lg ar[N][N];

int
main()

{
   bool flag = true;

   lg brk, n, j, t, k, h, i, m, ah, am, a, b, c, x, count;

   cin >> count;

   lg indata[count], indata2[count];

   lg ar[count][count];

   vector < lg > v, v2;

   for (i = 0; i < count; i++)

   {
      cin >> indata[i];
   }

   for (i = 0; i < count; i++)

   {
      cin >> indata2[i];
   }

   for (i = 0; i < count; i++)

   {
      for (j = 0; j < count; j++)

      {
         if (j > i)

         {
            ar[i][j] = indata[j] - indata[i];

            v.push_back(indata[j] - indata[i]);
         } else

            ar[i][j] = -1;
      }
   }

   // for output full matrix

   cout << "1st matrix :" << endl;

   for (i = 0; i < count; i++)

   {
      for (j = 0; j < count; j++)

      {
         cout << ar[i][j] << " ";
      }

      cout << endl;
   }

   lg sz = v.size();

   sort(v.begin(), v.end());

   cout << endl;

   // for x2

   cout << "2nd x2" << endl;

   for (i = 0; i < count; i++)

   {
      for (j = 0; j < count; j++)

      {
         if (j > i)

         {
            ar[i][j] = indata2[j] - indata2[i];

            v2.push_back(indata2[j] - indata2[i]);
         } else

            ar[i][j] = -1;
      }
   }

   cout << "2nd matrix :" << endl;

   for (i = 0; i < count; i++)

   {
      for (j = 0; j < count; j++)

      {
         cout << ar[i][j] << " ";
      }

      cout << endl;
   }

   sz = v2.size();

   sort(v2.begin(), v2.end());

   cout << endl;

   cout << "X1: ";

   for (i = 0; i < sz; i++)

   {
      cout << v[i] << " ";
   }

   cout << endl;

   cout << endl;

   cout << "X2: ";

   for (i = 0; i < sz; i++)

   {
      cout << v2[i] << " ";
   }

   cout << endl;

   cout << endl;

   flag = true;

   for (i = 0; i < sz; i++)

   {
      if (v[i] != v2[i])

      {
         cout << "Its not homomatric!" << endl;

         flag = false;

         break;
      }
   }

   if (flag)
      cout << "Its homomatric!" << endl;

   return 0;
}

Author: Kopil Das

(back to top)

Getting Started

To get a local copy up and running, follow these simple steps:

Installation

This repo doesn’t rely on any external dependencies or services. You can clone the repository by running the following command in your terminal:

1.Clone the repo

git clone https://github.com/mamutalib/Bio-informatics.git

(back to top)

Contributing

Contributions to this project are greatly appreciated. If you have a suggestion that would make this project better, please fork the repo and create a pull request. You can also simply open an issue with the tag “enhancement”. Don’t forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/YourFeatureName)
  3. Commit your Changes (git commit -m 'Add some YourFeatureName)
  4. Push to the Branch (git push origin feature/YourFeatureName)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Md. Abdul Mutalib - Twitter - mutalibcse@yahoo.com

Project Link: https://github.com/mamutalib/Bio-informatics

(back to top)

Acknowledgments

I gratefully acknowledge the valuable resources and tools that have helped me in my development work. These include open source licenses, cheat sheets, shields and icons, and platforms. Thank you to the developers and organizations who have contributed to the development community.

(back to top)