<p>My question is twofold. First, I've run into an issue working with .cif files and pandas dataframes. With BioPandas, I can read a .pdb file into a dataframe and then go the opposite direction, writing a .pdb file from a dataframe. With .cif files, I can only write into a dataframe - PandasMmcif does not contain a <code>to_cif</code> function like PandasPdb has a <code>to_pdb</code> function. Are there any alternative methods I could use to get from .cif to pandas dataframe back to .cif?</p>
<p>Second, the reason I am not simply converting all of my .cif files to .pdb is that I am uncertain whether I will lose data in the conversion. Is this fear unfounded? I don't know the specific differences between .pdb and .cif.</p>

CC BY-SA 4.0
2022-09-27T07:33:27.280Z
You may lose some metadata during mmCIF <-> PDB conversion (what is converted and what is ignored depends on the converter that you use), but it's the same when you load a PDB or mmCIF file into a program, modify it and write it back – some metadata may get lost. The most essential things should be preserved. Unless you have a big mmcif file that can't be converted to a standard PDB due to the limits on the number of chains and atoms in the PDB format (there are workarounds for this used by some converters).
marcin
CC BY-SA 4.0
2022-09-27T18:19:15.740Z
Perfect, thank you!
Brookspj
CC BY-SA 4.0
2024-08-16T16:56:42.573Z
try Biopyhton https://biopython.org/docs/1.75/api/Bio.PDB.mmcifio.html  class Bio.PDB.mmcifio.MMCIFIO

    Bases: Bio.PDB.PDBIO.StructureIO

    Write a Structure object or a mmCIF dictionary as a mmCIF file.
pippo1980
<python><protein-structure><structural-biology>
Writing to .cif from BioPandas
# Writing to .cif from BioPandas

(Asked by: username_0 on 2022-09-26)

My question is twofold. First, I've run into an issue working with .cif files and pandas dataframes. With BioPandas, I can read a .pdb file into a dataframe and then go the opposite direction, writing a .pdb file from a dataframe. With .cif files, I can only write into a dataframe - PandasMmcif does not contain a `to_cif` function like PandasPdb has a `to_pdb` function. Are there any alternative methods I could use to get from .cif to pandas dataframe back to .cif?

Second, the reason I am not simply converting all of my .cif files to .pdb is that I am uncertain whether I will lose data in the conversion. Is this fear unfounded? I don't know the specific differences between .pdb and .cif.

**Tags:** python, protein-structure, structural-biology
> **Comments:**
> **username_1**: You may lose some metadata during mmCIF <-> PDB conversion (what is converted and what is ignored depends on the converter that you use), but it's the same when you load a PDB or mmCIF file into a program, modify it and write it back – some metadata may get lost. The most essential things should be preserved. Unless you have a big mmcif file that can't be converted to a standard PDB due to the limits on the number of chains and atoms in the PDB format (there are workarounds for this used by some converters).  
> **username_0**: Perfect, thank you!  
> **username_2**: try Biopyhton https://biopython.org/docs/1.75/api/Bio.PDB.mmcifio.html  class Bio.PDB.mmcifio.MMCIFIO      Bases: Bio.PDB.PDBIO.StructureIO      Write a Structure object or a mmCIF dictionary as a mmCIF file.  

---

## 0 answers

