Skip to content

Instantly share code, notes, and snippets.

@diallobakary4
diallobakary4 / dir.py
Last active April 25, 2022 17:03
dir
# https://stackoverflow.com/questions/21542753/dir-without-built-in-methods
def vdir(obj):
return [x for x in dir(obj) if not x.startswith('__')]
#Test
#test2
print(1)
@diallobakary4
diallobakary4 / test.py
Last active April 23, 2022 17:50
test
print(11)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@diallobakary4
diallobakary4 / index.html
Created January 11, 2019 18:49
NGL@2.0.0-dev.32 - interactive/ligand-viewer
<div id="viewport" style="width:100%; height:100%;"></div>
@diallobakary4
diallobakary4 / itpsort2.py
Last active April 23, 2022 17:26
Fix the atom types names in a acpype generated itp file for Gromacs.Input: *_GMX.itp *_NEW.pdb eg: NAD_H_GMX.itp NAD_H_NEW.pdbto run: python itpsort2.py NAD_H_GMX.itp NAD_H_NEW.pdb
import os
import sys
from shutil import copyfile
"""
Fix the atom types names in a acpype generated itp file for Gromacs.
Input: *_GMX.itp *_NEW.pdb eg: NAD_H_GMX.itp NAD_H_NEW.pdb
to run: python itpsort2.py NAD_H_GMX.itp NAD_H_NEW.pdb
"""
file = sys.argv[1] #"NAD_H_GMX.itp"
pdb = sys.argv[2] # "NAD_H_NEW.pdb"
@diallobakary4
diallobakary4 / NCBI_Eutilities_Python.py
Created November 4, 2016 10:38
NCBI dataset extraction using Eutilities and Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#NCBI data extraction using Eutilities and Python
# More details "https://www.ncbi.nlm.nih.gov/books/NBK25498/
__author__ = "Bakary N'tji Diallo"
__email__ = "diallobakary4@gmail.com"
import requests
# -*- coding: utf-8 -*-
# Protein Translation Problem: Translate an RNA string into an amino acid string.
# Input: An RNA string Pattern and the array GeneticCode.
# Output: The translation of Pattern into an amino acid string Peptide.
from collections import defaultdict
import itertools
genetic_code = {'ACC': 'T', 'GCA': 'A', 'AAG': 'K', 'AAA': 'K', 'GUU': 'V', 'AAC': 'N', 'AGG': 'R',
'UGG': 'W', 'GUC': 'V', 'AGC': 'S', 'ACA': 'T', 'AGA': 'R', 'AAU': 'N', 'ACU': 'T',
# Protein Translation Problem: Translate an RNA string into an amino acid string.
# Input: An RNA string Pattern and the array GeneticCode.
# Output: The translation of Pattern into an amino acid string Peptide.
from collections import defaultdict
import itertools
Genetic_code = {'ACC': 'T', 'GCA': 'A', 'AAG': 'K', 'AAA': 'K', 'GUU': 'V', 'AAC': 'N', 'AGG': 'R',
'UGG': 'W', 'GUC': 'V', 'AGC': 'S', 'ACA': 'T', 'AGA': 'R', 'AAU': 'N', 'ACU': 'T',
'GUG': 'V', 'CAC': 'H', 'ACG': 'T', 'AGU': 'S', 'CCA': 'P', 'CAA': 'Q', 'CCC': 'P',
'UGU': 'C', 'GGU': 'G', 'UCU': 'S', 'GCG': 'A', 'CGA': 'R', 'CAG': 'Q', 'CGC': 'R',
# -*- coding: utf-8 -*-
# CODE CHALLENGE: Solve the String Composition Problem.
# Input: An integer k and a string Text.
# Output: Compositionk(Text) (the k-mers can be provided in any order).
def StringKmerCompo(sequence, kmerlenght):
compo,i =[],0
while i < (len(sequence)-kmerlenght+1):
compo.append(sequence[i:i+kmerlenght])
i+=1
@diallobakary4
diallobakary4 / Number of Each Word in a text.py
Created June 20, 2016 11:29
Count the number of each word in a text
# scrip that print the number of time a word appear in a text
#import the text file and read it
test = open("test list of word r.txt", 'r');
text = test.read();
#build a list of the words in the text
listOfWord = text.split()
# dictionnay that will contain the words