Hello, can you explain to me how to get the coordinates corresponding to my conformer indices? I was given the indices before, and now I would like to know how to get the corresponding coordinates. I was given a link to the GitHub repo of the coordinates:
https://github.com/sjdv1982/nucleotide-library (it contains a README)
and the following explanation:
Your conformer indices should correspond to the conformer array that you get when you concatenate the primary .npy and the extension .npy
So if primary is length X and extension is Y, then your conformer indices up to X should correspond to the primary .npy, between X and X+Y to the extension .npy, and there should be no indices above X+Y
(and it's the 0.5 A library)
I would like an explanation in French, please.
Oui. L’idée principale est la suivante :
ton indice de conformère ne pointe pas vers un seul fichier, mais vers le tableau obtenu en concaténant :
- le fichier primary
- puis le fichier extension
C’est exactement ce que dit la remarque qu’on t’a donnée, et cela correspond bien à l’organisation décrite dans le README du dépôt pour chaque motif de séquence et chaque niveau de précision. (GitHub)
Dans le dépôt, pour chaque bibliothèque, chaque motif et chaque précision, il y a notamment :
- un fichier primary :
[di/tri]nuc-<motif>.npy - un fichier extension :
[di/tri]nuc-<motif>-extension.npy(GitHub)
Comme on t’a précisé “it’s the 0.5 A library”, il faut prendre les fichiers du niveau 0.5 Å. (GitHub)
Exemples :
- dinucléotide motif
AC→dinuc-AC.npyetdinuc-AC-extension.npy - trinucléotide motif
AAC→trinuc-AAC.npyettrinuc-AAC-extension.npy
Supposons :
primarycontient X conformèresextensioncontient Y conformères
Alors l’indexation se fait sur :
all_conformers = concatenate(primary, extension)Donc :
- indices
0àX-1→ conformères dans primary - indices
XàX+Y-1→ conformères dans extension - un indice
>= X+Y→ invalide (GitHub)
Imaginons :
primarya longueur100extensiona longueur25
Alors :
- indice
0→primary[0] - indice
42→primary[42] - indice
99→primary[99] - indice
100→extension[0] - indice
107→extension[7] - indice
124→extension[24] - indice
125→ erreur, car hors limite
La règle générale est :
- si
idx < len(primary): prendreprimary[idx] - sinon : prendre
extension[idx - len(primary)]
Le README précise que les fichiers .npy contiennent uniquement les coordonnées xyz des fragments. (GitHub)
Donc, quand tu fais par exemple :
coords = primary[idx]ou
coords = extension[idx - len(primary)]coords correspond aux coordonnées du conformère associé à cet indice.
Le dépôt contient aussi des fichiers d’origines (*.origin.txt) et des fichiers d’indices dans output/. Le README précise que les fichiers dans output/ contiennent des indices qui se rapportent à l’array d’entrée de la pipeline, avec des indices commençant à 1. Ce n’est pas forcément la même chose que les indices de ton tableau concaténé primary + extension. (GitHub)
Autrement dit :
- les indices de conformères qu’on t’a donnés semblent être des indices dans le tableau concaténé
primary + extension - les fichiers
output/*-indices.txt, eux, ont une autre logique : ils référencent l’array d’entrée de la pipeline, et en indexation 1-based (GitHub)
Donc il ne faut pas mélanger ces deux systèmes d’indices.
Voici le principe :
import numpy as np
primary = np.load("dinuc-AC.npy")
extension = np.load("dinuc-AC-extension.npy")
idx = 107 # exemple
if idx < len(primary):
coords = primary[idx]
source = "primary"
local_idx = idx
elif idx < len(primary) + len(extension):
coords = extension[idx - len(primary)]
source = "extension"
local_idx = idx - len(primary)
else:
raise IndexError("Indice hors limites")
print("Source :", source)
print("Indice local :", local_idx)
print("Coordonnées :", coords)Pour retrouver les coordonnées à partir d’un indice :
-
choisis le bon motif (
AA,AC,AAC, etc.) -
prends les fichiers de la bibliothèque 0.5 Å
-
charge :
...npy= primary...-extension.npy= extension
-
considère que ton indice est dans
primary + extension -
si l’indice est avant la fin de
primary, il est dansprimary -
sinon, il est dans
extensionavec décalage delen(primary)
En une ligne :
coords = np.concatenate([primary, extension], axis=0)[idx]cela revient au même, tant que idx est bien un indice du tableau concaténé.
Si tu veux, je peux aussi te donner la même explication appliquée à un cas concret si tu me dis ton motif (AC, CAA, etc.) et un ou deux indices que tu as.