OSCR

A Bond-Level Sequence Framework for Molecular Representation Learning with Structural Constraints.

Code ↔ Paper

3 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

3 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.

The 3 matches · 1 of them tie a paragraph to a whole file without given lines: a weak match, whose lines are not tinted
  1. [1] § 3. Materials and Methods › 3.2. Materials › 3.2.2. Implementation Details ↔ utils/config.py, the whole file · a weak match · score 0.57 · masking ratios, hyperparameters, schedules, triplet, seeds, layer · block oscr:b:HRHXYXWDA9CDX-V · Report a mismatch
  2. [2] § 3. Materials and Methods › 3.1. Methodology › 3.1.1. Preliminary ↔ datasets/dataset.py, lines 32 to 75 · score 0.56 · formal charges, atomic, aromaticity, conjugation, ring, vector · block oscr:b:KEFMRQSXARXKP-8 · Report a mismatch
  3. [3] § 3. Materials and Methods › 3.1. Methodology › 3.1.1. Preliminary ↔ scripts/preprocess.py, lines 46 to 62 · score 0.56 · formal charges, atomic, aromaticity, conjugation, ring, vector · block oscr:b:GZFHMFV9N5J20-H · Report a mismatch

Paper

Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 152 lines · 4.3 KB · no license · 1 match

  1. # utils/config.py
  2. import os
  3. import json
  4. import time
  5. import torch
  6. class Config:
  7. seed = 202
  8. device = "cuda" if torch.cuda.is_available() else "cpu"
  9. num_workers = 0
  10. pin_memory = False
  11. # -----------------------
  12. # 1) Data
  13. # -----------------------
  14. train_csv = "data/pretrain/10K.csv"
  15. smiles_col = "SMILES"
  16. vocab_path = "data/splits/vocab_directed.json"
  17. target_cache_path = "data/pretrain/cache/data_directed.pt"
  18. max_seq_len = 64
  19. mask_ratio_1 = 0.15
  20. mask_ratio_2 = 0.30
  21. # -----------------------
  22. # 2) Model (Backbone)
  23. # -----------------------
  24. embed_dim = 256#512 #256
  25. num_heads = 32#64#32
  26. hidden_dim = 1024
  27. num_layers = 4
  28. dropout = 0.1
  29. global_attr_dim = 4
  30. adj_ratio = 0.85
  31. # -----------------------
  32. # 3) Optim / Schedule
  33. # -----------------------
  34. epochs = 20
  35. batch_size = 256
  36. lr = 1e-5
  37. weight_decay = 0.01
  38. grad_clip_norm = 5.0
  39. best_ema_beta = 0.9
  40. # -----------------------
  41. # 4) Pretrain Loss Hyperparams
  42. # -----------------------
  43. contrastive_temperature = 0.1
  44. triplet_margin = 1e-6
  45. triplet_loss_weight = 0.1
  46. # -----------------------
  47. # 5) Output
  48. # -----------------------
  49. out_root = "out/pretrain"
  50. run_name = "" # 为空则自动时间戳
  51. save_every_epochs = 1
  52. resume = True
  53. log_every_steps = 50
  54. # -----------------------
  55. # 6) Finetune (Classification)
  56. # -----------------------
  57. ft_dataset_name = "tox21"
  58. ft_data_root = "data/finetune"
  59. ft_epochs = 50
  60. ft_batch_size = 32
  61. ft_lr = 2e-5
  62. ft_encoder_lr_ratio = 0.05
  63. ft_weight_decay = 0.01
  64. ft_dropout = 0.2
  65. ft_freeze_epochs = 5
  66. unfreeze_last_n = -1
  67. ft_patience = 10
  68. ft_pos_weight_mode = "sqrt"
  69. pretrain_ckpt = "out/pretrain/best.pt"
  70. ft_vocab_path_un = "data/splits/vocab_undirected.json"
  71. ft_vocab_path_di = "data/splits/vocab_directed.json"
  72. mask_strategy = "structured" # random 或 structured
  73. use_consistency = True
  74. use_triplet = True
  75. lambda_cl = 1.0
  76. lambda_tri = 1.0
  77. # ============= 🆕 新增/修改的方法 =============
  78. @classmethod
  79. def override_from_json(cls, json_path: str) -> None:
  80. """从 JSON 文件加载参数并覆盖当前配置"""
  81. if not json_path or not os.path.exists(json_path):
  82. print(f"[Config] Warning: Config file not found: {json_path}")
  83. return
  84. print(f"[Config] Loading params from {json_path} ...")
  85. with open(json_path, "r", encoding="utf-8") as f:
  86. params = json.load(f)
  87. cls.override(params)
  88. @classmethod
  89. def override(cls, params: dict) -> None:
  90. """使用字典批量覆盖配置"""
  91. for k, v in params.items():
  92. if hasattr(cls, k):
  93. # 类型安全检查(可选):防止把 float 覆盖成 str
  94. original_val = getattr(cls, k)
  95. if isinstance(original_val, float) and isinstance(v, int):
  96. v = float(v)
  97. setattr(cls, k, v)
  98. # 只有在值真的改变时才打印,避免刷屏
  99. if str(original_val) != str(v):
  100. print(f" -> Override: {k} = {v}")
  101. else:
  102. print(f" -> [Ignore] Unknown key: {k}")
  103. @classmethod
  104. def get_run_name(cls) -> str:
  105. return cls.run_name or time.strftime("%m.%d_%H-%M-%S", time.localtime())
  106. @classmethod
  107. def get_run_dir(cls) -> str:
  108. return os.path.join(cls.out_root, cls.get_run_name())
  109. @classmethod
  110. def ensure_dirs(cls) -> str:
  111. run_dir = cls.get_run_dir()
  112. os.makedirs(run_dir, exist_ok=True)
  113. os.makedirs(os.path.join(run_dir, "ckpt"), exist_ok=True)
  114. return run_dir
  115. @classmethod
  116. def dump(cls, run_dir: str) -> None:
  117. """保存最终配置,方便复现"""
  118. cfg = {}
  119. for k, v in vars(cls).items():
  120. if k.startswith("_"): continue
  121. if callable(v) or isinstance(v, (classmethod, staticmethod)): continue
  122. try:
  123. json.dumps(v)
  124. cfg[k] = v
  125. except TypeError:
  126. cfg[k] = str(v)
  127. with open(os.path.join(run_dir, "config.json"), "w", encoding="utf-8") as f:
  128. json.dump(cfg, f, ensure_ascii=False, indent=2)

