Skip to content

Instantly share code, notes, and snippets.

@ssorgatem
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save ssorgatem/11393500 to your computer and use it in GitHub Desktop.

Select an option

Save ssorgatem/11393500 to your computer and use it in GitHub Desktop.
#-*-coding: utf-8 -*-
import pybel
llistat_actius = "nom_del_fitxer_amb_els_actius.txt"
#el fitxer amb els actius n'ha de tenir els títols separats per canvi de línia, espai o tabulador
with open(llistat_actius) as fitxer_llista: #Obre el fitxer amb la llista
llista_actius_interessants = fitxer_llista.read().split() # En fa una llista de python
sdf_actius_interessants = pybel.Outputfile("sdf","actius_interessants.sdf") # Crea el fitxer on escriurem els actius interessants
for mol in pybel.readfile("sdf","actives_final_sanitized_filtered.sdf"): # Per cada molecula al fitxer d'actius
if mol.title in llista_actius_interessants: # Si es a la llista
sdf_actius_interessants.write(mol) # L'escriu al fitxer
sdf_actius_interessants.close()# Tanca el fitxer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment