Skip to content

Adding missing public docstrings #1203

Closed

Description

@peterjc

Using the tool pydocstyle (installed with pip install pydocstyle), or its flake8 plugin equivalent (installed with pip install flake8-docstring), we can count missing docstrings:

$ pydocstyle Bio/ BioSQL/ --select D1 | grep "^        D" | cut -d "(" -f 1 | sort | uniq -c | sort -n
  12         D104: Missing docstring in public package
  21         D100: Missing docstring in public module
  60         D103: Missing docstring in public function
  96         D101: Missing docstring in public class
 271         D105: Missing docstring in magic method
 607         D102: Missing docstring in public method

or more simply using flake8:

$ flake8 Bio BioSQL --isolated --select D1 --statistics --quiet --quiet
21    D100 Missing docstring in public module
96    D101 Missing docstring in public class
607   D102 Missing docstring in public method
59    D103 Missing docstring in public function
12    D104 Missing docstring in public package
271   D105 Missing docstring in magic method

Ideally all the public facing code in Biopython would have docstrings, so it would be great to (gradually) add these where they are missing.

We can list the missed docstrings per file using a command like this:

$ flake8 Bio BioSQL --isolated --select D1 | cut -d ":" -f 1 | uniq -c
  20 Bio/bgzf.py
  28 Bio/DocSQL.py
  13 Bio/File.py
   5 Bio/MarkovModel.py
   1 Bio/MaxEntropy.py
   1 Bio/NaiveBayes.py
  12 Bio/pairwise2.py
   7 Bio/ParserSupport.py
  14 Bio/Seq.py
  17 Bio/SeqFeature.py
   6 Bio/SeqRecord.py
   3 Bio/Affy/CelFile.py
   3 Bio/Align/AlignInfo.py
   1 Bio/Align/Applications/_ClustalOmega.py
   1 Bio/Align/Applications/_Clustalw.py
   1 Bio/Align/Applications/_Dialign.py
   1 Bio/Align/Applications/_Mafft.py
   1 Bio/Align/Applications/_MSAProbs.py
   1 Bio/Align/Applications/_Muscle.py
   1 Bio/Align/Applications/_Prank.py
   1 Bio/Align/Applications/_Probcons.py
   1 Bio/Align/Applications/_TCoffee.py
   1 Bio/AlignIO/ClustalIO.py
   3 Bio/AlignIO/EmbossIO.py
   2 Bio/AlignIO/Interfaces.py
   2 Bio/AlignIO/MafIO.py
   2 Bio/AlignIO/MauveIO.py
   1 Bio/AlignIO/NexusIO.py
   3 Bio/AlignIO/PhylipIO.py
   1 Bio/AlignIO/StockholmIO.py
   9 Bio/Alphabet/__init__.py
   6 Bio/Alphabet/Reduced.py
   3 Bio/Application/__init__.py
  10 Bio/Blast/Applications.py
   1 Bio/Blast/NCBIStandalone.py
   8 Bio/Blast/ParseBlastTable.py
  13 Bio/Blast/Record.py
   1 Bio/CAPS/__init__.py
   1 Bio/Cluster/__init__.py
   2 Bio/codonalign/codonalignment.py
   2 Bio/codonalign/codonalphabet.py
   5 Bio/codonalign/codonseq.py
   1 Bio/Compass/__init__.py
  45 Bio/Crystal/__init__.py
  14 Bio/Data/CodonTable.py
  24 Bio/Emboss/Applications.py
   2 Bio/Emboss/Primer3.py
   4 Bio/Emboss/PrimerSearch.py
  35 Bio/Entrez/Parser.py
   3 Bio/ExPASy/cellosaurus.py
   3 Bio/ExPASy/Enzyme.py
   2 Bio/ExPASy/Prodoc.py
   1 Bio/ExPASy/Prosite.py
  10 Bio/ExPASy/ScanProsite.py
  21 Bio/FSSP/__init__.py
   5 Bio/FSSP/fssp_rec.py
   3 Bio/FSSP/FSSPTools.py
   1 Bio/GA/Evolver.py
   1 Bio/GA/Crossover/__init__.py
   1 Bio/GA/Crossover/GeneralPoint.py
   1 Bio/GA/Mutation/__init__.py
   1 Bio/GA/Repair/__init__.py
   1 Bio/GA/Selection/__init__.py
   1 Bio/GA/Selection/Abstract.py
   1 Bio/GenBank/__init__.py
   6 Bio/GenBank/Record.py
   2 Bio/GenBank/Scanner.py
   1 Bio/Geo/__init__.py
   3 Bio/Geo/Record.py
   3 Bio/Graphics/BasicChromosome.py
   1 Bio/Graphics/Comparative.py
   3 Bio/Graphics/Distribution.py
   1 Bio/Graphics/KGML_vis.py
   1 Bio/Graphics/GenomeDiagram/_CircularDrawer.py
   4 Bio/Graphics/GenomeDiagram/_CrossLink.py
   2 Bio/Graphics/GenomeDiagram/_LinearDrawer.py
   1 Bio/HMM/DynamicProgramming.py
   2 Bio/HMM/Trainer.py
   1 Bio/KDTree/KDTree.py
   1 Bio/KEGG/KGML/KGML_parser.py
   6 Bio/KEGG/KGML/KGML_pathway.py
   1 Bio/KEGG/Map/__init__.py
   8 Bio/motifs/__init__.py
   2 Bio/motifs/alignace.py
   3 Bio/motifs/mast.py
  13 Bio/motifs/matrix.py
   4 Bio/motifs/meme.py
   2 Bio/motifs/thresholds.py
   2 Bio/motifs/transfac.py
   1 Bio/motifs/applications/_xxmotif.py
   4 Bio/motifs/jaspar/__init__.py
   1 Bio/NeuralNetwork/__init__.py
   1 Bio/NeuralNetwork/Training.py
   1 Bio/NeuralNetwork/BackPropagation/__init__.py
   4 Bio/NeuralNetwork/BackPropagation/Layer.py
   1 Bio/NeuralNetwork/Gene/__init__.py
   2 Bio/NeuralNetwork/Gene/Schema.py
  20 Bio/Nexus/Nexus.py
   2 Bio/Nexus/Nodes.py
   5 Bio/Nexus/StandardData.py
   3 Bio/Nexus/Trees.py
   2 Bio/NMR/xpktools.py
   1 Bio/Pathway/Rep/Graph.py
   1 Bio/Pathway/Rep/MultiGraph.py
   6 Bio/PDB/AbstractPropertyMap.py
   9 Bio/PDB/Atom.py
   5 Bio/PDB/Chain.py
   6 Bio/PDB/Dice.py
   4 Bio/PDB/Entity.py
   4 Bio/PDB/Model.py
   7 Bio/PDB/NACCESS.py
   3 Bio/PDB/NeighborSearch.py
   3 Bio/PDB/PDBExceptions.py
   2 Bio/PDB/PDBIO.py
   2 Bio/PDB/Polypeptide.py
   2 Bio/PDB/PSEA.py
   9 Bio/PDB/Residue.py
   2 Bio/PDB/ResidueDepth.py
   6 Bio/PDB/Structure.py
   3 Bio/PDB/StructureBuilder.py
   1 Bio/PDB/Superimposer.py
   5 Bio/PDB/Vector.py
   1 Bio/PDB/mmCIF/__init__.py
   2 Bio/PDB/mmtf/__init__.py
   2 Bio/PDB/mmtf/DefaultParser.py
   1 Bio/PDB/QCPSuperimposer/__init__.py
  12 Bio/phenotype/phen_micro.py
   1 Bio/Phylo/_cdao_owl.py
   5 Bio/Phylo/BaseTree.py
   2 Bio/Phylo/CDAO.py
   6 Bio/Phylo/CDAOIO.py
   2 Bio/Phylo/Newick.py
   3 Bio/Phylo/NewickIO.py
   2 Bio/Phylo/NeXML.py
   6 Bio/Phylo/NeXMLIO.py
  71 Bio/Phylo/PhyloXML.py
  25 Bio/Phylo/PhyloXMLIO.py
   5 Bio/Phylo/TreeConstruction.py
   1 Bio/Phylo/Applications/_Fasttree.py
   1 Bio/Phylo/Applications/_Phyml.py
   1 Bio/Phylo/Applications/_Raxml.py
   1 Bio/Phylo/PAML/__init__.py
   4 Bio/Phylo/PAML/_paml.py
   1 Bio/Phylo/PAML/_parse_baseml.py
   1 Bio/Phylo/PAML/_parse_codeml.py
   1 Bio/Phylo/PAML/_parse_yn00.py
   1 Bio/Phylo/PAML/baseml.py
   2 Bio/Phylo/PAML/chi2.py
   1 Bio/Phylo/PAML/codeml.py
   2 Bio/Phylo/PAML/yn00.py
   4 Bio/PopGen/Async/__init__.py
   2 Bio/PopGen/FDist/__init__.py
   2 Bio/PopGen/FDist/Controller.py
   2 Bio/PopGen/GenePop/__init__.py
  13 Bio/PopGen/GenePop/Controller.py
  10 Bio/PopGen/GenePop/EasyController.py
   1 Bio/PopGen/GenePop/FileParser.py
   3 Bio/PopGen/GenePop/LargeFileParser.py
   1 Bio/PopGen/GenePop/Utils.py
   3 Bio/PopGen/SimCoal/Async.py
   2 Bio/PopGen/SimCoal/Cache.py
   2 Bio/PopGen/SimCoal/Controller.py
  12 Bio/PopGen/SimCoal/Template.py
   8 Bio/Restriction/Restriction.py
   1 Bio/Restriction/Restriction_Dictionary.py
   4 Bio/SCOP/__init__.py
   2 Bio/SCOP/Cla.py
   2 Bio/SCOP/Des.py
   2 Bio/SCOP/Dom.py
   2 Bio/SCOP/Hie.py
   6 Bio/SCOP/Raf.py
   2 Bio/SCOP/Residues.py
   2 Bio/SearchIO/_index.py
   5 Bio/SearchIO/BlatIO.py
   4 Bio/SearchIO/FastaIO.py
   9 Bio/SearchIO/_model/hit.py
  14 Bio/SearchIO/_model/hsp.py
  10 Bio/SearchIO/_model/query.py
   4 Bio/SearchIO/BlastIO/blast_tab.py
   2 Bio/SearchIO/BlastIO/blast_text.py
   5 Bio/SearchIO/BlastIO/blast_xml.py
   1 Bio/SearchIO/ExonerateIO/exonerate_cigar.py
   1 Bio/SearchIO/ExonerateIO/exonerate_text.py
   1 Bio/SearchIO/ExonerateIO/exonerate_vulgar.py
   3 Bio/SearchIO/HmmerIO/hmmer2_text.py
   1 Bio/SearchIO/HmmerIO/hmmer3_domtab.py
   3 Bio/SearchIO/HmmerIO/hmmer3_tab.py
   3 Bio/SearchIO/HmmerIO/hmmer3_text.py
  17 Bio/SeqIO/_index.py
   3 Bio/SeqIO/Interfaces.py
   1 Bio/SeqIO/PdbIO.py
   1 Bio/SeqIO/PhdIO.py
   1 Bio/SeqIO/SffIO.py
   1 Bio/SeqIO/UniprotIO.py
  12 Bio/Sequencing/Ace.py
   1 Bio/Sequencing/Phd.py
   5 Bio/Sequencing/Applications/_bwa.py
   1 Bio/Sequencing/Applications/_Novoalign.py
  15 Bio/Sequencing/Applications/_samtools.py
   2 Bio/SeqUtils/CodonUsage.py
   3 Bio/SeqUtils/IsoelectricPoint.py
   1 Bio/SeqUtils/ProtParam.py
   1 Bio/Statistics/__init__.py
  11 Bio/SubsMat/__init__.py
   4 Bio/SubsMat/FreqTable.py
   1 Bio/SVDSuperimposer/__init__.py
   4 Bio/SwissProt/__init__.py
   2 Bio/SwissProt/KeyWList.py
  10 Bio/UniGene/__init__.py
   1 Bio/Wise/__init__.py
   5 Bio/Wise/dnal.py
  12 Bio/Wise/psw.py
   5 BioSQL/BioSeq.py
  22 BioSQL/BioSeqDatabase.py
  10 BioSQL/DBUtils.py