config.py at commit 5b5028e, no license · at the source

Overview

Authors: Haoran Fan1, Haoqiang Qi1, Xin Huang1,2, Dongyang Zhu1,2, Na Wang1,2, Ting Wang1,2, Hongxun Hao1,2
  1. National Engineering Research Center of Industrial Crystallization Technology, School of Chemical Engineering and Technology, Tianjin University, Tianjin 300072, China; (H.F.); (H.Q.); (X.H.); (D.Z.)
  2. Engineering Research Center of Green Refining Process, Ministry of Education, Tianjin University, Tianjin 300072, China
Institutions: Tianjin University (China)
Journal: Molecules (Basel, Switzerland), volume 31, issue 11, article 1972
Dates: received 12 May 2026; accepted 3 June 2026; published online 5 June 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.3390/molecules31111972 · PMID 42280272 · PMCID PMC13257498 · OpenAlex W7163639147
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: cellular / molecular (subfield)
Methods: Statistics, Machine learning
Keywords: molecular property prediction, transformer, bond-level representation, self-supervised learning, structural degeneracy
Topic: Computational Drug Discovery Methods (Drug Discovery, Pharmacology, Toxicology and Pharmaceutics), according to OpenAlex
Funding: National Natural Science Foundation of China (22478281, 22578314)
Citations: not cited yet (Europe PMC); 27 references in the paper

Abstract

Molecular property prediction is a fundamental task in drug discovery and materials design. While graph neural networks (GNNs) and SMILES-based Transformers have made significant strides, the former are often limited by local message-passing bottlenecks such as over-squashing, while the latter frequently lack explicit topological constraints and suffer from severe vocabulary imbalance. In this work, we revisit the granularity of molecular modeling and propose a representation learning framework built upon bond-level sequences. Our framework models molecules as sequences of directed bond tokens and introduces a structure-aware hybrid attention mechanism. By imposing hard topological constraints on a subset of attention heads to reinforce local connectivity while preserving global receptive fields in the remaining heads, the design is intended to separate short-range chemical bonding from long-range contextual dependencies. For pre-training, we implemented a multi-scale consistency learning paradigm, which utilizes an atom-centric group masking strategy to induce a hierarchical loss of local structural information and employs contrastive and triplet losses to ensure identity consistency across varying scales of structural degradation. Furthermore, by incorporating macro-scale physicochemical descriptors (e.g., LogP, TPSA) as global anchors, we examined how the inclusion of global attribute bias can provide weak physicochemical priors during pre-training, while its effect during downstream fine-tuning remains task-dependent. Experimental results demonstrate that our lightweight model, with approximately 3.5 million parameters, exhibits a dataset-dependent performance profile across MoleculeNet benchmarks and shows promising behavior on selected topology-sensitive tasks, particularly MUV. Ablation studies further analyze the contribution of bond-level connectivity, the stage-dependent dynamics of global attribute bias, structured masking, and pre-training configurations. Ultimately, this work provides an alternative representation design for molecular modeling, offering a parameter-efficient option for future molecular learning systems alongside traditional SMILES-based and graph-based formulations.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 3 matches between paragraphs and lines of code.

Haoran-Fan/bondformer

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 5b5028ee4f3b0df07ee10bc5bb9cd174b59f8366, 11 March 2026
Languages: Python (20)
Size: 30 files, 20 scripts
Software Heritage: not archived
Found in: “Data Availability Statement”
Holds: README, environment (environment.yml)
Not found: license file, CITATION.cff, tests, continuous integration, documentation
Tools: PyTorch (15 files), NumPy (6 files), pandas (5 files), RDKit (2 files), scikit-learn (2 files)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
21 files

The paper's code and data availability statement is in the Data section.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 20 scripts, each with its path and the digest of its content;
  • 3 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data Availability Statement

The source code, environment specifications, and a self-contained demonstration dataset supporting the findings of this study are publicly available in the official repository to ensure reproducibility and open access: [https://github.com/Haoran-Fan/bondformer] (accessed on 2 June 2026).

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 5 keywords, 1 funder, 8 references.

Cite

This paper

Fan, H., Qi, H., Huang, X., Zhu, D., Wang, N., Wang, T., & Hao, H. (2026). A Bond-Level Sequence Framework for Molecular Representation Learning with Structural Constraints. Molecules (Basel, Switzerland), 31(11), 1972. https://doi.org/10.3390/molecules31111972

BibTeX

@article{fan2026bond,
author = {Fan, Haoran and Qi, Haoqiang and Huang, Xin and Zhu, Dongyang and Wang, Na and Wang, Ting and Hao, Hongxun},
title = {{A Bond-Level Sequence Framework for Molecular Representation Learning with Structural Constraints}},
journal = {Molecules (Basel, Switzerland)},
year = {2026},
month = jun,
volume = {31},
number = {11},
pages = {1972},
publisher = {Multidisciplinary Digital Publishing Institute (MDPI)},
issn = {1420-3049},
doi = {10.3390/molecules31111972},
url = {https://doi.org/10.3390/molecules31111972},
pmid = {42280272},
pmcid = {PMC13257498}
}

RIS

TY - JOUR
AU - Fan, Haoran
AU - Qi, Haoqiang
AU - Huang, Xin
AU - Zhu, Dongyang
AU - Wang, Na
AU - Wang, Ting
AU - Hao, Hongxun
TI - A Bond-Level Sequence Framework for Molecular Representation Learning with Structural Constraints
T2 - Molecules (Basel, Switzerland)
J2 - Molecules
PY - 2026
DA - 2026/06/05
VL - 31
IS - 11
SP - 1972
SN - 1420-3049
PB - Multidisciplinary Digital Publishing Institute (MDPI)
DO - 10.3390/molecules31111972
UR - https://doi.org/10.3390/molecules31111972
LA - en
ER -

CSL-JSON

{
"id": "10.3390/molecules31111972",
"type": "article-journal",
"title": "A Bond-Level Sequence Framework for Molecular Representation Learning with Structural Constraints",
"container-title": "Molecules (Basel, Switzerland)",
"author": [
{
"family": "Fan",
"given": "Haoran"
},
{
"family": "Qi",
"given": "Haoqiang"
},
{
"family": "Huang",
"given": "Xin"
},
{
"family": "Zhu",
"given": "Dongyang"
},
{
"family": "Wang",
"given": "Na"
},
{
"family": "Wang",
"given": "Ting"
},
{
"family": "Hao",
"given": "Hongxun"
}
],
"container-title-short": "Molecules",
"volume": "31",
"issue": "11",
"page": "1972",
"DOI": "10.3390/molecules31111972",
"PMID": "42280272",
"PMCID": "PMC13257498",
"ISSN": "1420-3049",
"publisher": "Multidisciplinary Digital Publishing Institute (MDPI)",
"URL": "https://doi.org/10.3390/molecules31111972",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
5
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1021/jacsau.5c00289 [code]
HiCLR: Knowledge-Induced Hierarchical Contrastive Learning with Retrosynthesis Prediction Yields a Reaction Foundation Model.
Journal: JACS Au
In common: RDKit, PyTorch, scikit-learn, 2 other tools, 3 references
[2] doi:10.1002/advs.202513556 [code]
Learned Conformational Space and Pharmacophore Into Molecular Foundational Model.
Journal: Advanced science (Weinheim, Baden-Wurttemberg, Germany)
In common: RDKit, PyTorch, scikit-learn, 2 other tools, cellular / molecular, 2 references
[3] doi:10.1038/s41540-024-00401-0 [code]
A deep position-encoding model for predicting olfactory perception from molecular structures and electrostatics.
Journal: NPJ systems biology and applications
In common: RDKit, PyTorch, scikit-learn, 2 other tools, cellular / molecular, 2 references
[4] doi:10.34133/csbj.0036 [code]
HYG-mol: An Interpretable Multimodal Hypergraph Framework for Molecular Property Prediction.
Journal: Computational and structural biotechnology journal
In common: RDKit, PyTorch, scikit-learn, 2 other tools, cellular / molecular, 2 references
[5] doi:10.1038/s41467-025-66685-w [code]
Molecular Motif Learning as a pretraining objective for molecular property prediction.
Journal: Nature communications
In common: RDKit, PyTorch, scikit-learn, 2 other tools, cellular / molecular, 2 references
[6] doi:10.1186/s13321-024-00933-x [code]
Group graph: a molecular graph representation with enhanced performance, efficiency and interpretability.
Journal: Journal of cheminformatics
In common: RDKit, PyTorch, scikit-learn, 2 other tools, cellular / molecular, 2 references
[7] doi:10.1038/s41467-023-38192-3 [code]
Chemistry-intuitive explanation of graph neural networks for molecular property prediction with substructure masking.
Journal: Nature communications
In common: RDKit, PyTorch, scikit-learn, 2 other tools, cellular / molecular, 2 references
[8] doi:10.1186/s13321-025-01007-2 [code]
Prediction of blood-brain barrier and Caco-2 permeability through the Enalos Cloud Platform: combining contrastive learning and atom-attention message passing neural networks.
Journal: Journal of cheminformatics
In common: RDKit, PyTorch, scikit-learn, 2 other tools, 2 references
[9] doi:10.1021/acs.jcim.5c01888 [code]
CANDID-CNS: AI Unlocks Stereochemistry and Beyond Rule of 5 to Predict CNS Penetration of Small Molecules.
Journal: Journal of chemical information and modeling
In common: RDKit, PyTorch, scikit-learn, 2 other tools, 2 references
[10] doi:10.1021/acs.jcim.5c00724 [code]
Graph Convolutional Neural Network-Enabled Frontier Molecular Orbital Prediction: A Case Study with Neurotransmitters and Antidepressants.
Journal: Journal of chemical information and modeling
In common: RDKit, PyTorch, scikit-learn, 2 other tools, cellular / molecular, 1 reference

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.3390/molecules31111972.svg)](https://openscicode.org/badge/doi/10.3390/molecules31111972)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.3390/molecules31111972.svg
   :target: https://openscicode.org/badge/doi/10.3390/molecules31111972
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.3390/molecules31111972"><img src="https://openscicode.org/badge/doi/10.3390/molecules31111972.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.