If you would like to work on this, please comment here with the name of the module you want to work on (e.g. Bio.SeqIO or Bio.Wise) to avoid duplication of effort.

Note all the new docstrings should pass the pydocstyle or flake8-docstring checks using Biopython's current configuration.

Right now we're using pydocstyle with .pydocstyle, but plan to move to flake8 using the flake8-docstring plugin configured with .flake8 files, see #1199.

Activity

  1. added
    good first issue
    on May 1, 2017
  2. Gasta88 commented on May 3, 2017

    @Gasta88
    Contributor

    I would like to help but I'm probably missing some basic information here.

    I have both pydocstyle and flake8 on my machines and when I pick some random files from the posted list, I get no warnings in return.
    By looking at these random files I can see that there is docstring inside.

    What else do we need to code?

  3. peterjc commented on May 3, 2017

    @peterjc
    MemberAuthor

    First try this - it may just be an out of date flake8?:

    pip install --upgrade flake8 flake8-docstrings pydocstyle
    flake8 Bio BioSQL --isolated --select D1
    

    This should (via the --isolated option) ignore any local configuration which might be ignoring the D1## codes.

    There isn't a similar option for pydocstyle so also try something like this:

    $ echo "[pydocstyle]" > empty-pydocstyle.ini
    $ pydocstyle Bio/ BioSQL/ --select D1 --config empty-pydocstyle.ini
    

    (Note on my personal machine I am using pip3 install ... which runs these tools under Python 3, which gives very slightly different output to when run under Python 2)

  4. Gasta88 commented on May 3, 2017

    @Gasta88
    Contributor

    Much better, thanks Peter. I'll start with Bio.bgzf .

  5. peterjc commented on May 4, 2017

    @peterjc
    MemberAuthor

    I would suggest one pull request per file or related set of files (e.g. if you updated several entries under Bio/SeqIO/ then one pull request makes sense). This is in part to help with reviewing with a random group of files we may need more than one reviewer if several module owners are involved.

  6. Gasta88 commented on May 4, 2017

    @Gasta88
    Contributor

    I'll start with Bio.DocSQL

  7. peterjc commented on May 4, 2017

    @peterjc
    MemberAuthor

    If you want to, sure - but Bio.DocSQL was deprecated in Biopython 1.69, and unless anyone objects it will be deleted next year. If you think the code is still useful and want to adopt it that would be reason enough to cancel the deprecation :)

  8. Gasta88 commented on May 4, 2017

    @Gasta88
    Contributor

    I have no personal reason to use it, therefore I'll leave it as it is.

    I'll concentrate instead on Bio.File then.

  9. peterjc commented on May 4, 2017

    @peterjc
    MemberAuthor

    @Gasta88 good choice - some of the methods in Bio.File will be familiar from Bio.bgzf 👍

  10. added a commit that references this issue on May 5, 2017
  11. souravsingh commented on May 8, 2017

    @souravsingh
    Contributor

    @peterjc I will pick Nexus

  12. ctSkennerton commented on May 12, 2017

    @ctSkennerton
    Contributor

    @peterjc I'll do the BioSQL module

  13. 43 remaining items

  14. peterjc commented on Jan 23, 2019

    @peterjc
    MemberAuthor

    Steady progress:

    $ flake8 Bio --isolated --select D1 --statistics --quiet --quiet
    18    D100 Missing docstring in public module
    55    D101 Missing docstring in public class
    157   D102 Missing docstring in public method
    28    D103 Missing docstring in public function
    145   D105 Missing docstring in magic method
    

    Let's solve D100 next?

    $ flake8 --isolated --select D100 Bio 
    Bio/SeqIO/PdbIO.py:1:1: D100 Missing docstring in public module
    Bio/motifs/meme.py:1:1: D100 Missing docstring in public module
    Bio/motifs/minimal.py:1:1: D100 Missing docstring in public module
    Bio/motifs/mast.py:1:1: D100 Missing docstring in public module
    Bio/ExPASy/ScanProsite.py:1:1: D100 Missing docstring in public module
    Bio/Pathway/Rep/Graph.py:1:1: D100 Missing docstring in public module
    Bio/Pathway/Rep/MultiGraph.py:1:1: D100 Missing docstring in public module
    Bio/Restriction/Restriction_Dictionary.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/_cdao_owl.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/PAML/codeml.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/PAML/_parse_codeml.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/PAML/_parse_baseml.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/PAML/baseml.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/PAML/_parse_yn00.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/PAML/yn00.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/PAML/_paml.py:1:1: D100 Missing docstring in public module
    Bio/Phylo/PAML/chi2.py:1:1: D100 Missing docstring in public module
    Bio/PopGen/GenePop/Utils.py:1:1: D100 Missing docstring in public module
    

    See also #1906 which has notes on two of the above.

  15. svalqui commented on Jan 23, 2019

    @svalqui
    Contributor

    @peterjc Bio.Phylo docstrings are already on PR #1868, I'll have a look at Bio.motifs.
    cheers,

  16. peterjc commented on Feb 1, 2019

    @peterjc
    MemberAuthor

    I think #1868 and #1906 plus the commits I just made will solve all the D100 cases.

    Update: Except for the three Bio.motifs ones, but @svalqui said he'd do them.

    Updated: See #1915 for the motifs docstrings.

  17. peterjc commented on Mar 15, 2019

    @peterjc
    MemberAuthor

    New numbers,

    $ flake8 Bio BioSQL --isolated --select D1 --statistics --quiet --quiet
    50    D101 Missing docstring in public class
    117   D102 Missing docstring in public method
    24    D103 Missing docstring in public function
    112   D105 Missing docstring in magic method
    

    I will split this out into sub-issues...

  18. peterjc commented on Mar 15, 2019

    @peterjc
    MemberAuthor

    OK, child issues #1960, #1961, #1962 and #1963 filed - closing this one. Thank you all.

  19. peterjc commented on Jun 6, 2019

    @peterjc
    MemberAuthor

    Just to note, all the child issues have now been closed - all the public modules, classes, methods, functions in Bio and BioSQL have docstrings (just the magic methods left, and they are a bit repetitive and less important anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationEnhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions