QPromaQ commited on
Commit
c1431c4
·
verified ·
1 Parent(s): 9f8dccc

Reset repository and upload final project (part 5)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_130501.dtd +79 -0
  2. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_140101.dtd +79 -0
  3. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_150101.dtd +79 -0
  4. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_180101.dtd +434 -0
  5. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_180601.dtd +454 -0
  6. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_190101.dtd +478 -0
  7. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_230101.dtd +468 -0
  8. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_240101.dtd +477 -0
  9. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_250101.dtd +475 -0
  10. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/references.ent +726 -0
  11. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/section.ent +220 -0
  12. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/taxon.dtd +131 -0
  13. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/xhtml-inlstyle-1.mod +34 -0
  14. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/xhtml-table-1.mod +333 -0
  15. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/xmlspecchars.ent +290 -0
  16. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/Parser.py +1165 -0
  17. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/._IPGReportSet.xsd +0 -0
  18. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/._NCBI_BlastOutput2.mod.xsd +0 -0
  19. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/._NCBI_BlastOutput2.xsd +0 -0
  20. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/IPGReportSet.xsd +97 -0
  21. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/NCBI_BlastOutput2.mod.xsd +360 -0
  22. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/NCBI_BlastOutput2.xsd +22 -0
  23. .venv_haddock/lib/python3.12/site-packages/Bio/Entrez/__init__.py +747 -0
  24. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._Enzyme.py +0 -0
  25. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._Prodoc.py +0 -0
  26. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._Prosite.py +0 -0
  27. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._ScanProsite.py +0 -0
  28. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/.___init__.py +0 -0
  29. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/.___pycache__ +0 -0
  30. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._cellosaurus.py +0 -0
  31. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/Enzyme.py +159 -0
  32. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/Prodoc.py +173 -0
  33. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/Prosite.py +308 -0
  34. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/ScanProsite.py +151 -0
  35. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/__init__.py +138 -0
  36. .venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/cellosaurus.py +208 -0
  37. .venv_haddock/lib/python3.12/site-packages/Bio/File.py +626 -0
  38. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/._Record.py +0 -0
  39. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/._Scanner.py +0 -0
  40. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/.___init__.py +0 -0
  41. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/.___pycache__ +0 -0
  42. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/._utils.py +0 -0
  43. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/Record.py +669 -0
  44. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/Scanner.py +1929 -0
  45. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/__init__.py +1206 -0
  46. .venv_haddock/lib/python3.12/site-packages/Bio/GenBank/utils.py +66 -0
  47. .venv_haddock/lib/python3.12/site-packages/Bio/Geo/._Record.py +0 -0
  48. .venv_haddock/lib/python3.12/site-packages/Bio/Geo/.___init__.py +0 -0
  49. .venv_haddock/lib/python3.12/site-packages/Bio/Geo/.___pycache__ +0 -0
  50. .venv_haddock/lib/python3.12/site-packages/Bio/Geo/Record.py +90 -0
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_130501.dtd ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ This is the Current DTD which NLM has written for
3
+ External Use. If you are a NCBI User, use the information
4
+ from the PubmedArticleSet.
5
+
6
+ Comments and suggestions are welcome.
7
+ (May 9, 2000)
8
+
9
+ Corrections:
10
+ ~~~~~~~~~~~
11
+ Oct. 09 2002
12
+ - "PubMedArticle" has been renamed to "PubmedArticle"
13
+ - All referencies to "PubMedArticle" has been removed
14
+ - "ProviderId" has been removed from PubmedData
15
+ - "URL" has been removed from PubmdeData
16
+
17
+ $Id: pubmed_130501.dtd 404126 2013-06-20 17:36:43Z korobtch $
18
+
19
+ -->
20
+ <!-- ================================================================= -->
21
+ <!-- ================================================================= -->
22
+ <!-- Reference to Where the MEDLINECITATION DTD is located -->
23
+ <!ENTITY % Medline PUBLIC "-//NLM//DTD Medline, 01 May 2013//EN"
24
+ "nlmmedlinecitationset_130501.dtd">
25
+ %Medline;
26
+ <!-- ================================================================= -->
27
+ <!ENTITY % ArticleTitle.Ref "ArticleTitle">
28
+ <!ENTITY % ISSN.Ref "ISSN?">
29
+ <!ENTITY % Pub.Date.Ref "PubDate?">
30
+ <!ENTITY % iso.language.codes "(AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
31
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
32
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
33
+ VI|ZH)">
34
+ <!ENTITY % pub.status.int "pmc | pmcr | pubmed | pubmedr |
35
+ premedline | medline | medliner | entrez | pmc-release">
36
+ <!ENTITY % pub.status "(received | accepted | epublish |
37
+ ppublish | revised | aheadofprint |
38
+ retracted | ecollection | %pub.status.int;)">
39
+ <!ENTITY % art.id.type.int "pubmed | medline | pmcid | pmcbook | bookaccession">
40
+
41
+ <!ENTITY % art.id.type "(doi | pii | pmcpid | pmpid | pmc | mid |
42
+ sici | %art.id.type.int;)">
43
+ <!-- ================================================================= -->
44
+ <!ELEMENT PubmedArticleSet (PubmedArticle | PubmedBookArticle)+>
45
+ <!-- ================================================================= -->
46
+ <!-- This is the top level element for PubMedArticle -->
47
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
48
+ <!-- ================================================================= -->
49
+ <!ENTITY % normal.date "Year, Month, Day, (Hour, (Minute, Second?)?)?">
50
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
51
+ <!ELEMENT PubMedPubDate (%normal.date;)>
52
+ <!ATTLIST PubMedPubDate
53
+ PubStatus %pub.status; #REQUIRED
54
+ >
55
+ <!ELEMENT PublicationStatus (#PCDATA)>
56
+ <!ELEMENT ArticleIdList (ArticleId+)>
57
+ <!ELEMENT ArticleId (#PCDATA)>
58
+ <!ATTLIST ArticleId
59
+ IdType %art.id.type; "pubmed"
60
+ >
61
+ <!ELEMENT History (PubMedPubDate+)>
62
+ <!ELEMENT URL (#PCDATA)>
63
+ <!ATTLIST URL
64
+ lang %iso.language.codes; #IMPLIED
65
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED
66
+ >
67
+ <!ELEMENT ObjectList (Object)+>
68
+ <!ELEMENT Object (Param)*>
69
+ <!ATTLIST Object Type CDATA #REQUIRED>
70
+ <!ELEMENT Param %text;>
71
+ <!ATTLIST Param Name CDATA #REQUIRED>
72
+ <!ELEMENT Hour (#PCDATA)>
73
+ <!ELEMENT Minute (#PCDATA)>
74
+ <!ELEMENT Second (#PCDATA)>
75
+
76
+ <!-- ================================================================= -->
77
+ <!ENTITY % Bookdoc PUBLIC "-//NLM//DTD Bookdoc, 01 Jan 2013//EN" "bookdoc_130101.dtd">
78
+ %Bookdoc;
79
+ <!-- ================================================================= -->
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_140101.dtd ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ This is the Current DTD which NLM has written for
3
+ External Use. If you are a NCBI User, use the information
4
+ from the PubmedArticleSet.
5
+
6
+ Comments and suggestions are welcome.
7
+ (May 9, 2000)
8
+
9
+ Corrections:
10
+ ~~~~~~~~~~~
11
+ Oct. 09 2002
12
+ - "PubMedArticle" has been renamed to "PubmedArticle"
13
+ - All referencies to "PubMedArticle" has been removed
14
+ - "ProviderId" has been removed from PubmedData
15
+ - "URL" has been removed from PubmdeData
16
+
17
+ $Id: pubmed_140101.dtd 413871 2013-09-18 19:22:41Z korobtch $
18
+
19
+ -->
20
+ <!-- ================================================================= -->
21
+ <!-- ================================================================= -->
22
+ <!-- Reference to Where the MEDLINECITATION DTD is located -->
23
+ <!ENTITY % Medline PUBLIC "-//NLM//DTD Medline, 01 Jan 2014//EN"
24
+ "nlmmedlinecitationset_140101.dtd">
25
+ %Medline;
26
+ <!-- ================================================================= -->
27
+ <!ENTITY % ArticleTitle.Ref "ArticleTitle">
28
+ <!ENTITY % ISSN.Ref "ISSN?">
29
+ <!ENTITY % Pub.Date.Ref "PubDate?">
30
+ <!ENTITY % iso.language.codes "(AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
31
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
32
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
33
+ VI|ZH)">
34
+ <!ENTITY % pub.status.int "pmc | pmcr | pubmed | pubmedr |
35
+ premedline | medline | medliner | entrez | pmc-release">
36
+ <!ENTITY % pub.status "(received | accepted | epublish |
37
+ ppublish | revised | aheadofprint |
38
+ retracted | ecollection | %pub.status.int;)">
39
+ <!ENTITY % art.id.type.int "pubmed | medline | pmcid | pmcbook | bookaccession">
40
+
41
+ <!ENTITY % art.id.type "(doi | pii | pmcpid | pmpid | pmc | mid |
42
+ sici | %art.id.type.int;)">
43
+ <!-- ================================================================= -->
44
+ <!ELEMENT PubmedArticleSet (PubmedArticle | PubmedBookArticle)+>
45
+ <!-- ================================================================= -->
46
+ <!-- This is the top level element for PubMedArticle -->
47
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
48
+ <!-- ================================================================= -->
49
+ <!ENTITY % normal.date "Year, Month, Day, (Hour, (Minute, Second?)?)?">
50
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
51
+ <!ELEMENT PubMedPubDate (%normal.date;)>
52
+ <!ATTLIST PubMedPubDate
53
+ PubStatus %pub.status; #REQUIRED
54
+ >
55
+ <!ELEMENT PublicationStatus (#PCDATA)>
56
+ <!ELEMENT ArticleIdList (ArticleId+)>
57
+ <!ELEMENT ArticleId (#PCDATA)>
58
+ <!ATTLIST ArticleId
59
+ IdType %art.id.type; "pubmed"
60
+ >
61
+ <!ELEMENT History (PubMedPubDate+)>
62
+ <!ELEMENT URL (#PCDATA)>
63
+ <!ATTLIST URL
64
+ lang %iso.language.codes; #IMPLIED
65
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED
66
+ >
67
+ <!ELEMENT ObjectList (Object)+>
68
+ <!ELEMENT Object (Param)*>
69
+ <!ATTLIST Object Type CDATA #REQUIRED>
70
+ <!ELEMENT Param %text;>
71
+ <!ATTLIST Param Name CDATA #REQUIRED>
72
+ <!ELEMENT Hour (#PCDATA)>
73
+ <!ELEMENT Minute (#PCDATA)>
74
+ <!ELEMENT Second (#PCDATA)>
75
+
76
+ <!-- ================================================================= -->
77
+ <!ENTITY % Bookdoc PUBLIC "-//NLM//DTD Bookdoc, 01 Jan 2014//EN" "bookdoc_140101.dtd">
78
+ %Bookdoc;
79
+ <!-- ================================================================= -->
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_150101.dtd ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ This is the Current DTD which NLM has written for
3
+ External Use. If you are a NCBI User, use the information
4
+ from the PubmedArticleSet.
5
+
6
+ Comments and suggestions are welcome.
7
+ (May 9, 2000)
8
+
9
+ Corrections:
10
+ ~~~~~~~~~~~
11
+ Oct. 09 2002
12
+ - "PubMedArticle" has been renamed to "PubmedArticle"
13
+ - All referencies to "PubMedArticle" has been removed
14
+ - "ProviderId" has been removed from PubmedData
15
+ - "URL" has been removed from PubmdeData
16
+
17
+ $Id: pubmed_150101.dtd 447938 2014-10-01 17:41:38Z korobtch $
18
+
19
+ -->
20
+ <!-- ================================================================= -->
21
+ <!-- ================================================================= -->
22
+ <!-- Reference to Where the MEDLINECITATION DTD is located -->
23
+ <!ENTITY % Medline PUBLIC "-//NLM//DTD Medline, 01 Jan 2015//EN"
24
+ "nlmmedlinecitationset_150101.dtd">
25
+ %Medline;
26
+ <!-- ================================================================= -->
27
+ <!ENTITY % ArticleTitle.Ref "ArticleTitle">
28
+ <!ENTITY % ISSN.Ref "ISSN?">
29
+ <!ENTITY % Pub.Date.Ref "PubDate?">
30
+ <!ENTITY % iso.language.codes "(AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
31
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
32
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
33
+ VI|ZH)">
34
+ <!ENTITY % pub.status.int "pmc | pmcr | pubmed | pubmedr |
35
+ premedline | medline | medliner | entrez | pmc-release">
36
+ <!ENTITY % pub.status "(received | accepted | epublish |
37
+ ppublish | revised | aheadofprint |
38
+ retracted | ecollection | %pub.status.int;)">
39
+ <!ENTITY % art.id.type.int "pubmed | medline | pmcid | pmcbook | bookaccession">
40
+
41
+ <!ENTITY % art.id.type "(doi | pii | pmcpid | pmpid | pmc | mid |
42
+ sici | %art.id.type.int;)">
43
+ <!-- ================================================================= -->
44
+ <!ELEMENT PubmedArticleSet (PubmedArticle | PubmedBookArticle)+>
45
+ <!-- ================================================================= -->
46
+ <!-- This is the top level element for PubMedArticle -->
47
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
48
+ <!-- ================================================================= -->
49
+ <!ENTITY % normal.date "Year, Month, Day, (Hour, (Minute, Second?)?)?">
50
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
51
+ <!ELEMENT PubMedPubDate (%normal.date;)>
52
+ <!ATTLIST PubMedPubDate
53
+ PubStatus %pub.status; #REQUIRED
54
+ >
55
+ <!ELEMENT PublicationStatus (#PCDATA)>
56
+ <!ELEMENT ArticleIdList (ArticleId+)>
57
+ <!ELEMENT ArticleId (#PCDATA)>
58
+ <!ATTLIST ArticleId
59
+ IdType %art.id.type; "pubmed"
60
+ >
61
+ <!ELEMENT History (PubMedPubDate+)>
62
+ <!ELEMENT URL (#PCDATA)>
63
+ <!ATTLIST URL
64
+ lang %iso.language.codes; #IMPLIED
65
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED
66
+ >
67
+ <!ELEMENT ObjectList (Object)+>
68
+ <!ELEMENT Object (Param)*>
69
+ <!ATTLIST Object Type CDATA #REQUIRED>
70
+ <!ELEMENT Param %text;>
71
+ <!ATTLIST Param Name CDATA #REQUIRED>
72
+ <!ELEMENT Hour (#PCDATA)>
73
+ <!ELEMENT Minute (#PCDATA)>
74
+ <!ELEMENT Second (#PCDATA)>
75
+
76
+ <!-- ================================================================= -->
77
+ <!ENTITY % Bookdoc PUBLIC "-//NLM//DTD Bookdoc, 01 Jan 2015//EN" "bookdoc_150101.dtd">
78
+ %Bookdoc;
79
+ <!-- ================================================================= -->
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_180101.dtd ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+
3
+ 2017-10-06
4
+
5
+ This DTD supports both the E-utilities and ftp service data dissemination methods.
6
+ It is based on http://dtd.nlm.nih.gov/ncbi/pubmed/out/pubmed_170101.dtd
7
+
8
+ Additions/Changes since 170101 DTD:
9
+
10
+ 1. Added Organism to the allowed values for SupplMeshName @Type
11
+ 2. Deleted DateCreated
12
+
13
+ NOTE: The use of "Medline" in a DTD or element name does not mean the record
14
+ represents a citation from a MEDLINE-selected journal. When the NLM DTDs and
15
+ XML elements were first created, MEDLINE records were the only data exported.
16
+ Now NLM exports citations other than MEDLINE records using these tools. To
17
+ minimize unnecessary disruption to users of the data and tools, NLM has
18
+ retained the original DTD and element names (e.g., MedlineTA, MedlineJournalInfo).
19
+
20
+ NOTE: StartPage and EndPage in Pagination element are not currently used; are
21
+ reserved for future use.
22
+
23
+ * = 0 or more occurrences (optional element, repeatable)
24
+ ? = 0 or 1 occurrences (optional element, at most 1)
25
+ + = 1 or more occurrences (required element, repeatable)
26
+ | = choice, one or the other but not both
27
+ no symbol = required element
28
+
29
+ -->
30
+ <!-- ================================================================= -->
31
+ <!-- ================================================================= -->
32
+ <!ENTITY % text "(#PCDATA | b | i | sup | sub | u)*" >
33
+
34
+ <!ENTITY % booklinkatts
35
+ "book CDATA #IMPLIED
36
+ part CDATA #IMPLIED
37
+ sec CDATA #IMPLIED" >
38
+ <!-- ================================================================= -->
39
+ <!-- ================================================================= -->
40
+
41
+ <!-- ================= Set-level elements ============================-->
42
+ <!ELEMENT PubmedArticleSet ((PubmedArticle | PubmedBookArticle)+, DeleteCitation?) >
43
+
44
+ <!ELEMENT BookDocumentSet (BookDocument*, DeleteDocument?) >
45
+
46
+ <!ELEMENT PubmedBookArticleSet (PubmedBookArticle*)>
47
+
48
+
49
+
50
+ <!-- ============= Document-level elements ============================-->
51
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
52
+
53
+ <!ELEMENT PubmedBookArticle (BookDocument, PubmedBookData?)>
54
+
55
+ <!ELEMENT BookDocument ( PMID, ArticleIdList, Book, LocationLabel*, ArticleTitle?, VernacularTitle?,
56
+ Pagination?, Language*, AuthorList*, InvestigatorList?, PublicationType*, Abstract?, Sections?, KeywordList*,
57
+ ContributionDate?, DateRevised?, CitationString?, GrantList?, ItemList*) >
58
+
59
+ <!ELEMENT DeleteCitation (PMID+) >
60
+
61
+ <!ELEMENT DeleteDocument (PMID*) >
62
+
63
+
64
+ <!-- =============== Sub-Document wrapper elements =====================-->
65
+ <!ELEMENT MedlineCitation (PMID, DateCompleted?, DateRevised?, Article,
66
+ MedlineJournalInfo, ChemicalList?, SupplMeshList?,CitationSubset*,
67
+ CommentsCorrectionsList?, GeneSymbolList?, MeshHeadingList?,
68
+ NumberOfReferences?, PersonalNameSubjectList?, OtherID*, OtherAbstract*,
69
+ KeywordList*, CoiStatement?, SpaceFlightMission*, InvestigatorList?, GeneralNote*)>
70
+ <!ATTLIST MedlineCitation
71
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD | NOTNLM) "NLM"
72
+ Status (Completed | In-Process | PubMed-not-MEDLINE | In-Data-Review | Publisher |
73
+ MEDLINE | OLDMEDLINE) #REQUIRED
74
+ VersionID CDATA #IMPLIED
75
+ VersionDate CDATA #IMPLIED
76
+ IndexingMethod CDATA #IMPLIED >
77
+
78
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?) >
79
+
80
+ <!ELEMENT PubmedBookData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
81
+
82
+ <!ELEMENT Article (Journal,ArticleTitle,((Pagination, ELocationID*) | ELocationID+),
83
+ Abstract?,AuthorList?, Language+, DataBankList?, GrantList?,
84
+ PublicationTypeList, VernacularTitle?, ArticleDate*) >
85
+ <!ATTLIST Article
86
+ PubModel (Print | Print-Electronic | Electronic | Electronic-Print | Electronic-eCollection) #REQUIRED >
87
+
88
+
89
+
90
+
91
+ <!-- ================================================================= -->
92
+ <!-- Everything else in alphabetical order -->
93
+ <!-- ================================================================= -->
94
+
95
+ <!ELEMENT Abstract (AbstractText+, CopyrightInformation?)>
96
+
97
+ <!ELEMENT AbstractText %text;>
98
+ <!ATTLIST AbstractText
99
+ Label CDATA #IMPLIED
100
+ NlmCategory (BACKGROUND | OBJECTIVE | METHODS | RESULTS | CONCLUSIONS | UNASSIGNED) #IMPLIED >
101
+
102
+ <!ELEMENT AccessionNumber (#PCDATA) >
103
+
104
+ <!ELEMENT AccessionNumberList (AccessionNumber+) >
105
+
106
+ <!ELEMENT Acronym (#PCDATA) >
107
+
108
+ <!ELEMENT Affiliation %text;>
109
+
110
+ <!ELEMENT AffiliationInfo (Affiliation, Identifier*)>
111
+
112
+ <!ELEMENT Agency (#PCDATA) >
113
+
114
+ <!ELEMENT ArticleDate (Year, Month, Day) >
115
+ <!ATTLIST ArticleDate
116
+ DateType CDATA #FIXED "Electronic" >
117
+
118
+ <!ELEMENT ArticleId (#PCDATA) >
119
+ <!ATTLIST ArticleId
120
+ IdType (doi | pii | pmcpid | pmpid | pmc | mid |
121
+ sici | pubmed | medline | pmcid | pmcbook | bookaccession) "pubmed" >
122
+
123
+ <!ELEMENT ArticleIdList (ArticleId+)>
124
+
125
+ <!ELEMENT ArticleTitle %text;>
126
+ <!ATTLIST ArticleTitle %booklinkatts; >
127
+
128
+ <!ELEMENT Author (((LastName, ForeName?, Initials?, Suffix?) | CollectiveName), Identifier*, AffiliationInfo*) >
129
+ <!ATTLIST Author
130
+ ValidYN (Y | N) "Y"
131
+ EqualContrib (Y | N) #IMPLIED >
132
+
133
+ <!ELEMENT AuthorList (Author+) >
134
+ <!ATTLIST AuthorList
135
+ CompleteYN (Y | N) "Y"
136
+ Type ( authors | editors ) #IMPLIED >
137
+
138
+ <!ELEMENT b %text; > <!-- bold -->
139
+
140
+ <!ELEMENT BeginningDate ( Year, ((Month, Day?) | Season)? ) >
141
+
142
+ <!ELEMENT Book ( Publisher, BookTitle, PubDate, BeginningDate?, EndingDate?, AuthorList*, InvestigatorList?, Volume?,
143
+ VolumeTitle?, Edition?, CollectionTitle?, Isbn*, ELocationID*, Medium?, ReportNumber?) >
144
+
145
+ <!ELEMENT BookTitle %text; >
146
+ <!ATTLIST BookTitle %booklinkatts; >
147
+
148
+ <!ELEMENT Chemical (RegistryNumber, NameOfSubstance) >
149
+
150
+ <!ELEMENT ChemicalList (Chemical+) >
151
+
152
+ <!ELEMENT CitationString %text; >
153
+
154
+ <!ELEMENT CitationSubset (#PCDATA) >
155
+
156
+ <!ELEMENT CoiStatement %text; >
157
+
158
+ <!ELEMENT CollectionTitle %text; >
159
+ <!ATTLIST CollectionTitle %booklinkatts; >
160
+
161
+ <!ELEMENT CollectiveName %text; >
162
+
163
+ <!ELEMENT CommentsCorrections (RefSource,PMID?,Note?) >
164
+ <!ATTLIST CommentsCorrections
165
+ RefType (AssociatedDataset | AssociatedPublication | CommentOn | CommentIn | ErratumIn |
166
+ ErratumFor | ExpressionOfConcernIn | ExpressionOfConcernFor |
167
+ RepublishedFrom | RepublishedIn |
168
+ RetractionOf | RetractionIn | UpdateIn | UpdateOf | SummaryForPatientsIn |
169
+ OriginalReportIn | ReprintOf | ReprintIn | Cites) #REQUIRED >
170
+
171
+ <!ELEMENT CommentsCorrectionsList (CommentsCorrections+) >
172
+
173
+ <!ELEMENT ContractNumber (#PCDATA) >
174
+
175
+ <!ELEMENT ContributionDate ( Year, ((Month, Day?) | Season)? ) >
176
+
177
+ <!ELEMENT CopyrightInformation (#PCDATA) >
178
+
179
+ <!ELEMENT Country (#PCDATA) >
180
+
181
+ <!ELEMENT DataBank (DataBankName, AccessionNumberList?) >
182
+
183
+ <!ELEMENT DataBankList (DataBank+) >
184
+
185
+ <!ATTLIST DataBankList
186
+ CompleteYN (Y | N) "Y" >
187
+
188
+ <!ELEMENT DataBankName (#PCDATA) >
189
+
190
+ <!ELEMENT DateCompleted (Year,Month,Day) >
191
+
192
+ <!ELEMENT DateRevised (Year,Month,Day) >
193
+
194
+ <!ELEMENT Day (#PCDATA )>
195
+
196
+ <!ELEMENT DescriptorName (#PCDATA) >
197
+ <!ATTLIST DescriptorName
198
+ MajorTopicYN (Y | N) "N"
199
+ Type (Geographic) #IMPLIED
200
+ UI CDATA #REQUIRED >
201
+
202
+ <!ELEMENT Edition (#PCDATA) >
203
+
204
+ <!ELEMENT ELocationID (#PCDATA) >
205
+ <!ATTLIST ELocationID
206
+ EIdType (doi | pii) #REQUIRED
207
+ ValidYN (Y | N) "Y">
208
+
209
+ <!ELEMENT EndingDate ( Year, ((Month, Day?) | Season)? ) >
210
+
211
+ <!ELEMENT EndPage (#PCDATA) >
212
+
213
+ <!ELEMENT ForeName (#PCDATA) >
214
+
215
+ <!ELEMENT GeneSymbol (#PCDATA) >
216
+
217
+ <!ELEMENT GeneSymbolList (GeneSymbol+)>
218
+
219
+ <!ELEMENT GeneralNote (#PCDATA) >
220
+ <!ATTLIST GeneralNote
221
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD) "NLM" >
222
+
223
+ <!ELEMENT Grant (GrantID?, Acronym?, Agency, Country)>
224
+
225
+ <!ELEMENT GrantID (#PCDATA) >
226
+
227
+ <!ELEMENT GrantList (Grant+)>
228
+ <!ATTLIST GrantList
229
+ CompleteYN (Y | N) "Y">
230
+
231
+ <!ELEMENT History (PubMedPubDate+) >
232
+
233
+ <!ELEMENT Hour (#PCDATA) >
234
+
235
+ <!ELEMENT i %text; > <!-- italic -->
236
+
237
+ <!ELEMENT Identifier (#PCDATA) >
238
+ <!ATTLIST Identifier
239
+ Source CDATA #REQUIRED >
240
+
241
+ <!ELEMENT Initials (#PCDATA) >
242
+
243
+ <!ELEMENT Investigator (LastName, ForeName?, Initials?, Suffix?, Identifier*, AffiliationInfo*) >
244
+ <!ATTLIST Investigator
245
+ ValidYN (Y | N) "Y" >
246
+
247
+ <!ELEMENT InvestigatorList (Investigator+) >
248
+
249
+ <!ELEMENT Isbn (#PCDATA) >
250
+
251
+ <!ELEMENT ISOAbbreviation (#PCDATA) >
252
+
253
+ <!ELEMENT ISSN (#PCDATA) >
254
+ <!ATTLIST ISSN
255
+ IssnType (Electronic | Print) #REQUIRED >
256
+
257
+ <!ELEMENT ISSNLinking (#PCDATA) >
258
+
259
+ <!ELEMENT Issue (#PCDATA) >
260
+ <!ELEMENT Item (#PCDATA)>
261
+
262
+ <!ELEMENT ItemList (Item+)>
263
+ <!ATTLIST ItemList
264
+ ListType CDATA #REQUIRED>
265
+
266
+ <!ELEMENT Journal (ISSN?, JournalIssue, Title?, ISOAbbreviation?)>
267
+
268
+ <!ELEMENT JournalIssue (Volume?, Issue?, PubDate) >
269
+ <!ATTLIST JournalIssue
270
+ CitedMedium (Internet | Print) #REQUIRED >
271
+
272
+ <!ELEMENT Keyword %text;>
273
+ <!ATTLIST Keyword
274
+ MajorTopicYN (Y | N) "N" >
275
+
276
+ <!ELEMENT KeywordList (Keyword+) >
277
+ <!ATTLIST KeywordList
278
+ Owner (NLM | NLM-AUTO | NASA | PIP | KIE | NOTNLM | HHS) "NLM" >
279
+
280
+ <!ELEMENT Language (#PCDATA) >
281
+
282
+ <!ELEMENT LastName (#PCDATA) >
283
+
284
+ <!ELEMENT LocationLabel (#PCDATA)>
285
+ <!ATTLIST LocationLabel
286
+ Type (part|chapter|section|appendix|figure|table|box) #IMPLIED >
287
+
288
+ <!ELEMENT Medium (#PCDATA) >
289
+
290
+ <!ELEMENT MedlineDate (#PCDATA) >
291
+
292
+ <!ELEMENT MedlineJournalInfo (Country?, MedlineTA, NlmUniqueID?, ISSNLinking?) >
293
+
294
+ <!ELEMENT MedlinePgn (#PCDATA) >
295
+
296
+ <!ELEMENT MedlineTA (#PCDATA) >
297
+
298
+ <!ELEMENT MeshHeading (DescriptorName, QualifierName*)>
299
+
300
+ <!ELEMENT MeshHeadingList (MeshHeading+)>
301
+
302
+ <!ELEMENT Minute (#PCDATA) >
303
+
304
+ <!ELEMENT Month (#PCDATA) >
305
+
306
+ <!ELEMENT NameOfSubstance (#PCDATA) >
307
+ <!ATTLIST NameOfSubstance
308
+ UI CDATA #REQUIRED >
309
+
310
+ <!ELEMENT NlmUniqueID (#PCDATA) >
311
+
312
+ <!ELEMENT Note (#PCDATA) >
313
+
314
+ <!ELEMENT NumberOfReferences (#PCDATA) >
315
+
316
+ <!ELEMENT Object (Param*)>
317
+ <!ATTLIST Object
318
+ Type CDATA #REQUIRED >
319
+
320
+ <!ELEMENT ObjectList (Object+) >
321
+
322
+ <!ELEMENT OtherAbstract (AbstractText+, CopyrightInformation?) >
323
+
324
+ <!ATTLIST OtherAbstract
325
+ Type (AAMC | AIDS | KIE | PIP | NASA | Publisher) #REQUIRED
326
+ Language CDATA "eng" >
327
+
328
+ <!ELEMENT OtherID (#PCDATA) >
329
+ <!ATTLIST OtherID
330
+ Source (NASA | KIE | PIP | POP | ARPL | CPC | IND | CPFH | CLML |
331
+ NRCBL | NLM | QCIM) #REQUIRED >
332
+
333
+ <!ELEMENT PMID (#PCDATA) >
334
+ <!ATTLIST PMID
335
+ Version CDATA #REQUIRED >
336
+
337
+ <!ELEMENT Pagination ((StartPage, EndPage?, MedlinePgn?) | MedlinePgn) >
338
+
339
+ <!ELEMENT Param %text;>
340
+ <!ATTLIST Param
341
+ Name CDATA #REQUIRED >
342
+
343
+ <!ELEMENT PersonalNameSubject (LastName, ForeName?, Initials?, Suffix?) >
344
+
345
+ <!ELEMENT PersonalNameSubjectList (PersonalNameSubject+) >
346
+
347
+ <!ELEMENT PubDate ((Year, ((Month, Day?) | Season)?) | MedlineDate) >
348
+
349
+ <!ELEMENT PublicationStatus (#PCDATA) >
350
+
351
+ <!ELEMENT PublicationType (#PCDATA) >
352
+ <!ATTLIST PublicationType
353
+ UI CDATA #REQUIRED >
354
+
355
+ <!ELEMENT PublicationTypeList (PublicationType+) >
356
+
357
+ <!ELEMENT PubMedPubDate (Year, Month, Day, (Hour, (Minute, Second?)?)?)>
358
+ <!ATTLIST PubMedPubDate
359
+ PubStatus (received | accepted | epublish |
360
+ ppublish | revised | aheadofprint |
361
+ retracted | ecollection | pmc | pmcr | pubmed | pubmedr |
362
+ premedline | medline | medliner | entrez | pmc-release) #REQUIRED >
363
+
364
+ <!ELEMENT Publisher (PublisherName, PublisherLocation?) >
365
+
366
+ <!ELEMENT PublisherLocation (#PCDATA) >
367
+
368
+ <!ELEMENT PublisherName %text; >
369
+
370
+ <!ELEMENT QualifierName (#PCDATA) >
371
+ <!ATTLIST QualifierName
372
+ MajorTopicYN (Y | N) "N"
373
+ UI CDATA #REQUIRED >
374
+
375
+ <!ELEMENT RefSource (#PCDATA) >
376
+
377
+ <!ELEMENT RegistryNumber (#PCDATA) >
378
+
379
+ <!ELEMENT ReportNumber (#PCDATA) >
380
+
381
+ <!ELEMENT Season (#PCDATA) >
382
+
383
+ <!ELEMENT Second (#PCDATA) >
384
+
385
+
386
+ <!ELEMENT Section (LocationLabel?, SectionTitle, Section*) >
387
+
388
+ <!ELEMENT Sections (Section+) >
389
+
390
+ <!ELEMENT SectionTitle %text; >
391
+ <!ATTLIST SectionTitle %booklinkatts; >
392
+
393
+ <!ELEMENT SpaceFlightMission (#PCDATA) >
394
+
395
+ <!ELEMENT StartPage (#PCDATA) >
396
+
397
+ <!ELEMENT sub %text; > <!-- subscript -->
398
+
399
+ <!ELEMENT Suffix %text;>
400
+
401
+ <!ELEMENT sup %text; > <!-- superscript -->
402
+
403
+ <!ELEMENT SupplMeshList (SupplMeshName+)>
404
+
405
+ <!ELEMENT SupplMeshName (#PCDATA) >
406
+ <!ATTLIST SupplMeshName
407
+ Type (Disease | Protocol | Organism) #REQUIRED
408
+ UI CDATA #REQUIRED >
409
+
410
+ <!ELEMENT Title (#PCDATA) >
411
+
412
+ <!ELEMENT u %text; > <!-- underline -->
413
+
414
+ <!ELEMENT URL (#PCDATA) >
415
+ <!ATTLIST URL
416
+ lang (AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
417
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
418
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
419
+ VI|ZH) #IMPLIED
420
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED >
421
+
422
+ <!ELEMENT VernacularTitle %text; >
423
+
424
+ <!ELEMENT Volume (#PCDATA) >
425
+
426
+ <!ELEMENT VolumeTitle %text; >
427
+
428
+ <!ELEMENT Year (#PCDATA) >
429
+
430
+
431
+
432
+
433
+
434
+
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_180601.dtd ADDED
@@ -0,0 +1,454 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+
3
+ 2017-10-06
4
+
5
+ This DTD supports both the E-utilities and ftp service data dissemination methods.
6
+ It is based on http://dtd.nlm.nih.gov/ncbi/pubmed/out/pubmed_180101.dtd
7
+
8
+ Additions/Changes since 180101 DTD:
9
+
10
+ 1. Added MathML3
11
+ 2. Allowed <mml:math> in <AbstractText>, <ArticleTitle>, <BookTitle>, <CollectionTitle>,
12
+ <Keyword>, <VernacularTitle>.
13
+
14
+ NOTE: The use of "Medline" in a DTD or element name does not mean the record
15
+ represents a citation from a MEDLINE-selected journal. When the NLM DTDs and
16
+ XML elements were first created, MEDLINE records were the only data exported.
17
+ Now NLM exports citations other than MEDLINE records using these tools. To
18
+ minimize unnecessary disruption to users of the data and tools, NLM has
19
+ retained the original DTD and element names (e.g., MedlineTA, MedlineJournalInfo).
20
+
21
+ NOTE: StartPage and EndPage in Pagination element are not currently used; are
22
+ reserved for future use.
23
+
24
+ * = 0 or more occurrences (optional element, repeatable)
25
+ ? = 0 or 1 occurrences (optional element, at most 1)
26
+ + = 1 or more occurrences (required element, repeatable)
27
+ | = choice, one or the other but not both
28
+ no symbol = required element
29
+
30
+ -->
31
+
32
+ <!-- ============================================================= -->
33
+ <!-- MATHML 3.0 SETUP -->
34
+ <!-- ============================================================= -->
35
+ <!-- MATHML SETUP FILE -->
36
+ <!ENTITY % mathml-in-pubmed SYSTEM "mathml-in-pubmed.mod" >
37
+ %mathml-in-pubmed;
38
+
39
+
40
+
41
+ <!-- ================================================================= -->
42
+ <!-- ================================================================= -->
43
+ <!ENTITY % text "#PCDATA | b | i | sup | sub | u" >
44
+
45
+ <!ENTITY % booklinkatts
46
+ "book CDATA #IMPLIED
47
+ part CDATA #IMPLIED
48
+ sec CDATA #IMPLIED" >
49
+ <!-- ================================================================= -->
50
+ <!-- ================================================================= -->
51
+
52
+ <!-- ================= Set-level elements ============================-->
53
+ <!ELEMENT PubmedArticleSet ((PubmedArticle | PubmedBookArticle)+, DeleteCitation?) >
54
+ <!ATTLIST PubmedArticleSet
55
+ >
56
+
57
+ <!ELEMENT BookDocumentSet (BookDocument*, DeleteDocument?) >
58
+ <!ATTLIST BookDocumentSet
59
+ >
60
+
61
+ <!ELEMENT PubmedBookArticleSet (PubmedBookArticle*)>
62
+ <!ATTLIST PubmedBookArticleSet
63
+ >
64
+
65
+
66
+ <!-- ============= Document-level elements ============================-->
67
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
68
+ <!ATTLIST PubmedArticle
69
+ >
70
+
71
+ <!ELEMENT PubmedBookArticle (BookDocument, PubmedBookData?)>
72
+ <!ATTLIST PubmedBookArticle
73
+ >
74
+
75
+ <!ELEMENT BookDocument ( PMID, ArticleIdList, Book, LocationLabel*, ArticleTitle?, VernacularTitle?,
76
+ Pagination?, Language*, AuthorList*, InvestigatorList?, PublicationType*, Abstract?, Sections?, KeywordList*,
77
+ ContributionDate?, DateRevised?, CitationString?, GrantList?, ItemList*) >
78
+
79
+ <!ELEMENT DeleteCitation (PMID+) >
80
+
81
+ <!ELEMENT DeleteDocument (PMID*) >
82
+
83
+
84
+ <!-- =============== Sub-Document wrapper elements =====================-->
85
+ <!ELEMENT MedlineCitation (PMID, DateCompleted?, DateRevised?, Article,
86
+ MedlineJournalInfo, ChemicalList?, SupplMeshList?,CitationSubset*,
87
+ CommentsCorrectionsList?, GeneSymbolList?, MeshHeadingList?,
88
+ NumberOfReferences?, PersonalNameSubjectList?, OtherID*, OtherAbstract*,
89
+ KeywordList*, CoiStatement?, SpaceFlightMission*, InvestigatorList?, GeneralNote*)>
90
+ <!ATTLIST MedlineCitation
91
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD | NOTNLM) "NLM"
92
+ Status (Completed | In-Process | PubMed-not-MEDLINE | In-Data-Review | Publisher |
93
+ MEDLINE | OLDMEDLINE) #REQUIRED
94
+ VersionID CDATA #IMPLIED
95
+ VersionDate CDATA #IMPLIED
96
+ IndexingMethod CDATA #IMPLIED >
97
+
98
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?) >
99
+
100
+ <!ELEMENT PubmedBookData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
101
+
102
+ <!ELEMENT Article (Journal,ArticleTitle,((Pagination, ELocationID*) | ELocationID+),
103
+ Abstract?,AuthorList?, Language+, DataBankList?, GrantList?,
104
+ PublicationTypeList, VernacularTitle?, ArticleDate*) >
105
+ <!ATTLIST Article
106
+ PubModel (Print | Print-Electronic | Electronic | Electronic-Print | Electronic-eCollection) #REQUIRED >
107
+
108
+
109
+
110
+
111
+ <!-- ================================================================= -->
112
+ <!-- Everything else in alphabetical order -->
113
+ <!-- ================================================================= -->
114
+
115
+ <!ELEMENT Abstract (AbstractText+, CopyrightInformation?)>
116
+
117
+ <!ELEMENT AbstractText (%text; | mml:math | DispFormula)* >
118
+ <!ATTLIST AbstractText
119
+ Label CDATA #IMPLIED
120
+ NlmCategory (BACKGROUND | OBJECTIVE | METHODS | RESULTS | CONCLUSIONS | UNASSIGNED) #IMPLIED >
121
+
122
+ <!ELEMENT AccessionNumber (#PCDATA) >
123
+
124
+ <!ELEMENT AccessionNumberList (AccessionNumber+) >
125
+
126
+ <!ELEMENT Acronym (#PCDATA) >
127
+
128
+ <!ELEMENT Affiliation (%text;)*>
129
+
130
+ <!ELEMENT AffiliationInfo (Affiliation, Identifier*)>
131
+
132
+ <!ELEMENT Agency (#PCDATA) >
133
+
134
+ <!ELEMENT ArticleDate (Year, Month, Day) >
135
+ <!ATTLIST ArticleDate
136
+ DateType CDATA #FIXED "Electronic" >
137
+
138
+ <!ELEMENT ArticleId (#PCDATA) >
139
+ <!ATTLIST ArticleId
140
+ IdType (doi | pii | pmcpid | pmpid | pmc | mid |
141
+ sici | pubmed | medline | pmcid | pmcbook | bookaccession) "pubmed" >
142
+
143
+ <!ELEMENT ArticleIdList (ArticleId+)>
144
+
145
+ <!ELEMENT ArticleTitle (%text; | mml:math)*>
146
+ <!ATTLIST ArticleTitle %booklinkatts; >
147
+
148
+ <!ELEMENT Author (((LastName, ForeName?, Initials?, Suffix?) | CollectiveName), Identifier*, AffiliationInfo*) >
149
+ <!ATTLIST Author
150
+ ValidYN (Y | N) "Y"
151
+ EqualContrib (Y | N) #IMPLIED >
152
+
153
+ <!ELEMENT AuthorList (Author+) >
154
+ <!ATTLIST AuthorList
155
+ CompleteYN (Y | N) "Y"
156
+ Type ( authors | editors ) #IMPLIED >
157
+
158
+ <!ELEMENT b (%text;)*> <!-- bold -->
159
+
160
+ <!ELEMENT BeginningDate ( Year, ((Month, Day?) | Season)? ) >
161
+
162
+ <!ELEMENT Book ( Publisher, BookTitle, PubDate, BeginningDate?, EndingDate?, AuthorList*, InvestigatorList?, Volume?,
163
+ VolumeTitle?, Edition?, CollectionTitle?, Isbn*, ELocationID*, Medium?, ReportNumber?) >
164
+
165
+ <!ELEMENT BookTitle (%text; | mml:math)*>
166
+ <!ATTLIST BookTitle %booklinkatts; >
167
+
168
+ <!ELEMENT Chemical (RegistryNumber, NameOfSubstance) >
169
+
170
+ <!ELEMENT ChemicalList (Chemical+) >
171
+
172
+ <!ELEMENT CitationString (%text;)*>
173
+
174
+ <!ELEMENT CitationSubset (#PCDATA) >
175
+
176
+ <!ELEMENT CoiStatement (%text;)*>
177
+
178
+ <!ELEMENT CollectionTitle (%text; | mml:math)*>
179
+ <!ATTLIST CollectionTitle %booklinkatts; >
180
+
181
+ <!ELEMENT CollectiveName (%text;)*>
182
+
183
+ <!ELEMENT CommentsCorrections (RefSource,PMID?,Note?) >
184
+ <!ATTLIST CommentsCorrections
185
+ RefType (AssociatedDataset | AssociatedPublication | CommentOn | CommentIn | ErratumIn |
186
+ ErratumFor | ExpressionOfConcernIn | ExpressionOfConcernFor |
187
+ RepublishedFrom | RepublishedIn |
188
+ RetractionOf | RetractionIn | UpdateIn | UpdateOf | SummaryForPatientsIn |
189
+ OriginalReportIn | ReprintOf | ReprintIn | Cites) #REQUIRED >
190
+
191
+ <!ELEMENT CommentsCorrectionsList (CommentsCorrections+) >
192
+
193
+ <!ELEMENT ContractNumber (#PCDATA) >
194
+
195
+ <!ELEMENT ContributionDate ( Year, ((Month, Day?) | Season)? ) >
196
+
197
+ <!ELEMENT CopyrightInformation (#PCDATA) >
198
+
199
+ <!ELEMENT Country (#PCDATA) >
200
+
201
+ <!ELEMENT DataBank (DataBankName, AccessionNumberList?) >
202
+
203
+ <!ELEMENT DataBankList (DataBank+) >
204
+
205
+ <!ATTLIST DataBankList
206
+ CompleteYN (Y | N) "Y" >
207
+
208
+ <!ELEMENT DataBankName (#PCDATA) >
209
+
210
+ <!ELEMENT DateCompleted (Year,Month,Day) >
211
+
212
+ <!ELEMENT DateRevised (Year,Month,Day) >
213
+
214
+ <!ELEMENT Day (#PCDATA )>
215
+
216
+ <!ELEMENT DescriptorName (#PCDATA) >
217
+ <!ATTLIST DescriptorName
218
+ MajorTopicYN (Y | N) "N"
219
+ Type (Geographic) #IMPLIED
220
+ UI CDATA #REQUIRED >
221
+
222
+ <!ELEMENT DispFormula (mml:math) >
223
+ <!ELEMENT Edition (#PCDATA) >
224
+
225
+ <!ELEMENT ELocationID (#PCDATA) >
226
+ <!ATTLIST ELocationID
227
+ EIdType (doi | pii) #REQUIRED
228
+ ValidYN (Y | N) "Y">
229
+
230
+ <!ELEMENT EndingDate ( Year, ((Month, Day?) | Season)? ) >
231
+
232
+ <!ELEMENT EndPage (#PCDATA) >
233
+
234
+ <!ELEMENT ForeName (#PCDATA) >
235
+
236
+ <!ELEMENT GeneSymbol (#PCDATA) >
237
+
238
+ <!ELEMENT GeneSymbolList (GeneSymbol+)>
239
+
240
+ <!ELEMENT GeneralNote (#PCDATA) >
241
+ <!ATTLIST GeneralNote
242
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD) "NLM" >
243
+
244
+ <!ELEMENT Grant (GrantID?, Acronym?, Agency, Country)>
245
+
246
+ <!ELEMENT GrantID (#PCDATA) >
247
+
248
+ <!ELEMENT GrantList (Grant+)>
249
+ <!ATTLIST GrantList
250
+ CompleteYN (Y | N) "Y">
251
+
252
+ <!ELEMENT History (PubMedPubDate+) >
253
+
254
+ <!ELEMENT Hour (#PCDATA) >
255
+
256
+ <!ELEMENT i (%text;)*> <!-- italic -->
257
+
258
+ <!ELEMENT Identifier (#PCDATA) >
259
+ <!ATTLIST Identifier
260
+ Source CDATA #REQUIRED >
261
+
262
+ <!ELEMENT Initials (#PCDATA) >
263
+
264
+ <!ELEMENT Investigator (LastName, ForeName?, Initials?, Suffix?, Identifier*, AffiliationInfo*) >
265
+ <!ATTLIST Investigator
266
+ ValidYN (Y | N) "Y" >
267
+
268
+ <!ELEMENT InvestigatorList (Investigator+) >
269
+
270
+ <!ELEMENT Isbn (#PCDATA) >
271
+
272
+ <!ELEMENT ISOAbbreviation (#PCDATA) >
273
+
274
+ <!ELEMENT ISSN (#PCDATA) >
275
+ <!ATTLIST ISSN
276
+ IssnType (Electronic | Print) #REQUIRED >
277
+
278
+ <!ELEMENT ISSNLinking (#PCDATA) >
279
+
280
+ <!ELEMENT Issue (#PCDATA) >
281
+ <!ELEMENT Item (#PCDATA)>
282
+
283
+ <!ELEMENT ItemList (Item+)>
284
+ <!ATTLIST ItemList
285
+ ListType CDATA #REQUIRED>
286
+
287
+ <!ELEMENT Journal (ISSN?, JournalIssue, Title?, ISOAbbreviation?)>
288
+
289
+ <!ELEMENT JournalIssue (Volume?, Issue?, PubDate) >
290
+ <!ATTLIST JournalIssue
291
+ CitedMedium (Internet | Print) #REQUIRED >
292
+
293
+ <!ELEMENT Keyword (%text; | mml:math)*>
294
+ <!ATTLIST Keyword
295
+ MajorTopicYN (Y | N) "N" >
296
+
297
+ <!ELEMENT KeywordList (Keyword+) >
298
+ <!ATTLIST KeywordList
299
+ Owner (NLM | NLM-AUTO | NASA | PIP | KIE | NOTNLM | HHS) "NLM" >
300
+
301
+ <!ELEMENT Language (#PCDATA) >
302
+
303
+ <!ELEMENT LastName (#PCDATA) >
304
+
305
+ <!ELEMENT LocationLabel (#PCDATA)>
306
+ <!ATTLIST LocationLabel
307
+ Type (part|chapter|section|appendix|figure|table|box) #IMPLIED >
308
+
309
+ <!ELEMENT Medium (#PCDATA) >
310
+
311
+ <!ELEMENT MedlineDate (#PCDATA) >
312
+
313
+ <!ELEMENT MedlineJournalInfo (Country?, MedlineTA, NlmUniqueID?, ISSNLinking?) >
314
+
315
+ <!ELEMENT MedlinePgn (#PCDATA) >
316
+
317
+ <!ELEMENT MedlineTA (#PCDATA) >
318
+
319
+ <!ELEMENT MeshHeading (DescriptorName, QualifierName*)>
320
+
321
+ <!ELEMENT MeshHeadingList (MeshHeading+)>
322
+
323
+ <!ELEMENT Minute (#PCDATA) >
324
+
325
+ <!ELEMENT Month (#PCDATA) >
326
+
327
+ <!ELEMENT NameOfSubstance (#PCDATA) >
328
+ <!ATTLIST NameOfSubstance
329
+ UI CDATA #REQUIRED >
330
+
331
+ <!ELEMENT NlmUniqueID (#PCDATA) >
332
+
333
+ <!ELEMENT Note (#PCDATA) >
334
+
335
+ <!ELEMENT NumberOfReferences (#PCDATA) >
336
+
337
+ <!ELEMENT Object (Param*)>
338
+ <!ATTLIST Object
339
+ Type CDATA #REQUIRED >
340
+
341
+ <!ELEMENT ObjectList (Object+) >
342
+
343
+ <!ELEMENT OtherAbstract (AbstractText+, CopyrightInformation?) >
344
+
345
+ <!ATTLIST OtherAbstract
346
+ Type (AAMC | AIDS | KIE | PIP | NASA | Publisher) #REQUIRED
347
+ Language CDATA "eng" >
348
+
349
+ <!ELEMENT OtherID (#PCDATA) >
350
+ <!ATTLIST OtherID
351
+ Source (NASA | KIE | PIP | POP | ARPL | CPC | IND | CPFH | CLML |
352
+ NRCBL | NLM | QCIM) #REQUIRED >
353
+
354
+ <!ELEMENT PMID (#PCDATA) >
355
+ <!ATTLIST PMID
356
+ Version CDATA #REQUIRED >
357
+
358
+ <!ELEMENT Pagination ((StartPage, EndPage?, MedlinePgn?) | MedlinePgn) >
359
+
360
+ <!ELEMENT Param (%text;)*>
361
+ <!ATTLIST Param
362
+ Name CDATA #REQUIRED >
363
+
364
+ <!ELEMENT PersonalNameSubject (LastName, ForeName?, Initials?, Suffix?) >
365
+
366
+ <!ELEMENT PersonalNameSubjectList (PersonalNameSubject+) >
367
+
368
+ <!ELEMENT PubDate ((Year, ((Month, Day?) | Season)?) | MedlineDate) >
369
+
370
+ <!ELEMENT PublicationStatus (#PCDATA) >
371
+
372
+ <!ELEMENT PublicationType (#PCDATA) >
373
+ <!ATTLIST PublicationType
374
+ UI CDATA #REQUIRED >
375
+
376
+ <!ELEMENT PublicationTypeList (PublicationType+) >
377
+
378
+ <!ELEMENT PubMedPubDate (Year, Month, Day, (Hour, (Minute, Second?)?)?)>
379
+ <!ATTLIST PubMedPubDate
380
+ PubStatus (received | accepted | epublish |
381
+ ppublish | revised | aheadofprint |
382
+ retracted | ecollection | pmc | pmcr | pubmed | pubmedr |
383
+ premedline | medline | medliner | entrez | pmc-release) #REQUIRED >
384
+
385
+ <!ELEMENT Publisher (PublisherName, PublisherLocation?) >
386
+
387
+ <!ELEMENT PublisherLocation (#PCDATA) >
388
+
389
+ <!ELEMENT PublisherName (%text;)*>
390
+
391
+ <!ELEMENT QualifierName (#PCDATA) >
392
+ <!ATTLIST QualifierName
393
+ MajorTopicYN (Y | N) "N"
394
+ UI CDATA #REQUIRED >
395
+
396
+ <!ELEMENT RefSource (#PCDATA) >
397
+
398
+ <!ELEMENT RegistryNumber (#PCDATA) >
399
+
400
+ <!ELEMENT ReportNumber (#PCDATA) >
401
+
402
+ <!ELEMENT Season (#PCDATA) >
403
+
404
+ <!ELEMENT Second (#PCDATA) >
405
+
406
+
407
+ <!ELEMENT Section (LocationLabel?, SectionTitle, Section*) >
408
+
409
+ <!ELEMENT Sections (Section+) >
410
+
411
+ <!ELEMENT SectionTitle (%text;)*>
412
+ <!ATTLIST SectionTitle %booklinkatts; >
413
+
414
+ <!ELEMENT SpaceFlightMission (#PCDATA) >
415
+
416
+ <!ELEMENT StartPage (#PCDATA) >
417
+
418
+ <!ELEMENT sub (%text;)*> <!-- subscript -->
419
+
420
+ <!ELEMENT Suffix (%text;)*>
421
+
422
+ <!ELEMENT sup (%text;)*> <!-- superscript -->
423
+
424
+ <!ELEMENT SupplMeshList (SupplMeshName+)>
425
+
426
+ <!ELEMENT SupplMeshName (#PCDATA) >
427
+ <!ATTLIST SupplMeshName
428
+ Type (Disease | Protocol | Organism) #REQUIRED
429
+ UI CDATA #REQUIRED >
430
+
431
+ <!ELEMENT Title (#PCDATA) >
432
+
433
+ <!ELEMENT u (%text;)*> <!-- underline -->
434
+
435
+ <!ELEMENT URL (#PCDATA) >
436
+ <!ATTLIST URL
437
+ lang (AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
438
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
439
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
440
+ VI|ZH) #IMPLIED
441
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED >
442
+
443
+ <!ELEMENT VernacularTitle (%text; | mml:math)*>
444
+
445
+ <!ELEMENT Volume (#PCDATA) >
446
+
447
+ <!ELEMENT VolumeTitle (%text;)*>
448
+
449
+ <!ELEMENT Year (#PCDATA) >
450
+
451
+
452
+
453
+
454
+
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_190101.dtd ADDED
@@ -0,0 +1,478 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+
3
+ 2018-09-01
4
+
5
+ This DTD supports both the E-utilities and ftp service data dissemination methods.
6
+ It is based on http://dtd.nlm.nih.gov/ncbi/pubmed/out/pubmed_190101.dtd
7
+
8
+ Additions/Changes since 180601 DTD:
9
+
10
+ 1. Added elements to capture reference citations:
11
+ <ReferenceList>
12
+ <Reference>
13
+ <Citation>
14
+ 2. Removed <CitationString> from book records.
15
+ 3. Added four values to CommentsCorrections/@RefType
16
+ CorrectedandRepublishedIn
17
+ CorrectedandRepublishedFrom
18
+ RetractedandRepublishedIn
19
+ RetractedandRepublishedFrom
20
+ 4. Added "plain-language-summary" to allowed values for @Type on
21
+ <OtherAbstract>
22
+
23
+ NOTE: The use of "Medline" in a DTD or element name does not mean the record
24
+ represents a citation from a MEDLINE-selected journal. When the NLM DTDs and
25
+ XML elements were first created, MEDLINE records were the only data exported.
26
+ Now NLM exports citations other than MEDLINE records using these tools. To
27
+ minimize unnecessary disruption to users of the data and tools, NLM has
28
+ retained the original DTD and element names (e.g., MedlineTA, MedlineJournalInfo).
29
+
30
+ NOTE: StartPage and EndPage in Pagination element are not currently used; are
31
+ reserved for future use.
32
+
33
+ * = 0 or more occurrences (optional element, repeatable)
34
+ ? = 0 or 1 occurrences (optional element, at most 1)
35
+ + = 1 or more occurrences (required element, repeatable)
36
+ | = choice, one or the other but not both
37
+ no symbol = required element
38
+
39
+ -->
40
+
41
+ <!-- ============================================================= -->
42
+ <!-- MATHML 3.0 SETUP -->
43
+ <!-- ============================================================= -->
44
+ <!-- MATHML SETUP FILE -->
45
+ <!ENTITY % mathml-in-pubmed SYSTEM "mathml-in-pubmed.mod" >
46
+ %mathml-in-pubmed;
47
+
48
+
49
+
50
+ <!-- ================================================================= -->
51
+ <!-- ================================================================= -->
52
+ <!ENTITY % text "#PCDATA | b | i | sup | sub | u" >
53
+
54
+ <!ENTITY % booklinkatts
55
+ "book CDATA #IMPLIED
56
+ part CDATA #IMPLIED
57
+ sec CDATA #IMPLIED" >
58
+ <!-- ================================================================= -->
59
+ <!-- ================================================================= -->
60
+
61
+ <!-- ================= Set-level elements ============================-->
62
+ <!ELEMENT PubmedArticleSet ((PubmedArticle | PubmedBookArticle)+, DeleteCitation?) >
63
+ <!ATTLIST PubmedArticleSet
64
+ >
65
+
66
+ <!ELEMENT BookDocumentSet (BookDocument*, DeleteDocument?) >
67
+ <!ATTLIST BookDocumentSet
68
+ >
69
+
70
+ <!ELEMENT PubmedBookArticleSet (PubmedBookArticle*)>
71
+ <!ATTLIST PubmedBookArticleSet
72
+ >
73
+
74
+
75
+ <!-- ============= Document-level elements ============================-->
76
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
77
+ <!ATTLIST PubmedArticle
78
+ >
79
+
80
+ <!ELEMENT PubmedBookArticle (BookDocument, PubmedBookData?)>
81
+ <!ATTLIST PubmedBookArticle
82
+ >
83
+
84
+ <!ELEMENT BookDocument ( PMID, ArticleIdList, Book, LocationLabel*, ArticleTitle?, VernacularTitle?,
85
+ Pagination?, Language*, AuthorList*, InvestigatorList?, PublicationType*, Abstract?, Sections?, KeywordList*,
86
+ ContributionDate?, DateRevised?, GrantList?, ItemList*, ReferenceList*) >
87
+
88
+ <!ELEMENT DeleteCitation (PMID+) >
89
+
90
+ <!ELEMENT DeleteDocument (PMID*) >
91
+
92
+
93
+ <!-- =============== Sub-Document wrapper elements =====================-->
94
+ <!ELEMENT MedlineCitation (PMID, DateCompleted?, DateRevised?, Article,
95
+ MedlineJournalInfo, ChemicalList?, SupplMeshList?,CitationSubset*,
96
+ CommentsCorrectionsList?, GeneSymbolList?, MeshHeadingList?,
97
+ NumberOfReferences?, PersonalNameSubjectList?, OtherID*, OtherAbstract*,
98
+ KeywordList*, CoiStatement?, SpaceFlightMission*, InvestigatorList?, GeneralNote*)>
99
+ <!ATTLIST MedlineCitation
100
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD | NOTNLM) "NLM"
101
+ Status (Completed | In-Process | PubMed-not-MEDLINE | In-Data-Review | Publisher |
102
+ MEDLINE | OLDMEDLINE) #REQUIRED
103
+ VersionID CDATA #IMPLIED
104
+ VersionDate CDATA #IMPLIED
105
+ IndexingMethod CDATA #IMPLIED >
106
+
107
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?, ReferenceList*) >
108
+
109
+ <!ELEMENT PubmedBookData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
110
+
111
+ <!ELEMENT Article (Journal,ArticleTitle,((Pagination, ELocationID*) | ELocationID+),
112
+ Abstract?,AuthorList?, Language+, DataBankList?, GrantList?,
113
+ PublicationTypeList, VernacularTitle?, ArticleDate*) >
114
+ <!ATTLIST Article
115
+ PubModel (Print | Print-Electronic | Electronic | Electronic-Print | Electronic-eCollection) #REQUIRED >
116
+
117
+
118
+
119
+
120
+ <!-- ================================================================= -->
121
+ <!-- Everything else in alphabetical order -->
122
+ <!-- ================================================================= -->
123
+
124
+ <!ELEMENT Abstract (AbstractText+, CopyrightInformation?)>
125
+
126
+ <!ELEMENT AbstractText (%text; | mml:math | DispFormula)* >
127
+ <!ATTLIST AbstractText
128
+ Label CDATA #IMPLIED
129
+ NlmCategory (BACKGROUND | OBJECTIVE | METHODS | RESULTS | CONCLUSIONS | UNASSIGNED) #IMPLIED >
130
+
131
+ <!ELEMENT AccessionNumber (#PCDATA) >
132
+
133
+ <!ELEMENT AccessionNumberList (AccessionNumber+) >
134
+
135
+ <!ELEMENT Acronym (#PCDATA) >
136
+
137
+ <!ELEMENT Affiliation (%text;)*>
138
+
139
+ <!ELEMENT AffiliationInfo (Affiliation, Identifier*)>
140
+
141
+ <!ELEMENT Agency (#PCDATA) >
142
+
143
+ <!ELEMENT ArticleDate (Year, Month, Day) >
144
+ <!ATTLIST ArticleDate
145
+ DateType CDATA #FIXED "Electronic" >
146
+
147
+ <!ELEMENT ArticleId (#PCDATA) >
148
+ <!ATTLIST ArticleId
149
+ IdType (doi | pii | pmcpid | pmpid | pmc | mid |
150
+ sici | pubmed | medline | pmcid | pmcbook | bookaccession) "pubmed" >
151
+
152
+ <!ELEMENT ArticleIdList (ArticleId+)>
153
+
154
+ <!ELEMENT ArticleTitle (%text; | mml:math)*>
155
+ <!ATTLIST ArticleTitle %booklinkatts; >
156
+
157
+ <!ELEMENT Author (((LastName, ForeName?, Initials?, Suffix?) | CollectiveName), Identifier*, AffiliationInfo*) >
158
+ <!ATTLIST Author
159
+ ValidYN (Y | N) "Y"
160
+ EqualContrib (Y | N) #IMPLIED >
161
+
162
+ <!ELEMENT AuthorList (Author+) >
163
+ <!ATTLIST AuthorList
164
+ CompleteYN (Y | N) "Y"
165
+ Type ( authors | editors ) #IMPLIED >
166
+
167
+ <!ELEMENT b (%text;)*> <!-- bold -->
168
+
169
+ <!ELEMENT BeginningDate ( Year, ((Month, Day?) | Season)? ) >
170
+
171
+ <!ELEMENT Book ( Publisher, BookTitle, PubDate, BeginningDate?, EndingDate?, AuthorList*, InvestigatorList?, Volume?,
172
+ VolumeTitle?, Edition?, CollectionTitle?, Isbn*, ELocationID*, Medium?, ReportNumber?) >
173
+
174
+ <!ELEMENT BookTitle (%text; | mml:math)*>
175
+ <!ATTLIST BookTitle %booklinkatts; >
176
+
177
+ <!ELEMENT Chemical (RegistryNumber, NameOfSubstance) >
178
+
179
+ <!ELEMENT ChemicalList (Chemical+) >
180
+
181
+ <!ELEMENT Citation (%text; | mml:math)*>
182
+
183
+ <!ELEMENT CitationSubset (#PCDATA) >
184
+
185
+ <!ELEMENT CoiStatement (%text;)*>
186
+
187
+ <!ELEMENT CollectionTitle (%text; | mml:math)*>
188
+ <!ATTLIST CollectionTitle %booklinkatts; >
189
+
190
+ <!ELEMENT CollectiveName (%text;)*>
191
+
192
+ <!ELEMENT CommentsCorrections (RefSource,PMID?,Note?) >
193
+ <!ATTLIST CommentsCorrections
194
+ RefType (AssociatedDataset |
195
+ AssociatedPublication |
196
+ CommentIn | CommentOn |
197
+ CorrectedandRepublishedIn | CorrectedandRepublishedFrom |
198
+ ErratumIn | ErratumFor |
199
+ ExpressionOfConcernIn | ExpressionOfConcernFor |
200
+ RepublishedIn | RepublishedFrom |
201
+ RetractedandRepublishedIn | RetractedandRepublishedFrom |
202
+ RetractionIn | RetractionOf |
203
+ UpdateIn | UpdateOf |
204
+ SummaryForPatientsIn |
205
+ OriginalReportIn |
206
+ ReprintIn | ReprintOf |
207
+ Cites) #REQUIRED >
208
+
209
+
210
+ <!ELEMENT CommentsCorrectionsList (CommentsCorrections+) >
211
+
212
+ <!ELEMENT ContractNumber (#PCDATA) >
213
+
214
+ <!ELEMENT ContributionDate ( Year, ((Month, Day?) | Season)? ) >
215
+
216
+ <!ELEMENT CopyrightInformation (#PCDATA) >
217
+
218
+ <!ELEMENT Country (#PCDATA) >
219
+
220
+ <!ELEMENT DataBank (DataBankName, AccessionNumberList?) >
221
+
222
+ <!ELEMENT DataBankList (DataBank+) >
223
+
224
+ <!ATTLIST DataBankList
225
+ CompleteYN (Y | N) "Y" >
226
+
227
+ <!ELEMENT DataBankName (#PCDATA) >
228
+
229
+ <!ELEMENT DateCompleted (Year,Month,Day) >
230
+
231
+ <!ELEMENT DateRevised (Year,Month,Day) >
232
+
233
+ <!ELEMENT Day (#PCDATA )>
234
+
235
+ <!ELEMENT DescriptorName (#PCDATA) >
236
+ <!ATTLIST DescriptorName
237
+ MajorTopicYN (Y | N) "N"
238
+ Type (Geographic) #IMPLIED
239
+ UI CDATA #REQUIRED >
240
+
241
+ <!ELEMENT DispFormula (mml:math) >
242
+ <!ELEMENT Edition (#PCDATA) >
243
+
244
+ <!ELEMENT ELocationID (#PCDATA) >
245
+ <!ATTLIST ELocationID
246
+ EIdType (doi | pii) #REQUIRED
247
+ ValidYN (Y | N) "Y">
248
+
249
+ <!ELEMENT EndingDate ( Year, ((Month, Day?) | Season)? ) >
250
+
251
+ <!ELEMENT EndPage (#PCDATA) >
252
+
253
+ <!ELEMENT ForeName (#PCDATA) >
254
+
255
+ <!ELEMENT GeneSymbol (#PCDATA) >
256
+
257
+ <!ELEMENT GeneSymbolList (GeneSymbol+)>
258
+
259
+ <!ELEMENT GeneralNote (#PCDATA) >
260
+ <!ATTLIST GeneralNote
261
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD) "NLM" >
262
+
263
+ <!ELEMENT Grant (GrantID?, Acronym?, Agency, Country)>
264
+
265
+ <!ELEMENT GrantID (#PCDATA) >
266
+
267
+ <!ELEMENT GrantList (Grant+)>
268
+ <!ATTLIST GrantList
269
+ CompleteYN (Y | N) "Y">
270
+
271
+ <!ELEMENT History (PubMedPubDate+) >
272
+
273
+ <!ELEMENT Hour (#PCDATA) >
274
+
275
+ <!ELEMENT i (%text;)*> <!-- italic -->
276
+
277
+ <!ELEMENT Identifier (#PCDATA) >
278
+ <!ATTLIST Identifier
279
+ Source CDATA #REQUIRED >
280
+
281
+ <!ELEMENT Initials (#PCDATA) >
282
+
283
+ <!ELEMENT Investigator (LastName, ForeName?, Initials?, Suffix?, Identifier*, AffiliationInfo*) >
284
+ <!ATTLIST Investigator
285
+ ValidYN (Y | N) "Y" >
286
+
287
+ <!ELEMENT InvestigatorList (Investigator+) >
288
+
289
+ <!ELEMENT Isbn (#PCDATA) >
290
+
291
+ <!ELEMENT ISOAbbreviation (#PCDATA) >
292
+
293
+ <!ELEMENT ISSN (#PCDATA) >
294
+ <!ATTLIST ISSN
295
+ IssnType (Electronic | Print) #REQUIRED >
296
+
297
+ <!ELEMENT ISSNLinking (#PCDATA) >
298
+
299
+ <!ELEMENT Issue (#PCDATA) >
300
+ <!ELEMENT Item (#PCDATA)>
301
+
302
+ <!ELEMENT ItemList (Item+)>
303
+ <!ATTLIST ItemList
304
+ ListType CDATA #REQUIRED>
305
+
306
+ <!ELEMENT Journal (ISSN?, JournalIssue, Title?, ISOAbbreviation?)>
307
+
308
+ <!ELEMENT JournalIssue (Volume?, Issue?, PubDate) >
309
+ <!ATTLIST JournalIssue
310
+ CitedMedium (Internet | Print) #REQUIRED >
311
+
312
+ <!ELEMENT Keyword (%text; | mml:math)*>
313
+ <!ATTLIST Keyword
314
+ MajorTopicYN (Y | N) "N" >
315
+
316
+ <!ELEMENT KeywordList (Keyword+) >
317
+ <!ATTLIST KeywordList
318
+ Owner (NLM | NLM-AUTO | NASA | PIP | KIE | NOTNLM | HHS) "NLM" >
319
+
320
+ <!ELEMENT Language (#PCDATA) >
321
+
322
+ <!ELEMENT LastName (#PCDATA) >
323
+
324
+ <!ELEMENT LocationLabel (#PCDATA)>
325
+ <!ATTLIST LocationLabel
326
+ Type (part|chapter|section|appendix|figure|table|box) #IMPLIED >
327
+
328
+ <!ELEMENT Medium (#PCDATA) >
329
+
330
+ <!ELEMENT MedlineDate (#PCDATA) >
331
+
332
+ <!ELEMENT MedlineJournalInfo (Country?, MedlineTA, NlmUniqueID?, ISSNLinking?) >
333
+
334
+ <!ELEMENT MedlinePgn (#PCDATA) >
335
+
336
+ <!ELEMENT MedlineTA (#PCDATA) >
337
+
338
+ <!ELEMENT MeshHeading (DescriptorName, QualifierName*)>
339
+
340
+ <!ELEMENT MeshHeadingList (MeshHeading+)>
341
+
342
+ <!ELEMENT Minute (#PCDATA) >
343
+
344
+ <!ELEMENT Month (#PCDATA) >
345
+
346
+ <!ELEMENT NameOfSubstance (#PCDATA) >
347
+ <!ATTLIST NameOfSubstance
348
+ UI CDATA #REQUIRED >
349
+
350
+ <!ELEMENT NlmUniqueID (#PCDATA) >
351
+
352
+ <!ELEMENT Note (#PCDATA) >
353
+
354
+ <!ELEMENT NumberOfReferences (#PCDATA) >
355
+
356
+ <!ELEMENT Object (Param*)>
357
+ <!ATTLIST Object
358
+ Type CDATA #REQUIRED >
359
+
360
+ <!ELEMENT ObjectList (Object+) >
361
+
362
+ <!ELEMENT OtherAbstract (AbstractText+, CopyrightInformation?) >
363
+
364
+ <!ATTLIST OtherAbstract
365
+ Type (AAMC | AIDS | KIE | PIP | NASA | Publisher |
366
+ plain-language-summary) #REQUIRED
367
+ Language CDATA "eng" >
368
+
369
+ <!ELEMENT OtherID (#PCDATA) >
370
+ <!ATTLIST OtherID
371
+ Source (NASA | KIE | PIP | POP | ARPL | CPC | IND | CPFH | CLML |
372
+ NRCBL | NLM | QCIM) #REQUIRED >
373
+
374
+ <!ELEMENT PMID (#PCDATA) >
375
+ <!ATTLIST PMID
376
+ Version CDATA #REQUIRED >
377
+
378
+ <!ELEMENT Pagination ((StartPage, EndPage?, MedlinePgn?) | MedlinePgn) >
379
+
380
+ <!ELEMENT Param (%text;)*>
381
+ <!ATTLIST Param
382
+ Name CDATA #REQUIRED >
383
+
384
+ <!ELEMENT PersonalNameSubject (LastName, ForeName?, Initials?, Suffix?) >
385
+
386
+ <!ELEMENT PersonalNameSubjectList (PersonalNameSubject+) >
387
+
388
+ <!ELEMENT PubDate ((Year, ((Month, Day?) | Season)?) | MedlineDate) >
389
+
390
+ <!ELEMENT PublicationStatus (#PCDATA) >
391
+
392
+ <!ELEMENT PublicationType (#PCDATA) >
393
+ <!ATTLIST PublicationType
394
+ UI CDATA #REQUIRED >
395
+
396
+ <!ELEMENT PublicationTypeList (PublicationType+) >
397
+
398
+ <!ELEMENT PubMedPubDate (Year, Month, Day, (Hour, (Minute, Second?)?)?)>
399
+ <!ATTLIST PubMedPubDate
400
+ PubStatus (received | accepted | epublish |
401
+ ppublish | revised | aheadofprint |
402
+ retracted | ecollection | pmc | pmcr | pubmed | pubmedr |
403
+ premedline | medline | medliner | entrez | pmc-release) #REQUIRED >
404
+
405
+ <!ELEMENT Publisher (PublisherName, PublisherLocation?) >
406
+
407
+ <!ELEMENT PublisherLocation (#PCDATA) >
408
+
409
+ <!ELEMENT PublisherName (%text;)*>
410
+
411
+ <!ELEMENT QualifierName (#PCDATA) >
412
+ <!ATTLIST QualifierName
413
+ MajorTopicYN (Y | N) "N"
414
+ UI CDATA #REQUIRED >
415
+
416
+ <!ELEMENT Reference (Citation, ArticleIdList?) >
417
+
418
+ <!ELEMENT ReferenceList (Title?, Reference*, ReferenceList*) >
419
+
420
+ <!ELEMENT RefSource (#PCDATA) >
421
+
422
+ <!ELEMENT RegistryNumber (#PCDATA) >
423
+
424
+ <!ELEMENT ReportNumber (#PCDATA) >
425
+
426
+ <!ELEMENT Season (#PCDATA) >
427
+
428
+ <!ELEMENT Second (#PCDATA) >
429
+
430
+
431
+ <!ELEMENT Section (LocationLabel?, SectionTitle, Section*) >
432
+
433
+ <!ELEMENT Sections (Section+) >
434
+
435
+ <!ELEMENT SectionTitle (%text;)*>
436
+ <!ATTLIST SectionTitle %booklinkatts; >
437
+
438
+ <!ELEMENT SpaceFlightMission (#PCDATA) >
439
+
440
+ <!ELEMENT StartPage (#PCDATA) >
441
+
442
+ <!ELEMENT sub (%text;)*> <!-- subscript -->
443
+
444
+ <!ELEMENT Suffix (%text;)*>
445
+
446
+ <!ELEMENT sup (%text;)*> <!-- superscript -->
447
+
448
+ <!ELEMENT SupplMeshList (SupplMeshName+)>
449
+
450
+ <!ELEMENT SupplMeshName (#PCDATA) >
451
+ <!ATTLIST SupplMeshName
452
+ Type (Disease | Protocol | Organism) #REQUIRED
453
+ UI CDATA #REQUIRED >
454
+
455
+ <!ELEMENT Title (#PCDATA) >
456
+
457
+ <!ELEMENT u (%text;)*> <!-- underline -->
458
+
459
+ <!ELEMENT URL (#PCDATA) >
460
+ <!ATTLIST URL
461
+ lang (AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
462
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
463
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
464
+ VI|ZH) #IMPLIED
465
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED >
466
+
467
+ <!ELEMENT VernacularTitle (%text; | mml:math)*>
468
+
469
+ <!ELEMENT Volume (#PCDATA) >
470
+
471
+ <!ELEMENT VolumeTitle (%text;)*>
472
+
473
+ <!ELEMENT Year (#PCDATA) >
474
+
475
+
476
+
477
+
478
+
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_230101.dtd ADDED
@@ -0,0 +1,468 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+
3
+ 2022-12-06
4
+
5
+ This DTD supports both the E-utilities and ftp service data dissemination methods.
6
+ It is based on http://dtd.nlm.nih.gov/ncbi/pubmed/out/pubmed_230101.dtd
7
+
8
+ Additions/Changes since pubmed_190101 DTD:
9
+
10
+ 1. added values "Population" and "Anatomy" to a list of allowed values
11
+ of "Type" attribute of "SupplMeshName".
12
+
13
+ NOTE: The use of "Medline" in a DTD or element name does not mean the record
14
+ represents a citation from a MEDLINE-selected journal. When the NLM DTDs and
15
+ XML elements were first created, MEDLINE records were the only data exported.
16
+ Now NLM exports citations other than MEDLINE records using these tools. To
17
+ minimize unnecessary disruption to users of the data and tools, NLM has
18
+ retained the original DTD and element names (e.g., MedlineTA, MedlineJournalInfo).
19
+
20
+ NOTE: The updated PubMed API now allows for the use of the StartPage and
21
+ EndPage elements in Pagination.
22
+
23
+ * = 0 or more occurrences (optional element, repeatable)
24
+ ? = 0 or 1 occurrences (optional element, at most 1)
25
+ + = 1 or more occurrences (required element, repeatable)
26
+ | = choice, one or the other but not both
27
+ no symbol = required element
28
+
29
+ -->
30
+
31
+ <!-- ============================================================= -->
32
+ <!-- MATHML 3.0 SETUP -->
33
+ <!-- ============================================================= -->
34
+ <!-- MATHML SETUP FILE -->
35
+ <!ENTITY % mathml-in-pubmed SYSTEM "mathml-in-pubmed.mod" >
36
+ %mathml-in-pubmed;
37
+
38
+
39
+
40
+ <!-- ================================================================= -->
41
+ <!-- ================================================================= -->
42
+ <!ENTITY % text "#PCDATA | b | i | sup | sub | u" >
43
+
44
+ <!ENTITY % booklinkatts
45
+ "book CDATA #IMPLIED
46
+ part CDATA #IMPLIED
47
+ sec CDATA #IMPLIED" >
48
+ <!-- ================================================================= -->
49
+ <!-- ================================================================= -->
50
+
51
+ <!-- ================= Set-level elements ============================-->
52
+ <!ELEMENT PubmedArticleSet ((PubmedArticle | PubmedBookArticle)+, DeleteCitation?) >
53
+ <!ATTLIST PubmedArticleSet
54
+ >
55
+
56
+ <!ELEMENT BookDocumentSet (BookDocument*, DeleteDocument?) >
57
+ <!ATTLIST BookDocumentSet
58
+ >
59
+
60
+ <!ELEMENT PubmedBookArticleSet (PubmedBookArticle*)>
61
+ <!ATTLIST PubmedBookArticleSet
62
+ >
63
+
64
+
65
+ <!-- ============= Document-level elements ============================-->
66
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
67
+ <!ATTLIST PubmedArticle
68
+ >
69
+
70
+ <!ELEMENT PubmedBookArticle (BookDocument, PubmedBookData?)>
71
+ <!ATTLIST PubmedBookArticle
72
+ >
73
+
74
+ <!ELEMENT BookDocument ( PMID, ArticleIdList, Book, LocationLabel*, ArticleTitle?, VernacularTitle?,
75
+ Pagination?, Language*, AuthorList*, InvestigatorList?, PublicationType*, Abstract?, Sections?, KeywordList*,
76
+ ContributionDate?, DateRevised?, GrantList?, ItemList*, ReferenceList*) >
77
+
78
+ <!ELEMENT DeleteCitation (PMID+) >
79
+
80
+ <!ELEMENT DeleteDocument (PMID*) >
81
+
82
+
83
+ <!-- =============== Sub-Document wrapper elements =====================-->
84
+ <!ELEMENT MedlineCitation (PMID, DateCompleted?, DateRevised?, Article,
85
+ MedlineJournalInfo, ChemicalList?, SupplMeshList?,CitationSubset*,
86
+ CommentsCorrectionsList?, GeneSymbolList?, MeshHeadingList?,
87
+ NumberOfReferences?, PersonalNameSubjectList?, OtherID*, OtherAbstract*,
88
+ KeywordList*, CoiStatement?, SpaceFlightMission*, InvestigatorList?, GeneralNote*)>
89
+ <!ATTLIST MedlineCitation
90
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD | NOTNLM) "NLM"
91
+ Status (Completed | In-Process | PubMed-not-MEDLINE | In-Data-Review | Publisher |
92
+ MEDLINE | OLDMEDLINE) #REQUIRED
93
+ VersionID CDATA #IMPLIED
94
+ VersionDate CDATA #IMPLIED
95
+ IndexingMethod CDATA #IMPLIED >
96
+
97
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?, ReferenceList*) >
98
+
99
+ <!ELEMENT PubmedBookData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
100
+
101
+ <!ELEMENT Article (Journal,ArticleTitle,((Pagination, ELocationID*) | ELocationID+),
102
+ Abstract?,AuthorList?, Language+, DataBankList?, GrantList?,
103
+ PublicationTypeList, VernacularTitle?, ArticleDate*) >
104
+ <!ATTLIST Article
105
+ PubModel (Print | Print-Electronic | Electronic | Electronic-Print | Electronic-eCollection) #REQUIRED >
106
+
107
+
108
+
109
+
110
+ <!-- ================================================================= -->
111
+ <!-- Everything else in alphabetical order -->
112
+ <!-- ================================================================= -->
113
+
114
+ <!ELEMENT Abstract (AbstractText+, CopyrightInformation?)>
115
+
116
+ <!ELEMENT AbstractText (%text; | mml:math | DispFormula)* >
117
+ <!ATTLIST AbstractText
118
+ Label CDATA #IMPLIED
119
+ NlmCategory (BACKGROUND | OBJECTIVE | METHODS | RESULTS | CONCLUSIONS | UNASSIGNED) #IMPLIED >
120
+
121
+ <!ELEMENT AccessionNumber (#PCDATA) >
122
+
123
+ <!ELEMENT AccessionNumberList (AccessionNumber+) >
124
+
125
+ <!ELEMENT Acronym (#PCDATA) >
126
+
127
+ <!ELEMENT Affiliation (%text;)*>
128
+
129
+ <!ELEMENT AffiliationInfo (Affiliation, Identifier*)>
130
+
131
+ <!ELEMENT Agency (#PCDATA) >
132
+
133
+ <!ELEMENT ArticleDate (Year, Month, Day) >
134
+ <!ATTLIST ArticleDate
135
+ DateType CDATA #FIXED "Electronic" >
136
+
137
+ <!ELEMENT ArticleId (#PCDATA) >
138
+ <!ATTLIST ArticleId
139
+ IdType (doi | pii | pmcpid | pmpid | pmc | mid |
140
+ sici | pubmed | medline | pmcid | pmcbook | bookaccession) "pubmed" >
141
+
142
+ <!ELEMENT ArticleIdList (ArticleId+)>
143
+
144
+ <!ELEMENT ArticleTitle (%text; | mml:math)*>
145
+ <!ATTLIST ArticleTitle %booklinkatts; >
146
+
147
+ <!ELEMENT Author (((LastName, ForeName?, Initials?, Suffix?) | CollectiveName), Identifier*, AffiliationInfo*) >
148
+ <!ATTLIST Author
149
+ ValidYN (Y | N) "Y"
150
+ EqualContrib (Y | N) #IMPLIED >
151
+
152
+ <!ELEMENT AuthorList (Author+) >
153
+ <!ATTLIST AuthorList
154
+ CompleteYN (Y | N) "Y"
155
+ Type ( authors | editors ) #IMPLIED >
156
+
157
+ <!ELEMENT b (%text;)*> <!-- bold -->
158
+
159
+ <!ELEMENT BeginningDate ( Year, ((Month, Day?) | Season)? ) >
160
+
161
+ <!ELEMENT Book ( Publisher, BookTitle, PubDate, BeginningDate?, EndingDate?, AuthorList*, InvestigatorList?, Volume?,
162
+ VolumeTitle?, Edition?, CollectionTitle?, Isbn*, ELocationID*, Medium?, ReportNumber?) >
163
+
164
+ <!ELEMENT BookTitle (%text; | mml:math)*>
165
+ <!ATTLIST BookTitle %booklinkatts; >
166
+
167
+ <!ELEMENT Chemical (RegistryNumber, NameOfSubstance) >
168
+
169
+ <!ELEMENT ChemicalList (Chemical+) >
170
+
171
+ <!ELEMENT Citation (%text; | mml:math)*>
172
+
173
+ <!ELEMENT CitationSubset (#PCDATA) >
174
+
175
+ <!ELEMENT CoiStatement (%text;)*>
176
+
177
+ <!ELEMENT CollectionTitle (%text; | mml:math)*>
178
+ <!ATTLIST CollectionTitle %booklinkatts; >
179
+
180
+ <!ELEMENT CollectiveName (%text;)*>
181
+
182
+ <!ELEMENT CommentsCorrections (RefSource,PMID?,Note?) >
183
+ <!ATTLIST CommentsCorrections
184
+ RefType (AssociatedDataset |
185
+ AssociatedPublication |
186
+ CommentIn | CommentOn |
187
+ CorrectedandRepublishedIn | CorrectedandRepublishedFrom |
188
+ ErratumIn | ErratumFor |
189
+ ExpressionOfConcernIn | ExpressionOfConcernFor |
190
+ RepublishedIn | RepublishedFrom |
191
+ RetractedandRepublishedIn | RetractedandRepublishedFrom |
192
+ RetractionIn | RetractionOf |
193
+ UpdateIn | UpdateOf |
194
+ SummaryForPatientsIn |
195
+ OriginalReportIn |
196
+ ReprintIn | ReprintOf |
197
+ Cites) #REQUIRED >
198
+
199
+
200
+ <!ELEMENT CommentsCorrectionsList (CommentsCorrections+) >
201
+
202
+ <!ELEMENT ContractNumber (#PCDATA) >
203
+
204
+ <!ELEMENT ContributionDate ( Year, ((Month, Day?) | Season)? ) >
205
+
206
+ <!ELEMENT CopyrightInformation (#PCDATA) >
207
+
208
+ <!ELEMENT Country (#PCDATA) >
209
+
210
+ <!ELEMENT DataBank (DataBankName, AccessionNumberList?) >
211
+
212
+ <!ELEMENT DataBankList (DataBank+) >
213
+
214
+ <!ATTLIST DataBankList
215
+ CompleteYN (Y | N) "Y" >
216
+
217
+ <!ELEMENT DataBankName (#PCDATA) >
218
+
219
+ <!ELEMENT DateCompleted (Year,Month,Day) >
220
+
221
+ <!ELEMENT DateRevised (Year,Month,Day) >
222
+
223
+ <!ELEMENT Day (#PCDATA )>
224
+
225
+ <!ELEMENT DescriptorName (#PCDATA) >
226
+ <!ATTLIST DescriptorName
227
+ MajorTopicYN (Y | N) "N"
228
+ Type (Geographic) #IMPLIED
229
+ UI CDATA #REQUIRED >
230
+
231
+ <!ELEMENT DispFormula (mml:math) >
232
+ <!ELEMENT Edition (#PCDATA) >
233
+
234
+ <!ELEMENT ELocationID (#PCDATA) >
235
+ <!ATTLIST ELocationID
236
+ EIdType (doi | pii) #REQUIRED
237
+ ValidYN (Y | N) "Y">
238
+
239
+ <!ELEMENT EndingDate ( Year, ((Month, Day?) | Season)? ) >
240
+
241
+ <!ELEMENT EndPage (#PCDATA) >
242
+
243
+ <!ELEMENT ForeName (#PCDATA) >
244
+
245
+ <!ELEMENT GeneSymbol (#PCDATA) >
246
+
247
+ <!ELEMENT GeneSymbolList (GeneSymbol+)>
248
+
249
+ <!ELEMENT GeneralNote (#PCDATA) >
250
+ <!ATTLIST GeneralNote
251
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD) "NLM" >
252
+
253
+ <!ELEMENT Grant (GrantID?, Acronym?, Agency, Country)>
254
+
255
+ <!ELEMENT GrantID (#PCDATA) >
256
+
257
+ <!ELEMENT GrantList (Grant+)>
258
+ <!ATTLIST GrantList
259
+ CompleteYN (Y | N) "Y">
260
+
261
+ <!ELEMENT History (PubMedPubDate+) >
262
+
263
+ <!ELEMENT Hour (#PCDATA) >
264
+
265
+ <!ELEMENT i (%text;)*> <!-- italic -->
266
+
267
+ <!ELEMENT Identifier (#PCDATA) >
268
+ <!ATTLIST Identifier
269
+ Source CDATA #REQUIRED >
270
+
271
+ <!ELEMENT Initials (#PCDATA) >
272
+
273
+ <!ELEMENT Investigator (LastName, ForeName?, Initials?, Suffix?, Identifier*, AffiliationInfo*) >
274
+ <!ATTLIST Investigator
275
+ ValidYN (Y | N) "Y" >
276
+
277
+ <!ELEMENT InvestigatorList (Investigator+) >
278
+
279
+ <!ELEMENT Isbn (#PCDATA) >
280
+
281
+ <!ELEMENT ISOAbbreviation (#PCDATA) >
282
+
283
+ <!ELEMENT ISSN (#PCDATA) >
284
+ <!ATTLIST ISSN
285
+ IssnType (Electronic | Print) #REQUIRED >
286
+
287
+ <!ELEMENT ISSNLinking (#PCDATA) >
288
+
289
+ <!ELEMENT Issue (#PCDATA) >
290
+ <!ELEMENT Item (#PCDATA)>
291
+
292
+ <!ELEMENT ItemList (Item+)>
293
+ <!ATTLIST ItemList
294
+ ListType CDATA #REQUIRED>
295
+
296
+ <!ELEMENT Journal (ISSN?, JournalIssue, Title?, ISOAbbreviation?)>
297
+
298
+ <!ELEMENT JournalIssue (Volume?, Issue?, PubDate) >
299
+ <!ATTLIST JournalIssue
300
+ CitedMedium (Internet | Print) #REQUIRED >
301
+
302
+ <!ELEMENT Keyword (%text; | mml:math)*>
303
+ <!ATTLIST Keyword
304
+ MajorTopicYN (Y | N) "N" >
305
+
306
+ <!ELEMENT KeywordList (Keyword+) >
307
+ <!ATTLIST KeywordList
308
+ Owner (NLM | NLM-AUTO | NASA | PIP | KIE | NOTNLM | HHS) "NLM" >
309
+
310
+ <!ELEMENT Language (#PCDATA) >
311
+
312
+ <!ELEMENT LastName (#PCDATA) >
313
+
314
+ <!ELEMENT LocationLabel (#PCDATA)>
315
+ <!ATTLIST LocationLabel
316
+ Type (part|chapter|section|appendix|figure|table|box) #IMPLIED >
317
+
318
+ <!ELEMENT Medium (#PCDATA) >
319
+
320
+ <!ELEMENT MedlineDate (#PCDATA) >
321
+
322
+ <!ELEMENT MedlineJournalInfo (Country?, MedlineTA, NlmUniqueID?, ISSNLinking?) >
323
+
324
+ <!ELEMENT MedlinePgn (#PCDATA) >
325
+
326
+ <!ELEMENT MedlineTA (#PCDATA) >
327
+
328
+ <!ELEMENT MeshHeading (DescriptorName, QualifierName*)>
329
+
330
+ <!ELEMENT MeshHeadingList (MeshHeading+)>
331
+
332
+ <!ELEMENT Minute (#PCDATA) >
333
+
334
+ <!ELEMENT Month (#PCDATA) >
335
+
336
+ <!ELEMENT NameOfSubstance (#PCDATA) >
337
+ <!ATTLIST NameOfSubstance
338
+ UI CDATA #REQUIRED >
339
+
340
+ <!ELEMENT NlmUniqueID (#PCDATA) >
341
+
342
+ <!ELEMENT Note (#PCDATA) >
343
+
344
+ <!ELEMENT NumberOfReferences (#PCDATA) >
345
+
346
+ <!ELEMENT Object (Param*)>
347
+ <!ATTLIST Object
348
+ Type CDATA #REQUIRED >
349
+
350
+ <!ELEMENT ObjectList (Object+) >
351
+
352
+ <!ELEMENT OtherAbstract (AbstractText+, CopyrightInformation?) >
353
+
354
+ <!ATTLIST OtherAbstract
355
+ Type (AAMC | AIDS | KIE | PIP | NASA | Publisher |
356
+ plain-language-summary) #REQUIRED
357
+ Language CDATA "eng" >
358
+
359
+ <!ELEMENT OtherID (#PCDATA) >
360
+ <!ATTLIST OtherID
361
+ Source (NASA | KIE | PIP | POP | ARPL | CPC | IND | CPFH | CLML |
362
+ NRCBL | NLM | QCIM) #REQUIRED >
363
+
364
+ <!ELEMENT PMID (#PCDATA) >
365
+ <!ATTLIST PMID
366
+ Version CDATA #REQUIRED >
367
+
368
+ <!ELEMENT Pagination ((StartPage, EndPage?, MedlinePgn?) | MedlinePgn) >
369
+
370
+ <!ELEMENT Param (%text;)*>
371
+ <!ATTLIST Param
372
+ Name CDATA #REQUIRED >
373
+
374
+ <!ELEMENT PersonalNameSubject (LastName, ForeName?, Initials?, Suffix?) >
375
+
376
+ <!ELEMENT PersonalNameSubjectList (PersonalNameSubject+) >
377
+
378
+ <!ELEMENT PubDate ((Year, ((Month, Day?) | Season)?) | MedlineDate) >
379
+
380
+ <!ELEMENT PublicationStatus (#PCDATA) >
381
+
382
+ <!ELEMENT PublicationType (#PCDATA) >
383
+ <!ATTLIST PublicationType
384
+ UI CDATA #REQUIRED >
385
+
386
+ <!ELEMENT PublicationTypeList (PublicationType+) >
387
+
388
+ <!ELEMENT PubMedPubDate (Year, Month, Day, (Hour, (Minute, Second?)?)?)>
389
+ <!ATTLIST PubMedPubDate
390
+ PubStatus (received | accepted | epublish |
391
+ ppublish | revised | aheadofprint |
392
+ retracted | ecollection | pmc | pmcr | pubmed | pubmedr |
393
+ premedline | medline | medliner | entrez | pmc-release) #REQUIRED >
394
+
395
+ <!ELEMENT Publisher (PublisherName, PublisherLocation?) >
396
+
397
+ <!ELEMENT PublisherLocation (#PCDATA) >
398
+
399
+ <!ELEMENT PublisherName (%text;)*>
400
+
401
+ <!ELEMENT QualifierName (#PCDATA) >
402
+ <!ATTLIST QualifierName
403
+ MajorTopicYN (Y | N) "N"
404
+ UI CDATA #REQUIRED >
405
+
406
+ <!ELEMENT Reference (Citation, ArticleIdList?) >
407
+
408
+ <!ELEMENT ReferenceList (Title?, Reference*, ReferenceList*) >
409
+
410
+ <!ELEMENT RefSource (#PCDATA) >
411
+
412
+ <!ELEMENT RegistryNumber (#PCDATA) >
413
+
414
+ <!ELEMENT ReportNumber (#PCDATA) >
415
+
416
+ <!ELEMENT Season (#PCDATA) >
417
+
418
+ <!ELEMENT Second (#PCDATA) >
419
+
420
+
421
+ <!ELEMENT Section (LocationLabel?, SectionTitle, Section*) >
422
+
423
+ <!ELEMENT Sections (Section+) >
424
+
425
+ <!ELEMENT SectionTitle (%text;)*>
426
+ <!ATTLIST SectionTitle %booklinkatts; >
427
+
428
+ <!ELEMENT SpaceFlightMission (#PCDATA) >
429
+
430
+ <!ELEMENT StartPage (#PCDATA) >
431
+
432
+ <!ELEMENT sub (%text;)*> <!-- subscript -->
433
+
434
+ <!ELEMENT Suffix (%text;)*>
435
+
436
+ <!ELEMENT sup (%text;)*> <!-- superscript -->
437
+
438
+ <!ELEMENT SupplMeshList (SupplMeshName+)>
439
+
440
+ <!ELEMENT SupplMeshName (#PCDATA) >
441
+ <!ATTLIST SupplMeshName
442
+ Type ( Disease | Protocol | Organism | Anatomy | Population ) #REQUIRED
443
+ UI CDATA #REQUIRED >
444
+
445
+ <!ELEMENT Title (#PCDATA) >
446
+
447
+ <!ELEMENT u (%text;)*> <!-- underline -->
448
+
449
+ <!ELEMENT URL (#PCDATA) >
450
+ <!ATTLIST URL
451
+ lang (AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
452
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
453
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
454
+ VI|ZH) #IMPLIED
455
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED >
456
+
457
+ <!ELEMENT VernacularTitle (%text; | mml:math)*>
458
+
459
+ <!ELEMENT Volume (#PCDATA) >
460
+
461
+ <!ELEMENT VolumeTitle (%text;)*>
462
+
463
+ <!ELEMENT Year (#PCDATA) >
464
+
465
+
466
+
467
+
468
+
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_240101.dtd ADDED
@@ -0,0 +1,477 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+
3
+ 2023-08-01
4
+
5
+ This DTD supports both the E-utilities and ftp service data dissemination methods.
6
+ It is based on http://dtd.nlm.nih.gov/ncbi/pubmed/out/pubmed_230101.dtd
7
+
8
+ Additions/Changes since pubmed_230101 DTD:
9
+
10
+ 1. Updated model of "Grant" to make "Country" optional (0 or 1)
11
+
12
+ 2. Added linking between group author names and investigator lists
13
+ - allowed "InvestigatorList" to repeat in "MedlineCitation"
14
+ - added "Investigators" attribute to "CollectiveName"
15
+ - added "ID" attribute on "InvestigatorList"
16
+
17
+
18
+ NOTE: The use of "Medline" in a DTD or element name does not mean the record
19
+ represents a citation from a MEDLINE-selected journal. When the NLM DTDs and
20
+ XML elements were first created, MEDLINE records were the only data exported.
21
+ Now NLM exports citations other than MEDLINE records using these tools. To
22
+ minimize unnecessary disruption to users of the data and tools, NLM has
23
+ retained the original DTD and element names (e.g., MedlineTA, MedlineJournalInfo).
24
+
25
+ NOTE: The updated PubMed API now allows for the use of the StartPage and
26
+ EndPage elements in Pagination.
27
+
28
+ * = 0 or more occurrences (optional element, repeatable)
29
+ ? = 0 or 1 occurrences (optional element, at most 1)
30
+ + = 1 or more occurrences (required element, repeatable)
31
+ | = choice, one or the other but not both
32
+ no symbol = required element
33
+
34
+ -->
35
+
36
+ <!-- ============================================================= -->
37
+ <!-- MATHML 3.0 SETUP -->
38
+ <!-- ============================================================= -->
39
+ <!-- MATHML SETUP FILE -->
40
+ <!ENTITY % mathml-in-pubmed SYSTEM "mathml-in-pubmed.mod" >
41
+ %mathml-in-pubmed;
42
+
43
+
44
+
45
+ <!-- ================================================================= -->
46
+ <!-- ================================================================= -->
47
+ <!ENTITY % text "#PCDATA | b | i | sup | sub | u" >
48
+
49
+ <!ENTITY % booklinkatts
50
+ "book CDATA #IMPLIED
51
+ part CDATA #IMPLIED
52
+ sec CDATA #IMPLIED" >
53
+ <!-- ================================================================= -->
54
+ <!-- ================================================================= -->
55
+
56
+ <!-- ================= Set-level elements ============================-->
57
+ <!ELEMENT PubmedArticleSet ((PubmedArticle | PubmedBookArticle)+, DeleteCitation?) >
58
+ <!ATTLIST PubmedArticleSet
59
+ >
60
+
61
+ <!ELEMENT BookDocumentSet (BookDocument*, DeleteDocument?) >
62
+ <!ATTLIST BookDocumentSet
63
+ >
64
+
65
+ <!ELEMENT PubmedBookArticleSet (PubmedBookArticle*)>
66
+ <!ATTLIST PubmedBookArticleSet
67
+ >
68
+
69
+
70
+ <!-- ============= Document-level elements ============================-->
71
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
72
+ <!ATTLIST PubmedArticle
73
+ >
74
+
75
+ <!ELEMENT PubmedBookArticle (BookDocument, PubmedBookData?)>
76
+ <!ATTLIST PubmedBookArticle
77
+ >
78
+
79
+ <!ELEMENT BookDocument ( PMID, ArticleIdList, Book, LocationLabel*, ArticleTitle?, VernacularTitle?,
80
+ Pagination?, Language*, AuthorList*, InvestigatorList?, PublicationType*, Abstract?, Sections?, KeywordList*,
81
+ ContributionDate?, DateRevised?, GrantList?, ItemList*, ReferenceList*) >
82
+
83
+ <!ELEMENT DeleteCitation (PMID+) >
84
+
85
+ <!ELEMENT DeleteDocument (PMID*) >
86
+
87
+
88
+ <!-- =============== Sub-Document wrapper elements =====================-->
89
+ <!ELEMENT MedlineCitation (PMID, DateCompleted?, DateRevised?, Article,
90
+ MedlineJournalInfo, ChemicalList?, SupplMeshList?,CitationSubset*,
91
+ CommentsCorrectionsList?, GeneSymbolList?, MeshHeadingList?,
92
+ NumberOfReferences?, PersonalNameSubjectList?, OtherID*, OtherAbstract*,
93
+ KeywordList*, CoiStatement?, SpaceFlightMission*, InvestigatorList*, GeneralNote*)>
94
+ <!ATTLIST MedlineCitation
95
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD | NOTNLM) "NLM"
96
+ Status (Completed | In-Process | PubMed-not-MEDLINE | In-Data-Review | Publisher |
97
+ MEDLINE | OLDMEDLINE) #REQUIRED
98
+ VersionID CDATA #IMPLIED
99
+ VersionDate CDATA #IMPLIED
100
+ IndexingMethod CDATA #IMPLIED >
101
+
102
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?, ReferenceList*) >
103
+
104
+ <!ELEMENT PubmedBookData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
105
+
106
+ <!ELEMENT Article (Journal,ArticleTitle,((Pagination, ELocationID*) | ELocationID+),
107
+ Abstract?,AuthorList?, Language+, DataBankList?, GrantList?,
108
+ PublicationTypeList, VernacularTitle?, ArticleDate*) >
109
+ <!ATTLIST Article
110
+ PubModel (Print | Print-Electronic | Electronic | Electronic-Print | Electronic-eCollection) #REQUIRED >
111
+
112
+
113
+
114
+
115
+ <!-- ================================================================= -->
116
+ <!-- Everything else in alphabetical order -->
117
+ <!-- ================================================================= -->
118
+
119
+ <!ELEMENT Abstract (AbstractText+, CopyrightInformation?)>
120
+
121
+ <!ELEMENT AbstractText (%text; | mml:math | DispFormula)* >
122
+ <!ATTLIST AbstractText
123
+ Label CDATA #IMPLIED
124
+ NlmCategory (BACKGROUND | OBJECTIVE | METHODS | RESULTS | CONCLUSIONS | UNASSIGNED) #IMPLIED >
125
+
126
+ <!ELEMENT AccessionNumber (#PCDATA) >
127
+
128
+ <!ELEMENT AccessionNumberList (AccessionNumber+) >
129
+
130
+ <!ELEMENT Acronym (#PCDATA) >
131
+
132
+ <!ELEMENT Affiliation (%text;)*>
133
+
134
+ <!ELEMENT AffiliationInfo (Affiliation, Identifier*)>
135
+
136
+ <!ELEMENT Agency (#PCDATA) >
137
+
138
+ <!ELEMENT ArticleDate (Year, Month, Day) >
139
+ <!ATTLIST ArticleDate
140
+ DateType CDATA #FIXED "Electronic" >
141
+
142
+ <!ELEMENT ArticleId (#PCDATA) >
143
+ <!ATTLIST ArticleId
144
+ IdType (doi | pii | pmcpid | pmpid | pmc | mid |
145
+ sici | pubmed | medline | pmcid | pmcbook | bookaccession) "pubmed" >
146
+
147
+ <!ELEMENT ArticleIdList (ArticleId+)>
148
+
149
+ <!ELEMENT ArticleTitle (%text; | mml:math)*>
150
+ <!ATTLIST ArticleTitle %booklinkatts; >
151
+
152
+ <!ELEMENT Author (((LastName, ForeName?, Initials?, Suffix?) | CollectiveName), Identifier*, AffiliationInfo*) >
153
+ <!ATTLIST Author
154
+ ValidYN (Y | N) "Y"
155
+ EqualContrib (Y | N) #IMPLIED >
156
+
157
+ <!ELEMENT AuthorList (Author+) >
158
+ <!ATTLIST AuthorList
159
+ CompleteYN (Y | N) "Y"
160
+ Type ( authors | editors ) #IMPLIED >
161
+
162
+ <!ELEMENT b (%text;)*> <!-- bold -->
163
+
164
+ <!ELEMENT BeginningDate ( Year, ((Month, Day?) | Season)? ) >
165
+
166
+ <!ELEMENT Book ( Publisher, BookTitle, PubDate, BeginningDate?, EndingDate?, AuthorList*, InvestigatorList?, Volume?,
167
+ VolumeTitle?, Edition?, CollectionTitle?, Isbn*, ELocationID*, Medium?, ReportNumber?) >
168
+
169
+ <!ELEMENT BookTitle (%text; | mml:math)*>
170
+ <!ATTLIST BookTitle %booklinkatts; >
171
+
172
+ <!ELEMENT Chemical (RegistryNumber, NameOfSubstance) >
173
+
174
+ <!ELEMENT ChemicalList (Chemical+) >
175
+
176
+ <!ELEMENT Citation (%text; | mml:math)*>
177
+
178
+ <!ELEMENT CitationSubset (#PCDATA) >
179
+
180
+ <!ELEMENT CoiStatement (%text;)*>
181
+
182
+ <!ELEMENT CollectionTitle (%text; | mml:math)*>
183
+ <!ATTLIST CollectionTitle %booklinkatts; >
184
+
185
+ <!ELEMENT CollectiveName (%text;)*>
186
+ <!ATTLIST CollectiveName
187
+ Investigators IDREF #IMPLIED>
188
+
189
+ <!ELEMENT CommentsCorrections (RefSource,PMID?,Note?) >
190
+ <!ATTLIST CommentsCorrections
191
+ RefType (AssociatedDataset |
192
+ AssociatedPublication |
193
+ CommentIn | CommentOn |
194
+ CorrectedandRepublishedIn | CorrectedandRepublishedFrom |
195
+ ErratumIn | ErratumFor |
196
+ ExpressionOfConcernIn | ExpressionOfConcernFor |
197
+ RepublishedIn | RepublishedFrom |
198
+ RetractedandRepublishedIn | RetractedandRepublishedFrom |
199
+ RetractionIn | RetractionOf |
200
+ UpdateIn | UpdateOf |
201
+ SummaryForPatientsIn |
202
+ OriginalReportIn |
203
+ ReprintIn | ReprintOf |
204
+ Cites) #REQUIRED >
205
+
206
+
207
+ <!ELEMENT CommentsCorrectionsList (CommentsCorrections+) >
208
+
209
+ <!ELEMENT ContractNumber (#PCDATA) >
210
+
211
+ <!ELEMENT ContributionDate ( Year, ((Month, Day?) | Season)? ) >
212
+
213
+ <!ELEMENT CopyrightInformation (#PCDATA) >
214
+
215
+ <!ELEMENT Country (#PCDATA) >
216
+
217
+ <!ELEMENT DataBank (DataBankName, AccessionNumberList?) >
218
+
219
+ <!ELEMENT DataBankList (DataBank+) >
220
+
221
+ <!ATTLIST DataBankList
222
+ CompleteYN (Y | N) "Y" >
223
+
224
+ <!ELEMENT DataBankName (#PCDATA) >
225
+
226
+ <!ELEMENT DateCompleted (Year,Month,Day) >
227
+
228
+ <!ELEMENT DateRevised (Year,Month,Day) >
229
+
230
+ <!ELEMENT Day (#PCDATA )>
231
+
232
+ <!ELEMENT DescriptorName (#PCDATA) >
233
+ <!ATTLIST DescriptorName
234
+ MajorTopicYN (Y | N) "N"
235
+ Type (Geographic) #IMPLIED
236
+ UI CDATA #REQUIRED >
237
+
238
+ <!ELEMENT DispFormula (mml:math) >
239
+ <!ELEMENT Edition (#PCDATA) >
240
+
241
+ <!ELEMENT ELocationID (#PCDATA) >
242
+ <!ATTLIST ELocationID
243
+ EIdType (doi | pii) #REQUIRED
244
+ ValidYN (Y | N) "Y">
245
+
246
+ <!ELEMENT EndingDate ( Year, ((Month, Day?) | Season)? ) >
247
+
248
+ <!ELEMENT EndPage (#PCDATA) >
249
+
250
+ <!ELEMENT ForeName (#PCDATA) >
251
+
252
+ <!ELEMENT GeneSymbol (#PCDATA) >
253
+
254
+ <!ELEMENT GeneSymbolList (GeneSymbol+)>
255
+
256
+ <!ELEMENT GeneralNote (#PCDATA) >
257
+ <!ATTLIST GeneralNote
258
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD) "NLM" >
259
+
260
+ <!ELEMENT Grant (GrantID?, Acronym?, Agency, Country?)>
261
+
262
+ <!ELEMENT GrantID (#PCDATA) >
263
+
264
+ <!ELEMENT GrantList (Grant+)>
265
+ <!ATTLIST GrantList
266
+ CompleteYN (Y | N) "Y">
267
+
268
+ <!ELEMENT History (PubMedPubDate+) >
269
+
270
+ <!ELEMENT Hour (#PCDATA) >
271
+
272
+ <!ELEMENT i (%text;)*> <!-- italic -->
273
+
274
+ <!ELEMENT Identifier (#PCDATA) >
275
+ <!ATTLIST Identifier
276
+ Source CDATA #REQUIRED >
277
+
278
+ <!ELEMENT Initials (#PCDATA) >
279
+
280
+ <!ELEMENT Investigator (LastName, ForeName?, Initials?, Suffix?, Identifier*, AffiliationInfo*) >
281
+ <!ATTLIST Investigator
282
+ ValidYN (Y | N) "Y" >
283
+
284
+ <!ELEMENT InvestigatorList (Investigator+) >
285
+ <!ATTLIST InvestigatorList
286
+ ID ID #IMPLIED>
287
+
288
+ <!ELEMENT Isbn (#PCDATA) >
289
+
290
+ <!ELEMENT ISOAbbreviation (#PCDATA) >
291
+
292
+ <!ELEMENT ISSN (#PCDATA) >
293
+ <!ATTLIST ISSN
294
+ IssnType (Electronic | Print) #REQUIRED >
295
+
296
+ <!ELEMENT ISSNLinking (#PCDATA) >
297
+
298
+ <!ELEMENT Issue (#PCDATA) >
299
+ <!ELEMENT Item (#PCDATA)>
300
+
301
+ <!ELEMENT ItemList (Item+)>
302
+ <!ATTLIST ItemList
303
+ ListType CDATA #REQUIRED>
304
+
305
+ <!ELEMENT Journal (ISSN?, JournalIssue, Title?, ISOAbbreviation?)>
306
+
307
+ <!ELEMENT JournalIssue (Volume?, Issue?, PubDate) >
308
+ <!ATTLIST JournalIssue
309
+ CitedMedium (Internet | Print) #REQUIRED >
310
+
311
+ <!ELEMENT Keyword (%text; | mml:math)*>
312
+ <!ATTLIST Keyword
313
+ MajorTopicYN (Y | N) "N" >
314
+
315
+ <!ELEMENT KeywordList (Keyword+) >
316
+ <!ATTLIST KeywordList
317
+ Owner (NLM | NLM-AUTO | NASA | PIP | KIE | NOTNLM | HHS) "NLM" >
318
+
319
+ <!ELEMENT Language (#PCDATA) >
320
+
321
+ <!ELEMENT LastName (#PCDATA) >
322
+
323
+ <!ELEMENT LocationLabel (#PCDATA)>
324
+ <!ATTLIST LocationLabel
325
+ Type (part|chapter|section|appendix|figure|table|box) #IMPLIED >
326
+
327
+ <!ELEMENT Medium (#PCDATA) >
328
+
329
+ <!ELEMENT MedlineDate (#PCDATA) >
330
+
331
+ <!ELEMENT MedlineJournalInfo (Country?, MedlineTA, NlmUniqueID?, ISSNLinking?) >
332
+
333
+ <!ELEMENT MedlinePgn (#PCDATA) >
334
+
335
+ <!ELEMENT MedlineTA (#PCDATA) >
336
+
337
+ <!ELEMENT MeshHeading (DescriptorName, QualifierName*)>
338
+
339
+ <!ELEMENT MeshHeadingList (MeshHeading+)>
340
+
341
+ <!ELEMENT Minute (#PCDATA) >
342
+
343
+ <!ELEMENT Month (#PCDATA) >
344
+
345
+ <!ELEMENT NameOfSubstance (#PCDATA) >
346
+ <!ATTLIST NameOfSubstance
347
+ UI CDATA #REQUIRED >
348
+
349
+ <!ELEMENT NlmUniqueID (#PCDATA) >
350
+
351
+ <!ELEMENT Note (#PCDATA) >
352
+
353
+ <!ELEMENT NumberOfReferences (#PCDATA) >
354
+
355
+ <!ELEMENT Object (Param*)>
356
+ <!ATTLIST Object
357
+ Type CDATA #REQUIRED >
358
+
359
+ <!ELEMENT ObjectList (Object+) >
360
+
361
+ <!ELEMENT OtherAbstract (AbstractText+, CopyrightInformation?) >
362
+
363
+ <!ATTLIST OtherAbstract
364
+ Type (AAMC | AIDS | KIE | PIP | NASA | Publisher |
365
+ plain-language-summary) #REQUIRED
366
+ Language CDATA "eng" >
367
+
368
+ <!ELEMENT OtherID (#PCDATA) >
369
+ <!ATTLIST OtherID
370
+ Source (NASA | KIE | PIP | POP | ARPL | CPC | IND | CPFH | CLML |
371
+ NRCBL | NLM | QCIM) #REQUIRED >
372
+
373
+ <!ELEMENT PMID (#PCDATA) >
374
+ <!ATTLIST PMID
375
+ Version CDATA #REQUIRED >
376
+
377
+ <!ELEMENT Pagination ((StartPage, EndPage?, MedlinePgn?) | MedlinePgn) >
378
+
379
+ <!ELEMENT Param (%text;)*>
380
+ <!ATTLIST Param
381
+ Name CDATA #REQUIRED >
382
+
383
+ <!ELEMENT PersonalNameSubject (LastName, ForeName?, Initials?, Suffix?) >
384
+
385
+ <!ELEMENT PersonalNameSubjectList (PersonalNameSubject+) >
386
+
387
+ <!ELEMENT PubDate ((Year, ((Month, Day?) | Season)?) | MedlineDate) >
388
+
389
+ <!ELEMENT PublicationStatus (#PCDATA) >
390
+
391
+ <!ELEMENT PublicationType (#PCDATA) >
392
+ <!ATTLIST PublicationType
393
+ UI CDATA #REQUIRED >
394
+
395
+ <!ELEMENT PublicationTypeList (PublicationType+) >
396
+
397
+ <!ELEMENT PubMedPubDate (Year, Month, Day, (Hour, (Minute, Second?)?)?)>
398
+ <!ATTLIST PubMedPubDate
399
+ PubStatus (received | accepted | epublish |
400
+ ppublish | revised | aheadofprint |
401
+ retracted | ecollection | pmc | pmcr | pubmed | pubmedr |
402
+ premedline | medline | medliner | entrez | pmc-release) #REQUIRED >
403
+
404
+ <!ELEMENT Publisher (PublisherName, PublisherLocation?) >
405
+
406
+ <!ELEMENT PublisherLocation (#PCDATA) >
407
+
408
+ <!ELEMENT PublisherName (%text;)*>
409
+
410
+ <!ELEMENT QualifierName (#PCDATA) >
411
+ <!ATTLIST QualifierName
412
+ MajorTopicYN (Y | N) "N"
413
+ UI CDATA #REQUIRED >
414
+
415
+ <!ELEMENT Reference (Citation, ArticleIdList?) >
416
+
417
+ <!ELEMENT ReferenceList (Title?, Reference*, ReferenceList*) >
418
+
419
+ <!ELEMENT RefSource (#PCDATA) >
420
+
421
+ <!ELEMENT RegistryNumber (#PCDATA) >
422
+
423
+ <!ELEMENT ReportNumber (#PCDATA) >
424
+
425
+ <!ELEMENT Season (#PCDATA) >
426
+
427
+ <!ELEMENT Second (#PCDATA) >
428
+
429
+
430
+ <!ELEMENT Section (LocationLabel?, SectionTitle, Section*) >
431
+
432
+ <!ELEMENT Sections (Section+) >
433
+
434
+ <!ELEMENT SectionTitle (%text;)*>
435
+ <!ATTLIST SectionTitle %booklinkatts; >
436
+
437
+ <!ELEMENT SpaceFlightMission (#PCDATA) >
438
+
439
+ <!ELEMENT StartPage (#PCDATA) >
440
+
441
+ <!ELEMENT sub (%text;)*> <!-- subscript -->
442
+
443
+ <!ELEMENT Suffix (%text;)*>
444
+
445
+ <!ELEMENT sup (%text;)*> <!-- superscript -->
446
+
447
+ <!ELEMENT SupplMeshList (SupplMeshName+)>
448
+
449
+ <!ELEMENT SupplMeshName (#PCDATA) >
450
+ <!ATTLIST SupplMeshName
451
+ Type ( Disease | Protocol | Organism | Anatomy | Population ) #REQUIRED
452
+ UI CDATA #REQUIRED >
453
+
454
+ <!ELEMENT Title (#PCDATA) >
455
+
456
+ <!ELEMENT u (%text;)*> <!-- underline -->
457
+
458
+ <!ELEMENT URL (#PCDATA) >
459
+ <!ATTLIST URL
460
+ lang (AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
461
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
462
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
463
+ VI|ZH) #IMPLIED
464
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED >
465
+
466
+ <!ELEMENT VernacularTitle (%text; | mml:math)*>
467
+
468
+ <!ELEMENT Volume (#PCDATA) >
469
+
470
+ <!ELEMENT VolumeTitle (%text;)*>
471
+
472
+ <!ELEMENT Year (#PCDATA) >
473
+
474
+
475
+
476
+
477
+
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/pubmed_250101.dtd ADDED
@@ -0,0 +1,475 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+
3
+ 2024-08-28
4
+
5
+ This DTD supports both the E-utilities and ftp service data dissemination methods.
6
+ It is based on http://dtd.nlm.nih.gov/ncbi/pubmed/out/pubmed_230101.dtd
7
+
8
+ Additions/Changes since pubmed_240101 DTD:
9
+
10
+ 1. Added AutoHM attribute to DescriptorName and QualifierName
11
+
12
+
13
+
14
+ NOTE: The use of "Medline" in a DTD or element name does not mean the record
15
+ represents a citation from a MEDLINE-selected journal. When the NLM DTDs and
16
+ XML elements were first created, MEDLINE records were the only data exported.
17
+ Now NLM exports citations other than MEDLINE records using these tools. To
18
+ minimize unnecessary disruption to users of the data and tools, NLM has
19
+ retained the original DTD and element names (e.g., MedlineTA, MedlineJournalInfo).
20
+
21
+ NOTE: The updated PubMed API now allows for the use of the StartPage and
22
+ EndPage elements in Pagination.
23
+
24
+ * = 0 or more occurrences (optional element, repeatable)
25
+ ? = 0 or 1 occurrences (optional element, at most 1)
26
+ + = 1 or more occurrences (required element, repeatable)
27
+ | = choice, one or the other but not both
28
+ no symbol = required element
29
+
30
+ -->
31
+
32
+ <!-- ============================================================= -->
33
+ <!-- MATHML 3.0 SETUP -->
34
+ <!-- ============================================================= -->
35
+ <!-- MATHML SETUP FILE -->
36
+ <!ENTITY % mathml-in-pubmed SYSTEM "mathml-in-pubmed.mod" >
37
+ %mathml-in-pubmed;
38
+
39
+
40
+
41
+ <!-- ================================================================= -->
42
+ <!-- ================================================================= -->
43
+ <!ENTITY % text "#PCDATA | b | i | sup | sub | u" >
44
+
45
+ <!ENTITY % booklinkatts
46
+ "book CDATA #IMPLIED
47
+ part CDATA #IMPLIED
48
+ sec CDATA #IMPLIED" >
49
+ <!-- ================================================================= -->
50
+ <!-- ================================================================= -->
51
+
52
+ <!-- ================= Set-level elements ============================-->
53
+ <!ELEMENT PubmedArticleSet ((PubmedArticle | PubmedBookArticle)+, DeleteCitation?) >
54
+ <!ATTLIST PubmedArticleSet
55
+ >
56
+
57
+ <!ELEMENT BookDocumentSet (BookDocument*, DeleteDocument?) >
58
+ <!ATTLIST BookDocumentSet
59
+ >
60
+
61
+ <!ELEMENT PubmedBookArticleSet (PubmedBookArticle*)>
62
+ <!ATTLIST PubmedBookArticleSet
63
+ >
64
+
65
+
66
+ <!-- ============= Document-level elements ============================-->
67
+ <!ELEMENT PubmedArticle (MedlineCitation, PubmedData?)>
68
+ <!ATTLIST PubmedArticle
69
+ >
70
+
71
+ <!ELEMENT PubmedBookArticle (BookDocument, PubmedBookData?)>
72
+ <!ATTLIST PubmedBookArticle
73
+ >
74
+
75
+ <!ELEMENT BookDocument ( PMID, ArticleIdList, Book, LocationLabel*, ArticleTitle?, VernacularTitle?,
76
+ Pagination?, Language*, AuthorList*, InvestigatorList?, PublicationType*, Abstract?, Sections?, KeywordList*,
77
+ ContributionDate?, DateRevised?, GrantList?, ItemList*, ReferenceList*) >
78
+
79
+ <!ELEMENT DeleteCitation (PMID+) >
80
+
81
+ <!ELEMENT DeleteDocument (PMID*) >
82
+
83
+
84
+ <!-- =============== Sub-Document wrapper elements =====================-->
85
+ <!ELEMENT MedlineCitation (PMID, DateCompleted?, DateRevised?, Article,
86
+ MedlineJournalInfo, ChemicalList?, SupplMeshList?,CitationSubset*,
87
+ CommentsCorrectionsList?, GeneSymbolList?, MeshHeadingList?,
88
+ NumberOfReferences?, PersonalNameSubjectList?, OtherID*, OtherAbstract*,
89
+ KeywordList*, CoiStatement?, SpaceFlightMission*, InvestigatorList*, GeneralNote*)>
90
+ <!ATTLIST MedlineCitation
91
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD | NOTNLM) "NLM"
92
+ Status (Completed | In-Process | PubMed-not-MEDLINE | In-Data-Review | Publisher |
93
+ MEDLINE | OLDMEDLINE) #REQUIRED
94
+ VersionID CDATA #IMPLIED
95
+ VersionDate CDATA #IMPLIED
96
+ IndexingMethod CDATA #IMPLIED >
97
+
98
+ <!ELEMENT PubmedData (History?, PublicationStatus, ArticleIdList, ObjectList?, ReferenceList*) >
99
+
100
+ <!ELEMENT PubmedBookData (History?, PublicationStatus, ArticleIdList, ObjectList?)>
101
+
102
+ <!ELEMENT Article (Journal,ArticleTitle,((Pagination, ELocationID*) | ELocationID+),
103
+ Abstract?,AuthorList?, Language+, DataBankList?, GrantList?,
104
+ PublicationTypeList, VernacularTitle?, ArticleDate*) >
105
+ <!ATTLIST Article
106
+ PubModel (Print | Print-Electronic | Electronic | Electronic-Print | Electronic-eCollection) #REQUIRED >
107
+
108
+
109
+
110
+
111
+ <!-- ================================================================= -->
112
+ <!-- Everything else in alphabetical order -->
113
+ <!-- ================================================================= -->
114
+
115
+ <!ELEMENT Abstract (AbstractText+, CopyrightInformation?)>
116
+
117
+ <!ELEMENT AbstractText (%text; | mml:math | DispFormula)* >
118
+ <!ATTLIST AbstractText
119
+ Label CDATA #IMPLIED
120
+ NlmCategory (BACKGROUND | OBJECTIVE | METHODS | RESULTS | CONCLUSIONS | UNASSIGNED) #IMPLIED >
121
+
122
+ <!ELEMENT AccessionNumber (#PCDATA) >
123
+
124
+ <!ELEMENT AccessionNumberList (AccessionNumber+) >
125
+
126
+ <!ELEMENT Acronym (#PCDATA) >
127
+
128
+ <!ELEMENT Affiliation (%text;)*>
129
+
130
+ <!ELEMENT AffiliationInfo (Affiliation, Identifier*)>
131
+
132
+ <!ELEMENT Agency (#PCDATA) >
133
+
134
+ <!ELEMENT ArticleDate (Year, Month, Day) >
135
+ <!ATTLIST ArticleDate
136
+ DateType CDATA #FIXED "Electronic" >
137
+
138
+ <!ELEMENT ArticleId (#PCDATA) >
139
+ <!ATTLIST ArticleId
140
+ IdType (doi | pii | pmcpid | pmpid | pmc | mid |
141
+ sici | pubmed | medline | pmcid | pmcbook | bookaccession) "pubmed" >
142
+
143
+ <!ELEMENT ArticleIdList (ArticleId+)>
144
+
145
+ <!ELEMENT ArticleTitle (%text; | mml:math)*>
146
+ <!ATTLIST ArticleTitle %booklinkatts; >
147
+
148
+ <!ELEMENT Author (((LastName, ForeName?, Initials?, Suffix?) | CollectiveName), Identifier*, AffiliationInfo*) >
149
+ <!ATTLIST Author
150
+ ValidYN (Y | N) "Y"
151
+ EqualContrib (Y | N) #IMPLIED >
152
+
153
+ <!ELEMENT AuthorList (Author+) >
154
+ <!ATTLIST AuthorList
155
+ CompleteYN (Y | N) "Y"
156
+ Type ( authors | editors ) #IMPLIED >
157
+
158
+ <!ELEMENT b (%text;)*> <!-- bold -->
159
+
160
+ <!ELEMENT BeginningDate ( Year, ((Month, Day?) | Season)? ) >
161
+
162
+ <!ELEMENT Book ( Publisher, BookTitle, PubDate, BeginningDate?, EndingDate?, AuthorList*, InvestigatorList?, Volume?,
163
+ VolumeTitle?, Edition?, CollectionTitle?, Isbn*, ELocationID*, Medium?, ReportNumber?) >
164
+
165
+ <!ELEMENT BookTitle (%text; | mml:math)*>
166
+ <!ATTLIST BookTitle %booklinkatts; >
167
+
168
+ <!ELEMENT Chemical (RegistryNumber, NameOfSubstance) >
169
+
170
+ <!ELEMENT ChemicalList (Chemical+) >
171
+
172
+ <!ELEMENT Citation (%text; | mml:math)*>
173
+
174
+ <!ELEMENT CitationSubset (#PCDATA) >
175
+
176
+ <!ELEMENT CoiStatement (%text;)*>
177
+
178
+ <!ELEMENT CollectionTitle (%text; | mml:math)*>
179
+ <!ATTLIST CollectionTitle %booklinkatts; >
180
+
181
+ <!ELEMENT CollectiveName (%text;)*>
182
+ <!ATTLIST CollectiveName
183
+ Investigators IDREF #IMPLIED>
184
+
185
+ <!ELEMENT CommentsCorrections (RefSource,PMID?,Note?) >
186
+ <!ATTLIST CommentsCorrections
187
+ RefType (AssociatedDataset |
188
+ AssociatedPublication |
189
+ CommentIn | CommentOn |
190
+ CorrectedandRepublishedIn | CorrectedandRepublishedFrom |
191
+ ErratumIn | ErratumFor |
192
+ ExpressionOfConcernIn | ExpressionOfConcernFor |
193
+ RepublishedIn | RepublishedFrom |
194
+ RetractedandRepublishedIn | RetractedandRepublishedFrom |
195
+ RetractionIn | RetractionOf |
196
+ UpdateIn | UpdateOf |
197
+ SummaryForPatientsIn |
198
+ OriginalReportIn |
199
+ ReprintIn | ReprintOf |
200
+ Cites) #REQUIRED >
201
+
202
+
203
+ <!ELEMENT CommentsCorrectionsList (CommentsCorrections+) >
204
+
205
+ <!ELEMENT ContractNumber (#PCDATA) >
206
+
207
+ <!ELEMENT ContributionDate ( Year, ((Month, Day?) | Season)? ) >
208
+
209
+ <!ELEMENT CopyrightInformation (#PCDATA) >
210
+
211
+ <!ELEMENT Country (#PCDATA) >
212
+
213
+ <!ELEMENT DataBank (DataBankName, AccessionNumberList?) >
214
+
215
+ <!ELEMENT DataBankList (DataBank+) >
216
+
217
+ <!ATTLIST DataBankList
218
+ CompleteYN (Y | N) "Y" >
219
+
220
+ <!ELEMENT DataBankName (#PCDATA) >
221
+
222
+ <!ELEMENT DateCompleted (Year,Month,Day) >
223
+
224
+ <!ELEMENT DateRevised (Year,Month,Day) >
225
+
226
+ <!ELEMENT Day (#PCDATA )>
227
+
228
+ <!ELEMENT DescriptorName (#PCDATA) >
229
+ <!ATTLIST DescriptorName
230
+ MajorTopicYN (Y | N) "N"
231
+ AutoHM (Y) #IMPLIED
232
+ Type (Geographic) #IMPLIED
233
+ UI CDATA #REQUIRED >
234
+
235
+ <!ELEMENT DispFormula (mml:math) >
236
+ <!ELEMENT Edition (#PCDATA) >
237
+
238
+ <!ELEMENT ELocationID (#PCDATA) >
239
+ <!ATTLIST ELocationID
240
+ EIdType (doi | pii) #REQUIRED
241
+ ValidYN (Y | N) "Y">
242
+
243
+ <!ELEMENT EndingDate ( Year, ((Month, Day?) | Season)? ) >
244
+
245
+ <!ELEMENT EndPage (#PCDATA) >
246
+
247
+ <!ELEMENT ForeName (#PCDATA) >
248
+
249
+ <!ELEMENT GeneSymbol (#PCDATA) >
250
+
251
+ <!ELEMENT GeneSymbolList (GeneSymbol+)>
252
+
253
+ <!ELEMENT GeneralNote (#PCDATA) >
254
+ <!ATTLIST GeneralNote
255
+ Owner (NLM | NASA | PIP | KIE | HSR | HMD) "NLM" >
256
+
257
+ <!ELEMENT Grant (GrantID?, Acronym?, Agency, Country?)>
258
+
259
+ <!ELEMENT GrantID (#PCDATA) >
260
+
261
+ <!ELEMENT GrantList (Grant+)>
262
+ <!ATTLIST GrantList
263
+ CompleteYN (Y | N) "Y">
264
+
265
+ <!ELEMENT History (PubMedPubDate+) >
266
+
267
+ <!ELEMENT Hour (#PCDATA) >
268
+
269
+ <!ELEMENT i (%text;)*> <!-- italic -->
270
+
271
+ <!ELEMENT Identifier (#PCDATA) >
272
+ <!ATTLIST Identifier
273
+ Source CDATA #REQUIRED >
274
+
275
+ <!ELEMENT Initials (#PCDATA) >
276
+
277
+ <!ELEMENT Investigator (LastName, ForeName?, Initials?, Suffix?, Identifier*, AffiliationInfo*) >
278
+ <!ATTLIST Investigator
279
+ ValidYN (Y | N) "Y" >
280
+
281
+ <!ELEMENT InvestigatorList (Investigator+) >
282
+ <!ATTLIST InvestigatorList
283
+ ID ID #IMPLIED>
284
+
285
+ <!ELEMENT Isbn (#PCDATA) >
286
+
287
+ <!ELEMENT ISOAbbreviation (#PCDATA) >
288
+
289
+ <!ELEMENT ISSN (#PCDATA) >
290
+ <!ATTLIST ISSN
291
+ IssnType (Electronic | Print) #REQUIRED >
292
+
293
+ <!ELEMENT ISSNLinking (#PCDATA) >
294
+
295
+ <!ELEMENT Issue (#PCDATA) >
296
+ <!ELEMENT Item (#PCDATA)>
297
+
298
+ <!ELEMENT ItemList (Item+)>
299
+ <!ATTLIST ItemList
300
+ ListType CDATA #REQUIRED>
301
+
302
+ <!ELEMENT Journal (ISSN?, JournalIssue, Title?, ISOAbbreviation?)>
303
+
304
+ <!ELEMENT JournalIssue (Volume?, Issue?, PubDate) >
305
+ <!ATTLIST JournalIssue
306
+ CitedMedium (Internet | Print) #REQUIRED >
307
+
308
+ <!ELEMENT Keyword (%text; | mml:math)*>
309
+ <!ATTLIST Keyword
310
+ MajorTopicYN (Y | N) "N" >
311
+
312
+ <!ELEMENT KeywordList (Keyword+) >
313
+ <!ATTLIST KeywordList
314
+ Owner (NLM | NLM-AUTO | NASA | PIP | KIE | NOTNLM | HHS) "NLM" >
315
+
316
+ <!ELEMENT Language (#PCDATA) >
317
+
318
+ <!ELEMENT LastName (#PCDATA) >
319
+
320
+ <!ELEMENT LocationLabel (#PCDATA)>
321
+ <!ATTLIST LocationLabel
322
+ Type (part|chapter|section|appendix|figure|table|box) #IMPLIED >
323
+
324
+ <!ELEMENT Medium (#PCDATA) >
325
+
326
+ <!ELEMENT MedlineDate (#PCDATA) >
327
+
328
+ <!ELEMENT MedlineJournalInfo (Country?, MedlineTA, NlmUniqueID?, ISSNLinking?) >
329
+
330
+ <!ELEMENT MedlinePgn (#PCDATA) >
331
+
332
+ <!ELEMENT MedlineTA (#PCDATA) >
333
+
334
+ <!ELEMENT MeshHeading (DescriptorName, QualifierName*)>
335
+
336
+ <!ELEMENT MeshHeadingList (MeshHeading+)>
337
+
338
+ <!ELEMENT Minute (#PCDATA) >
339
+
340
+ <!ELEMENT Month (#PCDATA) >
341
+
342
+ <!ELEMENT NameOfSubstance (#PCDATA) >
343
+ <!ATTLIST NameOfSubstance
344
+ UI CDATA #REQUIRED >
345
+
346
+ <!ELEMENT NlmUniqueID (#PCDATA) >
347
+
348
+ <!ELEMENT Note (#PCDATA) >
349
+
350
+ <!ELEMENT NumberOfReferences (#PCDATA) >
351
+
352
+ <!ELEMENT Object (Param*)>
353
+ <!ATTLIST Object
354
+ Type CDATA #REQUIRED >
355
+
356
+ <!ELEMENT ObjectList (Object+) >
357
+
358
+ <!ELEMENT OtherAbstract (AbstractText+, CopyrightInformation?) >
359
+
360
+ <!ATTLIST OtherAbstract
361
+ Type (AAMC | AIDS | KIE | PIP | NASA | Publisher |
362
+ plain-language-summary) #REQUIRED
363
+ Language CDATA "eng" >
364
+
365
+ <!ELEMENT OtherID (#PCDATA) >
366
+ <!ATTLIST OtherID
367
+ Source (NASA | KIE | PIP | POP | ARPL | CPC | IND | CPFH | CLML |
368
+ NRCBL | NLM | QCIM) #REQUIRED >
369
+
370
+ <!ELEMENT PMID (#PCDATA) >
371
+ <!ATTLIST PMID
372
+ Version CDATA #REQUIRED >
373
+
374
+ <!ELEMENT Pagination ((StartPage, EndPage?, MedlinePgn?) | MedlinePgn) >
375
+
376
+ <!ELEMENT Param (%text;)*>
377
+ <!ATTLIST Param
378
+ Name CDATA #REQUIRED >
379
+
380
+ <!ELEMENT PersonalNameSubject (LastName, ForeName?, Initials?, Suffix?) >
381
+
382
+ <!ELEMENT PersonalNameSubjectList (PersonalNameSubject+) >
383
+
384
+ <!ELEMENT PubDate ((Year, ((Month, Day?) | Season)?) | MedlineDate) >
385
+
386
+ <!ELEMENT PublicationStatus (#PCDATA) >
387
+
388
+ <!ELEMENT PublicationType (#PCDATA) >
389
+ <!ATTLIST PublicationType
390
+ UI CDATA #REQUIRED >
391
+
392
+ <!ELEMENT PublicationTypeList (PublicationType+) >
393
+
394
+ <!ELEMENT PubMedPubDate (Year, Month, Day, (Hour, (Minute, Second?)?)?)>
395
+ <!ATTLIST PubMedPubDate
396
+ PubStatus (received | accepted | epublish |
397
+ ppublish | revised | aheadofprint |
398
+ retracted | ecollection | pmc | pmcr | pubmed | pubmedr |
399
+ premedline | medline | medliner | entrez | pmc-release) #REQUIRED >
400
+
401
+ <!ELEMENT Publisher (PublisherName, PublisherLocation?) >
402
+
403
+ <!ELEMENT PublisherLocation (#PCDATA) >
404
+
405
+ <!ELEMENT PublisherName (%text;)*>
406
+
407
+ <!ELEMENT QualifierName (#PCDATA) >
408
+ <!ATTLIST QualifierName
409
+ AutoHM (Y) #IMPLIED
410
+ MajorTopicYN (Y | N) "N"
411
+ UI CDATA #REQUIRED >
412
+
413
+ <!ELEMENT Reference (Citation, ArticleIdList?) >
414
+
415
+ <!ELEMENT ReferenceList (Title?, Reference*, ReferenceList*) >
416
+
417
+ <!ELEMENT RefSource (#PCDATA) >
418
+
419
+ <!ELEMENT RegistryNumber (#PCDATA) >
420
+
421
+ <!ELEMENT ReportNumber (#PCDATA) >
422
+
423
+ <!ELEMENT Season (#PCDATA) >
424
+
425
+ <!ELEMENT Second (#PCDATA) >
426
+
427
+
428
+ <!ELEMENT Section (LocationLabel?, SectionTitle, Section*) >
429
+
430
+ <!ELEMENT Sections (Section+) >
431
+
432
+ <!ELEMENT SectionTitle (%text;)*>
433
+ <!ATTLIST SectionTitle %booklinkatts; >
434
+
435
+ <!ELEMENT SpaceFlightMission (#PCDATA) >
436
+
437
+ <!ELEMENT StartPage (#PCDATA) >
438
+
439
+ <!ELEMENT sub (%text;)*> <!-- subscript -->
440
+
441
+ <!ELEMENT Suffix (%text;)*>
442
+
443
+ <!ELEMENT sup (%text;)*> <!-- superscript -->
444
+
445
+ <!ELEMENT SupplMeshList (SupplMeshName+)>
446
+
447
+ <!ELEMENT SupplMeshName (#PCDATA) >
448
+ <!ATTLIST SupplMeshName
449
+ Type ( Disease | Protocol | Organism | Anatomy | Population ) #REQUIRED
450
+ UI CDATA #REQUIRED >
451
+
452
+ <!ELEMENT Title (#PCDATA) >
453
+
454
+ <!ELEMENT u (%text;)*> <!-- underline -->
455
+
456
+ <!ELEMENT URL (#PCDATA) >
457
+ <!ATTLIST URL
458
+ lang (AF|AR|AZ|BG|CS|DA|DE|EN|EL|ES|FA|FI|FR|HE|
459
+ HU|HY|IN|IS|IT|IW|JA|KA|KO|LT|MK|ML|NL|NO|
460
+ PL|PT|PS|RO|RU|SL|SK|SQ|SR|SV|SW|TH|TR|UK|
461
+ VI|ZH) #IMPLIED
462
+ Type ( FullText | Summary | fulltext | summary) #IMPLIED >
463
+
464
+ <!ELEMENT VernacularTitle (%text; | mml:math)*>
465
+
466
+ <!ELEMENT Volume (#PCDATA) >
467
+
468
+ <!ELEMENT VolumeTitle (%text;)*>
469
+
470
+ <!ELEMENT Year (#PCDATA) >
471
+
472
+
473
+
474
+
475
+
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/references.ent ADDED
@@ -0,0 +1,726 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- ============================================================= -->
2
+ <!-- MODULE: Bibliographic Reference (Citation) Class Elements -->
3
+ <!-- VERSION: 2.0 -->
4
+ <!-- DATE: August 2004 -->
5
+ <!-- -->
6
+ <!-- ============================================================= -->
7
+
8
+ <!-- ============================================================= -->
9
+ <!-- PUBLIC DOCUMENT TYPE DEFINITION -->
10
+ <!-- TYPICAL INVOCATION -->
11
+ <!--
12
+ "-//NLM//DTD Archiving and Interchange DTD Suite Bibliographic Reference (Citation) Class Elements v2.0 20040830//EN"
13
+ Delivered as file "references.ent" -->
14
+ <!-- ============================================================= -->
15
+
16
+ <!-- ============================================================= -->
17
+ <!-- SYSTEM: Archiving and Interchange DTD Suite -->
18
+ <!-- -->
19
+ <!-- PURPOSE: Defines the bibliographic reference elements -->
20
+ <!-- -->
21
+ <!-- -->
22
+ <!-- CONTAINS: 1) Default definition of the references class -->
23
+ <!-- 2) Parameter Entities for attribute lists -->
24
+ <!-- 3) Models for the bibliographic reference -->
25
+ <!-- class elements in alphabetical order -->
26
+ <!-- -->
27
+ <!-- CREATED FOR: -->
28
+ <!-- Digital archives and publishers who wish to -->
29
+ <!-- create a custom XML DTD for original markup of -->
30
+ <!-- journal literature, books, and related material, -->
31
+ <!-- or for archiving and transferring such material -->
32
+ <!-- between archives. -->
33
+ <!-- -->
34
+ <!-- This DTD is in the public domain. An organization -->
35
+ <!-- that wishes to create its own DTD from the suite -->
36
+ <!-- may do so without permission from NLM. -->
37
+ <!-- -->
38
+ <!-- The suite has been set up to be extended using a -->
39
+ <!-- new DTD file and a new DTD-specific customization -->
40
+ <!-- module to redefine the many Parameter Entities. -->
41
+ <!-- Do not modify the suite directly or redistribute -->
42
+ <!-- modified versions of the suite. -->
43
+ <!-- -->
44
+ <!-- In the interest of maintaining consistency and -->
45
+ <!-- clarity for potential users, NLM requests: -->
46
+ <!-- -->
47
+ <!-- 1. If you create a DTD from the Archiving and -->
48
+ <!-- Interchange DTD Suite and intend to stay -->
49
+ <!-- compatible with the suite, then please include -->
50
+ <!-- the following statement as a comment in all of -->
51
+ <!-- your DTD modules: -->
52
+ <!-- "Created from, and fully compatible with, -->
53
+ <!-- the Archiving and Interchange DTD Suite." -->
54
+ <!-- -->
55
+ <!-- 2. If you alter one or more modules of the suite, -->
56
+ <!-- then please rename your version and all its -->
57
+ <!-- modules to avoid any confusion with the -->
58
+ <!-- original suite. Also, please include the -->
59
+ <!-- following statement as a comment in all your -->
60
+ <!-- DTD modules: -->
61
+ <!-- "Based in part on, but not fully compatible -->
62
+ <!-- with, the Archiving and Interchange DTD -->
63
+ <!-- Suite." -->
64
+ <!-- -->
65
+ <!-- Suggestions for refinements and enhancements to -->
66
+ <!-- the DTD suite should be sent in email to: -->
67
+ <!-- archive-dtd@ncbi.nlm.nih.gov -->
68
+ <!-- -->
69
+ <!-- ORIGINAL CREATION DATE: -->
70
+ <!-- December 2002 -->
71
+ <!-- -->
72
+ <!-- CREATED BY: Jeff Beck (NCBI) -->
73
+ <!-- Deborah Lapeyre (Mulberry Technologies, Inc.) -->
74
+ <!-- Bruce Rosenblum (Inera Inc.) -->
75
+ <!-- -->
76
+ <!-- NLM thanks the Harvard University Libraries, both -->
77
+ <!-- for proposing that a draft archiving NLM DTD for -->
78
+ <!-- life sciences journals be extended to accommodate -->
79
+ <!-- journals in all disciplines and for sponsoring -->
80
+ <!-- Bruce Rosenblum's collaboration with other DTD -->
81
+ <!-- authors in completing Version 1.0. The Andrew W. -->
82
+ <!-- Mellon Foundation provided support for these -->
83
+ <!-- important contributions. -->
84
+ <!-- -->
85
+ <!-- ============================================================= -->
86
+
87
+
88
+ <!-- ============================================================= -->
89
+ <!-- DTD VERSION/CHANGE HISTORY -->
90
+ <!-- ============================================================= -->
91
+ <!--
92
+
93
+ =============================================================
94
+
95
+ Version Reason/Occasion (who) vx.x (yyyy-mm-dd)
96
+
97
+ =============================================================
98
+ Version 2.0 (DAL/BTU) v2.0 (2004-08-30)
99
+
100
+ Major requirement changes led to the new release, producing
101
+ DTD version "2.0":
102
+ a) The splitting of the Archival and Interchange Tag Set
103
+ DTDs into three DTDs from two: an authoring DTD, an
104
+ archive regularization and interchange DTD (the
105
+ current Blue Publishing DTD), and a preservationist
106
+ archive DTD (the current Green Archiving and Interchange
107
+ DTD).
108
+ b) AIT Working Group suggestions from the June 04 meeting
109
+ and June/July 2004 followup discussions
110
+ c) Suite remodularization to meet new (and newly articulated)
111
+ modularization requirements
112
+ d) New or renamed classes and mixes to make modifications
113
+ easier and more consistent
114
+
115
+ 12. COMPLETE MODELS WHEN OVER-RIDING A MODEL
116
+ (for all Parameter Entities suffixed "-model")
117
+ ### Customization Alert ###
118
+ Added internal parentheses to Parameter Entity and removed
119
+ them from Element Declaration for:
120
+ - %note-model;
121
+ - %ref-list-model;
122
+ - %ref-model;
123
+ - and removed the parentheses for <person-group>
124
+
125
+ 11. DEFAULT CLASSES - Were moved from this module to
126
+ %default-classes.ent;
127
+
128
+ 10. REFERENCES.CLASS - Added the following elements to the
129
+ %references.class;:
130
+ - <issue-id>
131
+ - <issue-title>
132
+ - <page-range>
133
+ - <role>
134
+ - <string-name>
135
+ - <volume-id>
136
+
137
+ 9. EMAIL AND URI
138
+ a. Added to %source-elements; by changing
139
+ %ext-links.class; ==> %address-link.class;
140
+
141
+ 8. LOOSENING ELEMENT USAGE in Archiving DTD and Suite
142
+ a. Rewrote content model for access-date as a new Parameter
143
+ Entity %access-date-elements;
144
+ b. Allowed all date components (%date-part.class;)
145
+ inside this PE in Archiving DTD (Green) customization
146
+ c. The default value is the empty string in this module,
147
+ therefore, access date, by default, contains nothing
148
+ but #PCDATA.
149
+
150
+ 7. ROLE ELEMENT - Was added to the default references class
151
+ %references.class;
152
+
153
+ 6. PERSON GROUP - To add <string-name> as well as correct various
154
+ classing problems:
155
+
156
+ a. Content model was made into a Parameter Entity
157
+ %person-group-model;
158
+
159
+ b. The content model was changed to incorporate the new
160
+ -%name.class;, which adds both <string-name> and <collab>
161
+
162
+ 5. NAME CLASS / STRING NAME
163
+ a. Created a new element <string-name> for names that
164
+ do not follow the former, strict personal name model.
165
+
166
+ b. Created a new class %name.class; to hold all the ways
167
+ to name people: <name>, <string-name>, and <collab>
168
+ who produce products or articles. Used in:
169
+ - <person-group>
170
+
171
+ c. To allow <string-name> to be used anywhere <name> is
172
+ used:
173
+ - Added to default %references.class;
174
+
175
+ 4. NEW PARAMETER ENTITIES - To correct potential classing
176
+ problems, created the following new Parameter Entities:
177
+ a. NEW CLASSES
178
+ - %just-para.class; used in <annotation>, -%note-model;
179
+ - %ref-list.class; used in <ref-list>
180
+ b. NEW MIXES
181
+ - <edition> -%edition-elements;
182
+ - <gov> -%gov-elements;
183
+ - <patent> -%patent-elements;
184
+ - <series-title> -%series-title-elements;
185
+ - <std> -%std-elements;
186
+ - <time-stamp> -%time-stamp-elements;
187
+
188
+
189
+ 3. Updated public identifier to "v2.0 20040830"
190
+
191
+ =============================================================
192
+ Version 1.1 (TRG) v1.1 (2003-11-01)
193
+
194
+ 2. Added element <page-count> to parameter entity
195
+ %references.class;
196
+ Rationale: Permit tagging of page count where included in
197
+ references.
198
+
199
+ =============================================================
200
+ Version 1.0 Post Publishing DTD Change (DAL) v 1.0 2003-02-10
201
+
202
+ 1. Removed <other-ref>, since the Publishing (authoring) DTD did
203
+ not need it and that is what it had been made for. It was
204
+ never to be used for conversion or interchange, so it's gone.
205
+ Removed %other-ref-elements; as well. It did not need to be
206
+ removed from any context, as it was never used.
207
+ -->
208
+
209
+
210
+ <!-- ============================================================= -->
211
+ <!-- PARAMETER ENTITY DEPENDENCIES
212
+ Requires the following parameter entities
213
+ be defined before calling this module,
214
+ usually accomplished in the Customization
215
+ Module for the specific DTD:
216
+ - %emphasis.class;
217
+ - %just-rendition;
218
+ - %label.class;
219
+ - %para-level;
220
+ - %rendition-plus;
221
+ - %simple-phrase;
222
+ - %subsup.class; -->
223
+ <!-- ============================================================= -->
224
+
225
+
226
+ <!-- ============================================================= -->
227
+ <!-- PARAMETER ENTITIES FOR ATTRIBUTE LISTS -->
228
+ <!-- ============================================================= -->
229
+
230
+
231
+ <!-- PERSON GROUP ATTRIBUTES -->
232
+ <!-- Attributes for the <person-group> element -->
233
+ <!ENTITY % person-group-atts
234
+ "person-group-type
235
+ CDATA #IMPLIED" >
236
+
237
+
238
+ <!-- PUBLICATION IDENTIFIER ATTRIBUTES -->
239
+ <!-- Attributes for the <pub-id> element -->
240
+ <!ENTITY % pub-id-atts
241
+ "pub-id-type
242
+ (%pub-id-types;) #IMPLIED" >
243
+
244
+
245
+ <!-- xml:lang The language in which the value of the
246
+ element is expressed. Recommended best
247
+ practice is to use values as defined in
248
+ RFC 1766, typically 2-letter language
249
+ codes such as "FR" (French), "EN" (English),
250
+ and "DE" (German). These values are NOT
251
+ case sensitive, so "EN" = "en". The values
252
+ may include hyphenated differentiations such
253
+ as "EN-AU" (Australian English) and "EN-US"
254
+ (United States English). -->
255
+
256
+
257
+ <!-- SOURCE ATTRIBUTES -->
258
+ <!-- Attributes for the <source> and
259
+ <trans-source> elements -->
260
+ <!ENTITY % source-atts
261
+ "xml:lang NMTOKEN #IMPLIED" >
262
+
263
+ <!-- ============================================================= -->
264
+ <!-- BIBLIOGRAPHIC REFERENCE LIST ELEMENTS -->
265
+ <!-- ============================================================= -->
266
+
267
+
268
+ <!--ELEM article-title
269
+ Defined in %common.ent; -->
270
+ <!--ELEM collab Defined in %common.ent; -->
271
+ <!--ELEM conf-date Defined in %common.ent; -->
272
+ <!--ELEM conf-loc Defined in %common.ent; -->
273
+ <!--ELEM conf-name Defined in %common.ent; -->
274
+ <!--ELEM day Defined in %common.ent; -->
275
+ <!--ELEM elocation-id Defined in %common.ent; -->
276
+ <!--ELEM email Defined in %common.ent; -->
277
+ <!--ELEM fpage Defined in %common.ent; -->
278
+ <!--ELEM issn Defined in %common.ent; -->
279
+ <!--ELEM issue Defined in %common.ent; -->
280
+ <!--ELEM lpage Defined in %common.ent; -->
281
+ <!--ELEM month Defined in %common.ent; -->
282
+ <!--ELEM publisher-loc
283
+ Defined in %common.ent; -->
284
+ <!--ELEM publisher-name
285
+ Defined in %common.ent; -->
286
+ <!--ELEM season Defined in %common.ent; -->
287
+ <!--ELEM title Defined in %common.ent; -->
288
+ <!--ELEM trans-title Defined in %common.ent; -->
289
+ <!--ELEM volume Defined in %common.ent; -->
290
+ <!--ELEM year Defined in %common.ent; -->
291
+
292
+
293
+ <!-- REFERENCE LIST MODEL -->
294
+ <!-- Content model for the <ref-list> element -->
295
+ <!ENTITY % ref-list-model
296
+ "(title?, (%para-level;)*, ref*,
297
+ (%ref-list.class;)* )" >
298
+
299
+
300
+ <!-- REFERENCE LIST (BIBLIOGRAPHIC REFERENCE LIST)
301
+ -->
302
+ <!-- List of references (citations) for the
303
+ article. Often called "References",
304
+ "Bibliography", or "Additional Reading". No
305
+ distinction is made between lists of cited
306
+ references and lists of suggested references.
307
+ Authoring Note: The optional paragraph-level
308
+ elements after the title allow for those rare
309
+ cases where there is explanatory material
310
+ inside the list, before the references. There
311
+ may also be similar explanatory material
312
+ inside each reference group. Explanatory
313
+ material preceding a citation will need to
314
+ be placed inside the citation. -->
315
+ <!ELEMENT ref-list %ref-list-model; >
316
+
317
+
318
+ <!-- REFERENCE ITEM MODEL -->
319
+ <!-- Content model for the <ref> element -->
320
+ <!ENTITY % ref-model "(label?, (citation | note)+ )" >
321
+
322
+
323
+ <!-- REFERENCE ITEM -->
324
+ <!-- One item in a bibliographic list, typically
325
+ a citation describing a referenced work, but
326
+ some journals may place notes in this list as
327
+ well as citations.
328
+ Conversion Note: There is usually a number or
329
+ other label preceding each citation, which
330
+ the tagger may choose to preserve using the
331
+ label attribute. -->
332
+ <!ELEMENT ref %ref-model; >
333
+ <!-- id Unique identifier so that citation can be
334
+ referenced -->
335
+ <!ATTLIST ref
336
+ id ID #IMPLIED >
337
+
338
+
339
+ <!--ELEM citation Defined in %common.ent; -->
340
+
341
+
342
+ <!-- NOTE IN A REFERENCE LIST MODEL -->
343
+ <!ENTITY % note-model "(label?, (%just-para.class;)+ )" >
344
+
345
+
346
+ <!-- NOTE IN A REFERENCE LIST -->
347
+ <!-- Used to tag non-citation material that
348
+ sometimes within a reference list, for
349
+ example, used to tag end note material when
350
+ such a note is placed within a reference
351
+ list.
352
+ Authoring Note: For conversion use only. For
353
+ creating new reference lists, notes should
354
+ not be intermingled with citations. -->
355
+ <!ELEMENT note %note-model; >
356
+ <!-- id Unique identifier so that citation can be
357
+ referenced -->
358
+ <!ATTLIST note
359
+ id ID #IMPLIED >
360
+
361
+
362
+ <!-- ============================================================= -->
363
+ <!-- BIBLIOGRAPHIC REFERENCE CLASS -->
364
+ <!-- ============================================================= -->
365
+
366
+
367
+ <!-- ACCESS DATE ELEMENTS -->
368
+ <!-- The elements that can be included along with
369
+ data characters inside the content model of
370
+ the Access Date <access-date> element -->
371
+ <!ENTITY % access-date-elements
372
+ " " >
373
+
374
+
375
+ <!-- ACCESS DATE FOR CITED WORK -->
376
+ <!-- The date on which the work which is cited
377
+ was examined. Some online resources are
378
+ changing so quickly that a citation to the
379
+ resource is not complete without the date
380
+ on which the cited resource was examined,
381
+ since a day before or a day later the
382
+ relevant material might be different.
383
+ Related Elements: The related element
384
+ <time-stamp> is used to record not the time
385
+ when a cited resource was examined, but the
386
+ time stamp that was found on the resource
387
+ when it was examined, for time-stamped
388
+ resources. -->
389
+ <!ELEMENT access-date (#PCDATA %access-date-elements;)* >
390
+
391
+
392
+ <!-- ANNOTATION IN A CITATION -->
393
+ <!-- Most citations just provide the bibliographic
394
+ information for a cited reference but a few
395
+ describe or comment upon the nature or
396
+ quality of the reference or summarize its
397
+ findings.
398
+ Display Note: All of the other reference
399
+ elements are inline elements. In contrast,
400
+ an Annotation may be considered a block
401
+ element, with space before it and after it.-->
402
+ <!ELEMENT annotation ((%just-para.class;)+) >
403
+
404
+
405
+ <!-- COMMENT ELEMENTS -->
406
+ <!-- The elements that can be included along with
407
+ data characters inside the content model of
408
+ the Comment in a Citation <comment> element.
409
+ DESIGN NOTE: All inline mixes begin with an
410
+ OR bar, but since %simple-phrase; is an
411
+ inline mix, the OR bar is already there. -->
412
+ <!ENTITY % comment-elements
413
+ "%simple-phrase;" >
414
+
415
+
416
+ <!-- COMMENT IN A CITATION -->
417
+ <!-- Used to mark unstructured text within an
418
+ otherwise element structured reference.
419
+ In an unstructured reference, this text would
420
+ merely be data characters.
421
+ Typical comments could include:
422
+ <comment>[Abstract]</comment>
423
+ <comment> translated from Russian</comment>
424
+ DESIGN NOTE: The <comment> element is defined
425
+ here largely for the sake of conversion, to
426
+ preserve the semantic markup when translating
427
+ from other DTDs.
428
+ Authoring and Conversion Note: The Comment
429
+ element should be used to mark substantive
430
+ text only; it should NOT be used to markup
431
+ punctuation that occurs between elements.
432
+ Display Note: Comments should appear inline
433
+ with other reference elements. This is a
434
+ very different rendering from that given the
435
+ similar element Annotation, which is
436
+ typically a longer commentary concerning a
437
+ citation that is rendered as a block
438
+ element.
439
+ DESIGN NOTE: All inline mixes begin with an
440
+ OR bar, but since %simple-phrase; is an
441
+ inline mix, the OR bar is already there. -->
442
+ <!ELEMENT comment (#PCDATA %comment-elements;)* >
443
+
444
+
445
+ <!-- EDITION ELEMENTS -->
446
+ <!-- The elements that can be included along with
447
+ data characters inside the content model of
448
+ <edition>
449
+ Design Note: -%just-rendition; begins with
450
+ an OR bar, so this inline mix begins with
451
+ an OR bar. -->
452
+ <!ENTITY % edition-elements
453
+ "%just-rendition;" >
454
+
455
+ <!-- EDITION, CITED -->
456
+ <!-- The edition number of a cited publication -->
457
+ <!ELEMENT edition (#PCDATA %edition-elements;)* >
458
+
459
+
460
+ <!-- GOVERNMENT REPORT ELEMENTS -->
461
+ <!-- The elements that can be included along with
462
+ data characters inside the content model of
463
+ <gov>
464
+ Design Note: -%rendition-plus; begins with
465
+ an OR bar, so this inline mix begins with
466
+ an OR bar. -->
467
+ <!ENTITY % gov-elements "%rendition-plus;" >
468
+
469
+
470
+ <!-- GOVERNMENT REPORT, CITED -->
471
+ <!-- The identification information (typically the
472
+ title and/or an identification number) for
473
+ a cited governmental report or other
474
+ government publication -->
475
+ <!ELEMENT gov (#PCDATA %gov-elements;)* >
476
+
477
+
478
+ <!-- ISBN -->
479
+ <!-- International Standard Book Number -->
480
+ <!ELEMENT isbn (#PCDATA) >
481
+
482
+
483
+ <!-- PATENT NUMBER ELEMENTS -->
484
+ <!-- The elements that can be included along with
485
+ data characters inside the content model of
486
+ <patent>
487
+ Design Note: -%just-rendition; begins with
488
+ an OR bar, so this inline mix begins with
489
+ an OR bar. -->
490
+ <!ENTITY % patent-elements
491
+ "%just-rendition;" >
492
+
493
+
494
+ <!-- PATENT NUMBER, CITED -->
495
+ <!-- The identification information (typically the
496
+ patent number or number and name) for a
497
+ cited patent -->
498
+ <!ELEMENT patent (#PCDATA %patent-elements;)* >
499
+
500
+
501
+ <!-- PERSON GROUP MODEL -->
502
+ <!-- Content model for the Person Group element -->
503
+ <!ENTITY % person-group-model
504
+ "(%name.class; | aff | etal)*" >
505
+
506
+
507
+ <!-- PERSON GROUP FOR A CITED PUBLICATION -->
508
+ <!-- Wrapper element for one or more authors,
509
+ editors, translators, etc. named in a cited
510
+ reference.
511
+ Remarks: Similar to the <contrib-group>
512
+ element in the metadata, but could not use
513
+ the same name (as this is a DTD not a schema)
514
+ since the content is different. -->
515
+ <!ELEMENT person-group %person-group-model; >
516
+ <!-- person-group-type
517
+ Identifies the "role" of the persons being
518
+ named, a group of authors, a group of
519
+ editors, members of the G&S chorus, etc.
520
+ Valid Types include:
521
+ author - Content creators
522
+ editor - Content editors
523
+ guest-editor
524
+ - Content editor that has been
525
+ invited to edit all or part of
526
+ a work
527
+ inventor
528
+ - Idea, software, or machine creator
529
+ assignee
530
+ - Person to whom a patent is awarded
531
+ translator
532
+ - Translated the cited work from
533
+ one language into another
534
+ trans-editor
535
+ - Editor of a translated version of
536
+ a work
537
+ all-authors
538
+ - Used to identify a complete list
539
+ of authors when a subset of the
540
+ author group is used elsewhere
541
+ in the citation. This may occur,
542
+ for example, when a citation
543
+ identifies both a book and a
544
+ chapter within the book.
545
+ compiler
546
+ - Put together a composite work
547
+ from multiple sources
548
+ -->
549
+ <!ATTLIST person-group
550
+ %person-group-atts; >
551
+
552
+
553
+ <!-- PUBLICATION IDENTIFIER FOR A CITED PUBLICATION
554
+ -->
555
+ <!-- The identifier of a publication such as a
556
+ related journal article that is listed
557
+ within a Citation <citation> inside the
558
+ bibliographic reference list <ref-list> of
559
+ an article. -->
560
+ <!ELEMENT pub-id (#PCDATA) >
561
+ <!-- pub-id-type
562
+ The "pub-id-type" attribute names the
563
+ type of identifier, or the organization or
564
+ system that defined this identifier for the
565
+ identifier of the journal article or a
566
+ cited publication.
567
+ Used on the <article-id> element, which
568
+ holds an identifier for the entire article.
569
+ Also used on the <pub-id> element, which
570
+ is an identifier for a publication cited in
571
+ a bibliographic reference (citation).
572
+ Valid Types include:
573
+ coden - Obsolete PDB/CCDC identifier, may
574
+ be present on older articles
575
+ doi - Digital Object Identifier for
576
+ the publication being referenced
577
+ medline- NLM Medline identifier
578
+ other - None of the named identifiers
579
+ pii - Publisher Item Identifier, see
580
+ /epub/piius.htm
581
+ pmid - PubMed ID (see
582
+ www.ncbi.nlm.nih.gov/entrez/
583
+ query.fcgi?db=PubMed)
584
+ publisher-id -
585
+ Publisher's identifying number
586
+ such as an 'article-id', 'artnum',
587
+ 'identifier', 'article- number',
588
+ etc.
589
+ sici - Serial Item and Contribution
590
+ Identifier (SICI). A journal
591
+ article may have more than one
592
+ SICI, one for a print version and
593
+ one for an electronic version. -->
594
+ <!ATTLIST pub-id
595
+ %pub-id-atts; >
596
+
597
+
598
+ <!-- SERIES ELEMENTS -->
599
+ <!-- The elements that can be included along with
600
+ data characters inside the content model of
601
+ <series>
602
+ Design Note: -%rendition-plus; begins with
603
+ an OR bar, so this inline mix begins with
604
+ an OR bar. -->
605
+ <!ENTITY % series-elements "%rendition-plus;" >
606
+
607
+
608
+ <!-- SERIES -->
609
+ <!-- Container element for any series information
610
+ used in a citation. For example, within a
611
+ citation to a non-journal item that spans
612
+ multiple volumes, this element could contain
613
+ the unique title of the entire series:
614
+ <citation citation-type="book">
615
+ <name>...</name> and <name>...</name>
616
+ <year>1989</year>. <series>The Birds of
617
+ South America</series>. <volume>1</volume>.
618
+ <source>The Oscine Passerines</source>.
619
+ <publisher-name>University of Texas
620
+ Press</publisher-name>
621
+ , <publisher-loc>Austin</publisher-loc>
622
+ </citation>
623
+ -->
624
+ <!ELEMENT series (#PCDATA %series-elements;)* >
625
+
626
+
627
+ <!-- STANDARD ELEMENTS -->
628
+ <!-- The elements that can be included along with
629
+ data characters inside the content model of
630
+ <std>
631
+ Design Note: -%rendition-plus; begins with
632
+ an OR bar, so this inline mix begins with
633
+ an OR bar. -->
634
+ <!ENTITY % std-elements "%rendition-plus;" >
635
+
636
+
637
+ <!-- STANDARD, CITED -->
638
+ <!-- The identification information (typically the
639
+ standard number, organization, and name) for
640
+ a cited standard, where "standard" is defined
641
+ as a document produced by a recognized
642
+ standards body such ISO, IEEE, OASIS, ANSI,
643
+ etc. -->
644
+ <!ELEMENT std (#PCDATA %std-elements;)* >
645
+
646
+
647
+ <!-- SOURCE ELEMENTS -->
648
+ <!-- The elements that can be included along with
649
+ data characters inside the content model of
650
+ a <source>. -->
651
+ <!ENTITY % source-elements
652
+ "| %emphasis.class; | %address-link.class; |
653
+ %subsup.class;" >
654
+
655
+
656
+ <!-- SOURCE -->
657
+ <!-- Within a citation, this is the title of a
658
+ journal, book, conference proceedings, etc.
659
+ that is the source of the cited material. -->
660
+ <!ELEMENT source (#PCDATA %source-elements;)* >
661
+ <!-- xml:lang The language in which the value of the
662
+ element is expressed. Recommended best
663
+ practice is to use values as defined in
664
+ RFC 1766, typically 2-letter language
665
+ codes such as "FR" (French), "EN" (English),
666
+ and "DE" (German). These values are NOT
667
+ case sensitive, so "EN" = "en". The values
668
+ may include hyphenated differentiations such
669
+ as "EN-AU" (Australian English) and "EN-US"
670
+ (United States English). -->
671
+ <!ATTLIST source
672
+ %source-atts; >
673
+
674
+
675
+ <!-- TIME STAMP ELEMENTS -->
676
+ <!-- The elements that can be included along with
677
+ data characters inside the content model of
678
+ a <time-stamp>. -->
679
+ <!ENTITY % time-stamp-elements
680
+ " " >
681
+
682
+
683
+ <!-- TIME STAMP FOR CITED WORK -->
684
+ <!-- Used to record any time stamp that was
685
+ found on the cited resource when it was
686
+ examined, for resources such as databases
687
+ that may use a time signature to identify
688
+ different versions. Note: This is not the
689
+ time when the cited resource was examined,
690
+ but rather the time it was produced,
691
+ distributed, whatever milestone the resource
692
+ creators chose to stamp time stamp.
693
+ Related Element: <access-date> is the date
694
+ on which the cited work was examined. Some
695
+ online resources are changing so quickly
696
+ that a citation to the resource is not
697
+ complete without the date. -->
698
+ <!ELEMENT time-stamp (#PCDATA %time-stamp-elements;) >
699
+
700
+
701
+ <!-- TRANSLATED SOURCE -->
702
+ <!-- Within a citation, this is the title of a
703
+ journal, book, conference proceedings, etc.
704
+ that is the source of the cited material,
705
+ but with the source name given in a different
706
+ language from the source as given in the
707
+ <source> element. For example, if an article
708
+ is originally in French, the <source> name
709
+ would be the French name and the
710
+ <trans-source> might be in English. -->
711
+ <!ELEMENT trans-source (#PCDATA %source-elements;)* >
712
+ <!-- xml:lang The language in which the value of the
713
+ element is expressed. Recommended best
714
+ practice is to use values as defined in
715
+ RFC 1766, typically 2-letter language
716
+ codes such as "FR" (French), "EN" (English),
717
+ and "DE" (German). These values are NOT
718
+ case sensitive, so "EN" = "en". The values
719
+ may include hyphenated differentiates such
720
+ as "EN-AU" (Australian English) and "EN-US"
721
+ (United States English). -->
722
+ <!ATTLIST trans-source
723
+ %source-atts; >
724
+
725
+
726
+ <!-- ================== End Bibliographic Class Module =========== -->
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/section.ent ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- ============================================================= -->
2
+ <!-- MODULE: Section Class Elements -->
3
+ <!-- VERSION: 2.0 -->
4
+ <!-- DATE: August 2004 -->
5
+ <!-- -->
6
+ <!-- ============================================================= -->
7
+
8
+ <!-- ============================================================= -->
9
+ <!-- PUBLIC DOCUMENT TYPE DEFINITION -->
10
+ <!-- TYPICAL INVOCATION -->
11
+ <!--
12
+ "-//NLM//DTD Archiving and Interchange DTD Suite Section Class Elements v2.0 20040830//EN"
13
+ Delivered as file "section.ent" -->
14
+ <!-- ============================================================= -->
15
+
16
+ <!-- ============================================================= -->
17
+ <!-- SYSTEM: Archiving and Interchange DTD Suite -->
18
+ <!-- -->
19
+ <!-- PURPOSE: Defines the member of the sec.class, that is, -->
20
+ <!-- names all section-level elements in the -->
21
+ <!-- Archiving and Interchange DTD Suite -->
22
+ <!-- -->
23
+ <!-- At the time of the initial DTD creation -->
24
+ <!-- there is only one such element, Section itself -->
25
+ <!-- <sec>, but future expansion to named sections -->
26
+ <!-- (such as <methodology> or <materials> or any -->
27
+ <!-- new section-level structures would be added here. -->
28
+ <!-- -->
29
+ <!-- CONTAINS: 1) Default definition of the section class -->
30
+ <!-- 2) Defaults for attribute lists -->
31
+ <!-- 3) Section <sec> -->
32
+ <!-- -->
33
+ <!-- CREATED FOR: -->
34
+ <!-- Digital archives and publishers who wish to -->
35
+ <!-- create a custom XML DTD for original markup of -->
36
+ <!-- journal literature, books, and related material, -->
37
+ <!-- or for archiving and transferring such material -->
38
+ <!-- between archives. -->
39
+ <!-- -->
40
+ <!-- This DTD is in the public domain. An organization -->
41
+ <!-- that wishes to create its own DTD from the suite -->
42
+ <!-- may do so without permission from NLM. -->
43
+ <!-- -->
44
+ <!-- The suite has been set up to be extended using a -->
45
+ <!-- new DTD file and a new DTD-specific customization -->
46
+ <!-- module to redefine the many Parameter Entities. -->
47
+ <!-- Do not modify the suite directly or redistribute -->
48
+ <!-- modified versions of the suite. -->
49
+ <!-- -->
50
+ <!-- In the interest of maintaining consistency and -->
51
+ <!-- clarity for potential users, NLM requests: -->
52
+ <!-- -->
53
+ <!-- 1. If you create a DTD from the Archiving and -->
54
+ <!-- Interchange DTD Suite and intend to stay -->
55
+ <!-- compatible with the suite, then please include -->
56
+ <!-- the following statement as a comment in all of -->
57
+ <!-- your DTD modules: -->
58
+ <!-- "Created from, and fully compatible with, -->
59
+ <!-- the Archiving and Interchange DTD Suite." -->
60
+ <!-- -->
61
+ <!-- 2. If you alter one or more modules of the suite, -->
62
+ <!-- then please rename your version and all its -->
63
+ <!-- modules to avoid any confusion with the -->
64
+ <!-- original suite. Also, please include the -->
65
+ <!-- following statement as a comment in all your -->
66
+ <!-- DTD modules: -->
67
+ <!-- "Based in part on, but not fully compatible -->
68
+ <!-- with, the Archiving and Interchange DTD -->
69
+ <!-- Suite." -->
70
+ <!-- -->
71
+ <!-- Suggestions for refinements and enhancements to -->
72
+ <!-- the DTD suite should be sent in email to: -->
73
+ <!-- archive-dtd@ncbi.nlm.nih.gov -->
74
+ <!-- -->
75
+ <!-- ORIGINAL CREATION DATE: -->
76
+ <!-- December 2002 -->
77
+ <!-- -->
78
+ <!-- CREATED BY: Jeff Beck (NCBI) -->
79
+ <!-- Deborah Lapeyre (Mulberry Technologies, Inc.) -->
80
+ <!-- Bruce Rosenblum (Inera Inc.) -->
81
+ <!-- -->
82
+ <!-- NLM thanks the Harvard University Libraries, both -->
83
+ <!-- for proposing that a draft archiving NLM DTD for -->
84
+ <!-- life sciences journals be extended to accommodate -->
85
+ <!-- journals in all disciplines and for sponsoring -->
86
+ <!-- Bruce Rosenblum's collaboration with other DTD -->
87
+ <!-- authors in completing Version 1.0. The Andrew W. -->
88
+ <!-- Mellon Foundation provided support for these -->
89
+ <!-- important contributions. -->
90
+ <!-- -->
91
+ <!-- ============================================================= -->
92
+
93
+
94
+ <!-- ============================================================= -->
95
+ <!-- DTD VERSION/CHANGE HISTORY -->
96
+ <!-- ============================================================= -->
97
+ <!--
98
+ =============================================================
99
+
100
+ Version Reason/Occasion (who) vx.x (yyyy-mm-dd)
101
+
102
+ =============================================================
103
+ Version 2.0 (DAL/BTU) v2.0 (2004-08-30)
104
+
105
+ Major requirement changes led to the new release, producing
106
+ DTD version "2.0":
107
+ a) The splitting of the Archival and Interchange Tag Set
108
+ DTDs into three DTDs from two: an authoring DTD, an
109
+ archive regularization and interchange DTD (the
110
+ current Blue Publishing DTD), and a preservationist
111
+ archive DTD (the current Green Archiving and Interchange
112
+ DTD).
113
+ b) AIT Working Group suggestions from the June 04 meeting
114
+ and June/July 2004 followup discussions
115
+ c) Suite remodularization to meet new (and newly articulated)
116
+ modularization requirements
117
+ d) New or renamed classes and mixes to make modifications
118
+ easier and more consistent
119
+
120
+ 3. COMPLETE MODELS WHEN OVER-RIDING A MODEL
121
+ (for all Parameter Entities suffixed "-model")
122
+ ### Customization Alert ###
123
+ Added internal parentheses to Parameter Entity and removed
124
+ them from Element Declaration for:
125
+ - %sec-model;
126
+
127
+ 2. DEFAULT CLASSES - Were moved from this module to
128
+ %default-classes.ent;
129
+
130
+ 1. Updated public identifier to "v2.0 20040830"
131
+ -->
132
+
133
+
134
+ <!-- ============================================================= -->
135
+ <!-- PARAMETER ENTITY DEPENDENCIES
136
+ Requires the following parameter entities
137
+ be defined before calling this module.
138
+ The content-model Parameter Entities are
139
+ defined in %common.ent; but may be
140
+ redefined in the Customization Module for
141
+ the specific DTD:
142
+ %sec-model; - Content model for section-like
143
+ elements
144
+ -->
145
+ <!-- ============================================================= -->
146
+
147
+
148
+ <!-- ============================================================= -->
149
+ <!-- DEFAULTS FOR ATTRIBUTE LISTS -->
150
+ <!-- ============================================================= -->
151
+
152
+
153
+ <!-- SECTION ATTRIBUTES -->
154
+ <!-- Attribute list for Section element -->
155
+ <!ENTITY % sec-atts
156
+ "id ID #IMPLIED
157
+ xml:lang NMTOKEN #IMPLIED
158
+ sec-type CDATA #IMPLIED
159
+ disp-level CDATA #IMPLIED" >
160
+
161
+
162
+ <!-- ============================================================= -->
163
+ <!-- SECTION ELEMENTS -->
164
+ <!-- ============================================================= -->
165
+
166
+
167
+ <!-- SECTION -->
168
+ <!-- A headed group of material; the basic
169
+ structural unit of the article -->
170
+ <!ELEMENT sec %sec-model; >
171
+ <!-- id Unique identifier, so the Section can be
172
+ referenced
173
+ xml:lang The language in which the value of the
174
+ element is expressed. Recommended best
175
+ practice is to use values as defined in
176
+ RFC 1766, typically 2-letter language
177
+ codes such as "FR" (French), "EN" (English),
178
+ and "DE" (German). These values are NOT
179
+ case sensitive, so "EN" = "en". The values
180
+ may include hyphenated differentiations such
181
+ as "EN-AU" (Australian English) and "EN-US"
182
+ (United States English).
183
+ sec-type Conversion Note: This attribute may be used
184
+ to retain information on the semantic
185
+ content of a section where that is known.
186
+ Authoring Note: Top-level sections (those
187
+ that are not nested inside other sections)
188
+ may be assigned a "type" attribute for
189
+ indexing purposes. This attribute should be
190
+ used only if the section is one of the listed
191
+ types and should otherwise be omitted. A
192
+ section that contains content of more than
193
+ one type should have the type IDs combined.
194
+ (e.g., "Materials and Methods" would be
195
+ type="materials|methods").
196
+ Types values are:
197
+ intro Introduction/Synopsis
198
+ materials Materials
199
+ methods Methods/Methodology/Procedures
200
+ subjects Patients/Participants/Subjects
201
+ cases Cases/Case Reports
202
+ results Results/Statement of Findings
203
+ discussion Discussion/Interpretation
204
+ conclusions Conclusions/Comment
205
+ disp-level Sometimes in print or on screen, the display
206
+ or apparent hierarchical level of a section
207
+ is not the same as its real position in the
208
+ hierarchy. For example, in some styles,
209
+ the "Clinical Finding" Section or the
210
+ 'Methodology" Section always looks like a
211
+ particular level heading (say a level 2 head),
212
+ wherever it falls in the hierarchy (say a
213
+ level 1 head or a level 3 head). This
214
+ attribute can be used to record the needed
215
+ display level. (Rare) -->
216
+ <!ATTLIST sec
217
+ %sec-atts; >
218
+
219
+
220
+ <!-- ================== End Section Class Module ================= -->
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/taxon.dtd ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- ?xml version="1.0"? -->
2
+ <!-- DOCTYPE TaxaSet PUBLIC "-//NLM//DTD TaxaSet, 20 February 2004//EN" "taxon.dtd" -->
3
+
4
+ <!-- $Id: taxon.dtd 348960 2012-01-05 21:51:40Z yasmax $ -->
5
+
6
+ <!-- ELEMENTS -->
7
+ <!ELEMENT TaxId (#PCDATA)>
8
+ <!ELEMENT ParentTaxId (#PCDATA)>
9
+ <!ELEMENT Division (#PCDATA)>
10
+ <!ELEMENT Rank (#PCDATA)>
11
+ <!ELEMENT ClassCDE (#PCDATA)>
12
+ <!ELEMENT DispName (#PCDATA)>
13
+ <!ELEMENT UniqueName (#PCDATA)>
14
+ <!ELEMENT GCId (#PCDATA)>
15
+ <!ELEMENT GCName (#PCDATA)>
16
+ <!ELEMENT MGCId (#PCDATA)>
17
+ <!ELEMENT MGCName (#PCDATA)>
18
+ <!ELEMENT Lineage (#PCDATA)>
19
+ <!ELEMENT PropName (#PCDATA)>
20
+ <!ELEMENT CreateDate (#PCDATA)>
21
+ <!ELEMENT UpdateDate (#PCDATA)>
22
+ <!ELEMENT PubDate (#PCDATA)>
23
+ <!ELEMENT CitId (#PCDATA)>
24
+ <!ELEMENT CitKey (#PCDATA)>
25
+ <!ELEMENT CitUrl (#PCDATA)>
26
+ <!ELEMENT CitText (#PCDATA)>
27
+ <!ELEMENT CitPubmedId (#PCDATA)>
28
+ <!ELEMENT CitMedlineId (#PCDATA)>
29
+ <!ELEMENT ModId (#PCDATA)>
30
+ <!ELEMENT ModType (#PCDATA)>
31
+ <!ELEMENT ModName (#PCDATA)>
32
+ <!ELEMENT ModGBhidden (#PCDATA)>
33
+ <!ELEMENT RModId (#PCDATA)>
34
+ <!ELEMENT RTaxId (#PCDATA)>
35
+ <!ELEMENT ScientificName (#PCDATA)>
36
+ <!ELEMENT GenbankCommonName (#PCDATA)>
37
+ <!ELEMENT GenbankAcronym (#PCDATA)>
38
+ <!ELEMENT BlastName (#PCDATA)>
39
+ <!ELEMENT EquivalentName (#PCDATA)>
40
+ <!ELEMENT Synonym (#PCDATA)>
41
+ <!ELEMENT Acronym (#PCDATA)>
42
+ <!ELEMENT Misspelling (#PCDATA)>
43
+ <!ELEMENT Anamorph (#PCDATA)>
44
+ <!ELEMENT Includes (#PCDATA)>
45
+ <!ELEMENT CommonName (#PCDATA)>
46
+ <!ELEMENT Inpart (#PCDATA)>
47
+ <!ELEMENT Misnomer (#PCDATA)>
48
+ <!ELEMENT Teleomorph (#PCDATA)>
49
+ <!ELEMENT GenbankSynonym (#PCDATA)>
50
+ <!ELEMENT GenbankAnamorph (#PCDATA)>
51
+ <!ELEMENT PropValueInt (#PCDATA)>
52
+ <!ELEMENT PropValueBool (#PCDATA)>
53
+ <!ELEMENT PropValueString (#PCDATA)>
54
+
55
+ <!-- Taxon structural entities -->
56
+ <!ELEMENT TaxaSet ( Taxon* )>
57
+
58
+ <!ELEMENT Taxon (
59
+ TaxId,
60
+ ScientificName,
61
+ OtherNames?,
62
+ ParentTaxId?,
63
+ Rank?,
64
+ Division?,
65
+ GeneticCode?,
66
+ MitoGeneticCode?,
67
+ Lineage?,
68
+ LineageEx?,
69
+ Citations?,
70
+ Modifiers?,
71
+ Properties?,
72
+ CreateDate?,
73
+ UpdateDate?,
74
+ PubDate?,
75
+ AkaTaxIds?
76
+ )>
77
+
78
+
79
+ <!ELEMENT OtherNames ( GenbankCommonName?,
80
+ GenbankAcronym?,
81
+ BlastName?,
82
+ ( EquivalentName |
83
+ Synonym |
84
+ Acronym |
85
+ Misspelling |
86
+ Anamorph |
87
+ Includes |
88
+ CommonName |
89
+ Inpart |
90
+ Misnomer |
91
+ Teleomorph |
92
+ GenbankSynonym |
93
+ GenbankAnamorph
94
+ )*,
95
+ Name*
96
+ )>
97
+
98
+ <!ELEMENT Name ( ClassCDE, DispName, UniqueName? )>
99
+
100
+ <!ELEMENT GeneticCode ( GCId, GCName )>
101
+
102
+ <!ELEMENT MitoGeneticCode ( MGCId, MGCName )>
103
+
104
+ <!ELEMENT Citations ( Citation+ )>
105
+
106
+ <!ELEMENT Citation ( CitId,
107
+ CitKey,
108
+ CitUrl?,
109
+ CitText?,
110
+ CitPubmedId?,
111
+ CitMedlineId?
112
+ )>
113
+
114
+ <!ELEMENT Modifiers ( Modifier+ )>
115
+
116
+ <!ELEMENT Modifier ( ModId,
117
+ ModType,
118
+ ModName,
119
+ ModGBhidden,
120
+ ( RModId | RTaxId )?
121
+ )>
122
+
123
+ <!ELEMENT Properties ( Property+ )>
124
+
125
+ <!ELEMENT Property ( PropName, ( PropValueInt |
126
+ PropValueBool |
127
+ PropValueString ) )>
128
+
129
+ <!ELEMENT AkaTaxIds ( TaxId* )>
130
+
131
+ <!ELEMENT LineageEx ( Taxon* )>
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/xhtml-inlstyle-1.mod ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- ...................................................................... -->
2
+ <!-- XHTML Inline Style Module ........................................... -->
3
+ <!-- file: xhtml-inlstyle-1.mod
4
+
5
+ This is XHTML, a reformulation of HTML as a modular XML application.
6
+ Copyright 1998-2005 W3C (MIT, ERCIM, Keio), All Rights Reserved.
7
+ Revision: $Id: xhtml-inlstyle-1.mod,v 4.0 2001/04/02 22:42:49 altheim Exp $
8
+
9
+ This DTD module is identified by the PUBLIC and SYSTEM identifiers:
10
+
11
+ PUBLIC "-//W3C//ENTITIES XHTML Inline Style 1.0//EN"
12
+ SYSTEM "http://www.w3.org/MarkUp/DTD/xhtml-inlstyle-1.mod"
13
+
14
+ Revisions:
15
+ (none)
16
+ ....................................................................... -->
17
+
18
+ <!-- Inline Style
19
+
20
+ This module declares the 'style' attribute, used to support inline
21
+ style markup. This module must be instantiated prior to the XHTML
22
+ Common Attributes module in order to be included in %Core.attrib;.
23
+ -->
24
+
25
+ <!ENTITY % style.attrib
26
+ "style CDATA #IMPLIED"
27
+ >
28
+
29
+
30
+ <!ENTITY % Core.extra.attrib
31
+ "%style.attrib;"
32
+ >
33
+
34
+ <!-- end of xhtml-inlstyle-1.mod -->
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/xhtml-table-1.mod ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- ...................................................................... -->
2
+ <!-- XHTML Table Module .................................................. -->
3
+ <!-- file: xhtml-table-1.mod
4
+
5
+ This is XHTML, a reformulation of HTML as a modular XML application.
6
+ Copyright 1998-2005 W3C (MIT, ERCIM, Keio), All Rights Reserved.
7
+ Revision: $Id: xhtml-table-1.mod,v 4.1 2001/04/10 09:42:30 altheim Exp $ SMI
8
+
9
+ This DTD module is identified by the PUBLIC and SYSTEM identifiers:
10
+
11
+ PUBLIC "-//W3C//ELEMENTS XHTML Tables 1.0//EN"
12
+ SYSTEM "http://www.w3.org/MarkUp/DTD/xhtml-table-1.mod"
13
+
14
+ Revisions:
15
+ (none)
16
+ ....................................................................... -->
17
+
18
+ <!-- Tables
19
+
20
+ table, caption, thead, tfoot, tbody, colgroup, col, tr, th, td
21
+
22
+ This module declares element types and attributes used to provide
23
+ table markup similar to HTML 4, including features that enable
24
+ better accessibility for non-visual user agents.
25
+ -->
26
+
27
+ <!-- declare qualified element type names:
28
+ -->
29
+ <!ENTITY % table.qname "table" >
30
+ <!ENTITY % caption.qname "caption" >
31
+ <!ENTITY % thead.qname "thead" >
32
+ <!ENTITY % tfoot.qname "tfoot" >
33
+ <!ENTITY % tbody.qname "tbody" >
34
+ <!ENTITY % colgroup.qname "colgroup" >
35
+ <!ENTITY % col.qname "col" >
36
+ <!ENTITY % tr.qname "tr" >
37
+ <!ENTITY % th.qname "th" >
38
+ <!ENTITY % td.qname "td" >
39
+
40
+ <!-- The frame attribute specifies which parts of the frame around
41
+ the table should be rendered. The values are not the same as
42
+ CALS to avoid a name clash with the valign attribute.
43
+ -->
44
+ <!ENTITY % frame.attrib
45
+ "frame ( void
46
+ | above
47
+ | below
48
+ | hsides
49
+ | lhs
50
+ | rhs
51
+ | vsides
52
+ | box
53
+ | border ) #IMPLIED"
54
+ >
55
+
56
+ <!-- The rules attribute defines which rules to draw between cells:
57
+
58
+ If rules is absent then assume:
59
+
60
+ "none" if border is absent or border="0" otherwise "all"
61
+ -->
62
+ <!ENTITY % rules.attrib
63
+ "rules ( none
64
+ | groups
65
+ | rows
66
+ | cols
67
+ | all ) #IMPLIED"
68
+ >
69
+
70
+ <!-- horizontal alignment attributes for cell contents
71
+ -->
72
+ <!ENTITY % CellHAlign.attrib
73
+ "align ( left
74
+ | center
75
+ | right
76
+ | justify
77
+ | char ) #IMPLIED
78
+ char %Character.datatype; #IMPLIED
79
+ charoff %Length.datatype; #IMPLIED"
80
+ >
81
+
82
+ <!-- vertical alignment attribute for cell contents
83
+ -->
84
+ <!ENTITY % CellVAlign.attrib
85
+ "valign ( top
86
+ | middle
87
+ | bottom
88
+ | baseline ) #IMPLIED"
89
+ >
90
+
91
+ <!-- scope is simpler than axes attribute for common tables
92
+ -->
93
+ <!ENTITY % scope.attrib
94
+ "scope ( row
95
+ | col
96
+ | rowgroup
97
+ | colgroup ) #IMPLIED"
98
+ >
99
+
100
+ <!-- table: Table Element .............................. -->
101
+
102
+ <!ENTITY % table.element "INCLUDE" >
103
+ <![%table.element;[
104
+ <!ENTITY % table.content
105
+ "( %caption.qname;?, ( %col.qname;* | %colgroup.qname;* ),
106
+ (( %thead.qname;?, %tfoot.qname;?, %tbody.qname;+ ) | ( %tr.qname;+ )))"
107
+ >
108
+ <!ELEMENT %table.qname; %table.content; >
109
+ <!-- end of table.element -->]]>
110
+
111
+ <!ENTITY % table.attlist "INCLUDE" >
112
+ <![%table.attlist;[
113
+ <!ATTLIST %table.qname;
114
+ %Common.attrib;
115
+ summary %Text.datatype; #IMPLIED
116
+ width %Length.datatype; #IMPLIED
117
+ border %Pixels.datatype; #IMPLIED
118
+ %frame.attrib;
119
+ %rules.attrib;
120
+ cellspacing %Length.datatype; #IMPLIED
121
+ cellpadding %Length.datatype; #IMPLIED
122
+ >
123
+ <!-- end of table.attlist -->]]>
124
+
125
+ <!-- caption: Table Caption ............................ -->
126
+
127
+ <!ENTITY % caption.element "INCLUDE" >
128
+ <![%caption.element;[
129
+ <!ENTITY % caption.content
130
+ "( #PCDATA | %Inline.mix; )*"
131
+ >
132
+ <!ELEMENT %caption.qname; %caption.content; >
133
+ <!-- end of caption.element -->]]>
134
+
135
+ <!ENTITY % caption.attlist "INCLUDE" >
136
+ <![%caption.attlist;[
137
+ <!ATTLIST %caption.qname;
138
+ %Common.attrib;
139
+ >
140
+ <!-- end of caption.attlist -->]]>
141
+
142
+ <!-- thead: Table Header ............................... -->
143
+
144
+ <!-- Use thead to duplicate headers when breaking table
145
+ across page boundaries, or for static headers when
146
+ tbody sections are rendered in scrolling panel.
147
+ -->
148
+
149
+ <!ENTITY % thead.element "INCLUDE" >
150
+ <![%thead.element;[
151
+ <!ENTITY % thead.content "( %tr.qname; )+" >
152
+ <!ELEMENT %thead.qname; %thead.content; >
153
+ <!-- end of thead.element -->]]>
154
+
155
+ <!ENTITY % thead.attlist "INCLUDE" >
156
+ <![%thead.attlist;[
157
+ <!ATTLIST %thead.qname;
158
+ %Common.attrib;
159
+ %CellHAlign.attrib;
160
+ %CellVAlign.attrib;
161
+ >
162
+ <!-- end of thead.attlist -->]]>
163
+
164
+ <!-- tfoot: Table Footer ............................... -->
165
+
166
+ <!-- Use tfoot to duplicate footers when breaking table
167
+ across page boundaries, or for static footers when
168
+ tbody sections are rendered in scrolling panel.
169
+ -->
170
+
171
+ <!ENTITY % tfoot.element "INCLUDE" >
172
+ <![%tfoot.element;[
173
+ <!ENTITY % tfoot.content "( %tr.qname; )+" >
174
+ <!ELEMENT %tfoot.qname; %tfoot.content; >
175
+ <!-- end of tfoot.element -->]]>
176
+
177
+ <!ENTITY % tfoot.attlist "INCLUDE" >
178
+ <![%tfoot.attlist;[
179
+ <!ATTLIST %tfoot.qname;
180
+ %Common.attrib;
181
+ %CellHAlign.attrib;
182
+ %CellVAlign.attrib;
183
+ >
184
+ <!-- end of tfoot.attlist -->]]>
185
+
186
+ <!-- tbody: Table Body ................................. -->
187
+
188
+ <!-- Use multiple tbody sections when rules are needed
189
+ between groups of table rows.
190
+ -->
191
+
192
+ <!ENTITY % tbody.element "INCLUDE" >
193
+ <![%tbody.element;[
194
+ <!ENTITY % tbody.content "( %tr.qname; )+" >
195
+ <!ELEMENT %tbody.qname; %tbody.content; >
196
+ <!-- end of tbody.element -->]]>
197
+
198
+ <!ENTITY % tbody.attlist "INCLUDE" >
199
+ <![%tbody.attlist;[
200
+ <!ATTLIST %tbody.qname;
201
+ %Common.attrib;
202
+ %CellHAlign.attrib;
203
+ %CellVAlign.attrib;
204
+ >
205
+ <!-- end of tbody.attlist -->]]>
206
+
207
+ <!-- colgroup: Table Column Group ...................... -->
208
+
209
+ <!-- colgroup groups a set of col elements. It allows you
210
+ to group several semantically-related columns together.
211
+ -->
212
+
213
+ <!ENTITY % colgroup.element "INCLUDE" >
214
+ <![%colgroup.element;[
215
+ <!ENTITY % colgroup.content "( %col.qname; )*" >
216
+ <!ELEMENT %colgroup.qname; %colgroup.content; >
217
+ <!-- end of colgroup.element -->]]>
218
+
219
+ <!ENTITY % colgroup.attlist "INCLUDE" >
220
+ <![%colgroup.attlist;[
221
+ <!ATTLIST %colgroup.qname;
222
+ %Common.attrib;
223
+ span %Number.datatype; '1'
224
+ width %MultiLength.datatype; #IMPLIED
225
+ %CellHAlign.attrib;
226
+ %CellVAlign.attrib;
227
+ >
228
+ <!-- end of colgroup.attlist -->]]>
229
+
230
+ <!-- col: Table Column ................................. -->
231
+
232
+ <!-- col elements define the alignment properties for
233
+ cells in one or more columns.
234
+
235
+ The width attribute specifies the width of the
236
+ columns, e.g.
237
+
238
+ width="64" width in screen pixels
239
+ width="0.5*" relative width of 0.5
240
+
241
+ The span attribute causes the attributes of one
242
+ col element to apply to more than one column.
243
+ -->
244
+
245
+ <!ENTITY % col.element "INCLUDE" >
246
+ <![%col.element;[
247
+ <!ENTITY % col.content "EMPTY" >
248
+ <!ELEMENT %col.qname; %col.content; >
249
+ <!-- end of col.element -->]]>
250
+
251
+ <!ENTITY % col.attlist "INCLUDE" >
252
+ <![%col.attlist;[
253
+ <!ATTLIST %col.qname;
254
+ %Common.attrib;
255
+ span %Number.datatype; '1'
256
+ width %MultiLength.datatype; #IMPLIED
257
+ %CellHAlign.attrib;
258
+ %CellVAlign.attrib;
259
+ >
260
+ <!-- end of col.attlist -->]]>
261
+
262
+ <!-- tr: Table Row ..................................... -->
263
+
264
+ <!ENTITY % tr.element "INCLUDE" >
265
+ <![%tr.element;[
266
+ <!ENTITY % tr.content "( %th.qname; | %td.qname; )+" >
267
+ <!ELEMENT %tr.qname; %tr.content; >
268
+ <!-- end of tr.element -->]]>
269
+
270
+ <!ENTITY % tr.attlist "INCLUDE" >
271
+ <![%tr.attlist;[
272
+ <!ATTLIST %tr.qname;
273
+ %Common.attrib;
274
+ %CellHAlign.attrib;
275
+ %CellVAlign.attrib;
276
+ >
277
+ <!-- end of tr.attlist -->]]>
278
+
279
+ <!-- th: Table Header Cell ............................. -->
280
+
281
+ <!-- th is for header cells, td for data,
282
+ but for cells acting as both use td
283
+ -->
284
+
285
+ <!ENTITY % th.element "INCLUDE" >
286
+ <![%th.element;[
287
+ <!ENTITY % th.content
288
+ "( #PCDATA | %Flow.mix; )*"
289
+ >
290
+ <!ELEMENT %th.qname; %th.content; >
291
+ <!-- end of th.element -->]]>
292
+
293
+ <!ENTITY % th.attlist "INCLUDE" >
294
+ <![%th.attlist;[
295
+ <!ATTLIST %th.qname;
296
+ %Common.attrib;
297
+ abbr %Text.datatype; #IMPLIED
298
+ axis CDATA #IMPLIED
299
+ headers IDREFS #IMPLIED
300
+ %scope.attrib;
301
+ rowspan %Number.datatype; '1'
302
+ colspan %Number.datatype; '1'
303
+ %CellHAlign.attrib;
304
+ %CellVAlign.attrib;
305
+ >
306
+ <!-- end of th.attlist -->]]>
307
+
308
+ <!-- td: Table Data Cell ............................... -->
309
+
310
+ <!ENTITY % td.element "INCLUDE" >
311
+ <![%td.element;[
312
+ <!ENTITY % td.content
313
+ "( #PCDATA | %Flow.mix; )*"
314
+ >
315
+ <!ELEMENT %td.qname; %td.content; >
316
+ <!-- end of td.element -->]]>
317
+
318
+ <!ENTITY % td.attlist "INCLUDE" >
319
+ <![%td.attlist;[
320
+ <!ATTLIST %td.qname;
321
+ %Common.attrib;
322
+ abbr %Text.datatype; #IMPLIED
323
+ axis CDATA #IMPLIED
324
+ headers IDREFS #IMPLIED
325
+ %scope.attrib;
326
+ rowspan %Number.datatype; '1'
327
+ colspan %Number.datatype; '1'
328
+ %CellHAlign.attrib;
329
+ %CellVAlign.attrib;
330
+ >
331
+ <!-- end of td.attlist -->]]>
332
+
333
+ <!-- end of xhtml-table-1.mod -->
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/DTDs/xmlspecchars.ent ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- ============================================================= -->
2
+ <!-- MODULE: XML Special Characters Module -->
3
+ <!-- VERSION: 2.0 -->
4
+ <!-- DATE: August 2004 -->
5
+ <!-- ============================================================= -->
6
+
7
+ <!-- ============================================================= -->
8
+ <!-- PUBLIC DOCUMENT TYPE DEFINITION -->
9
+ <!-- TYPICAL INVOCATION -->
10
+ <!--
11
+ "-//NLM//DTD Archiving and Interchange DTD Suite XML Special Characters Module v2.0 20040830//EN"
12
+ Delivered as file "xmlspecchars.ent" -->
13
+ <!-- ============================================================= -->
14
+
15
+ <!-- ============================================================= -->
16
+ <!-- SYSTEM: Archiving and Interchange DTD Suite -->
17
+ <!-- -->
18
+ <!-- PURPOSE: External Parameter Entities for calling in the -->
19
+ <!-- special character entities -->
20
+ <!-- -->
21
+ <!-- CONTAINS: 1) Calls to external entity sets -->
22
+ <!-- -->
23
+ <!-- MODULES REQUIRED: -->
24
+ <!-- The standard ISO special character entity sets -->
25
+ <!-- (see below) -->
26
+ <!-- -->
27
+ <!-- CREATED FOR: -->
28
+ <!-- Digital archives and publishers who wish to -->
29
+ <!-- create a custom XML DTD for original markup of -->
30
+ <!-- journal literature, books, and related material, -->
31
+ <!-- or for archiving and transferring such material -->
32
+ <!-- between archives. -->
33
+ <!-- -->
34
+ <!-- This DTD is in the public domain. An organization -->
35
+ <!-- that wishes to create its own DTD from the suite -->
36
+ <!-- may do so without permission from NLM. -->
37
+ <!-- -->
38
+ <!-- The suite has been set up to be extended using a -->
39
+ <!-- new DTD file and a new DTD-specific customization -->
40
+ <!-- module to redefine the many Parameter Entities. -->
41
+ <!-- Do not modify the suite directly or redistribute -->
42
+ <!-- modified versions of the suite. -->
43
+ <!-- -->
44
+ <!-- In the interest of maintaining consistency and -->
45
+ <!-- clarity for potential users, NLM requests: -->
46
+ <!-- -->
47
+ <!-- 1. If you create a DTD from the Archiving and -->
48
+ <!-- Interchange DTD Suite and intend to stay -->
49
+ <!-- compatible with the suite, then please include -->
50
+ <!-- the following statement as a comment in all of -->
51
+ <!-- your DTD modules: -->
52
+ <!-- "Created from, and fully compatible with, -->
53
+ <!-- the Archiving and Interchange DTD Suite." -->
54
+ <!-- -->
55
+ <!-- 2. If you alter one or more modules of the suite, -->
56
+ <!-- then please rename your version and all its -->
57
+ <!-- modules to avoid any confusion with the -->
58
+ <!-- original suite. Also, please include the -->
59
+ <!-- following statement as a comment in all your -->
60
+ <!-- DTD modules: -->
61
+ <!-- "Based in part on, but not fully compatible -->
62
+ <!-- with, the Archiving and Interchange DTD -->
63
+ <!-- Suite." -->
64
+ <!-- -->
65
+ <!-- Suggestions for refinements and enhancements to -->
66
+ <!-- the DTD suite should be sent in email to: -->
67
+ <!-- archive-dtd@ncbi.nlm.nih.gov -->
68
+ <!-- -->
69
+ <!-- ORIGINAL CREATION DATE: -->
70
+ <!-- December 2002 -->
71
+ <!-- -->
72
+ <!-- CREATED BY: Jeff Beck (NCBI) -->
73
+ <!-- Deborah Lapeyre (Mulberry Technologies, Inc.) -->
74
+ <!-- Bruce Rosenblum (Inera Inc.) -->
75
+ <!-- -->
76
+ <!-- NLM thanks the Harvard University Libraries, both -->
77
+ <!-- for proposing that a draft archiving NLM DTD for -->
78
+ <!-- life sciences journals be extended to accommodate -->
79
+ <!-- journals in all disciplines and for sponsoring -->
80
+ <!-- Bruce Rosenblum's collaboration with other DTD -->
81
+ <!-- authors in completing Version 1.0. The Andrew W. -->
82
+ <!-- Mellon Foundation provided support for these -->
83
+ <!-- important contributions. -->
84
+ <!-- -->
85
+ <!-- ============================================================= -->
86
+
87
+
88
+ <!-- ============================================================= -->
89
+ <!-- DTD VERSION/CHANGE HISTORY -->
90
+ <!-- ============================================================= -->
91
+ <!--
92
+ =============================================================
93
+
94
+ Version Reason/Occasion (who) vx.x (yyyy-mm-dd)
95
+
96
+ Major requirement changes led to the new release, producing
97
+ DTD version "2.0":
98
+ a) The splitting of the Archival and Interchange Tag Set
99
+ DTDs into three DTDs from two: an authoring DTD, an
100
+ archive regularization and interchange DTD (the
101
+ current Blue Publishing DTD), and a preservationist
102
+ archive DTD (the current Green Archiving and Interchange
103
+ DTD).
104
+ b) AIT Working Group suggestions from the June 04 meeting
105
+ and June/July 2004 followup discussions
106
+ c) Suite remodularization to meet new (and newly articulated)
107
+ modularization requirements
108
+ d) New or renamed classes and mixes to make modifications
109
+ easier and more consistent
110
+
111
+ 1. Updated public identifier to "v2.0 20040830"
112
+ -->
113
+
114
+
115
+ <!-- ============================================================= -->
116
+ <!-- ISO STANDARD SPECIAL CHARACTER SETS DEFINED-->
117
+ <!-- ============================================================= -->
118
+
119
+
120
+ <!-- ISO STANDARD ADDED LATIN 1 -->
121
+ <!ENTITY % ISOlat1 PUBLIC
122
+ "-//W3C//ENTITIES Added Latin 1 for MathML 2.0//EN"
123
+ "xmlchars/isolat1.ent" >
124
+
125
+
126
+ <!-- ISO STANDARD ADDED LATIN 2 -->
127
+ <!ENTITY % ISOlat2 PUBLIC
128
+ "-//W3C//ENTITIES Added Latin 2 for MathML 2.0//EN"
129
+ "xmlchars/isolat2.ent" >
130
+
131
+
132
+ <!-- ISO BOX AND LINE DRAWING -->
133
+ <!ENTITY % ISObox PUBLIC
134
+ "-//W3C//ENTITIES Box and Line Drawing for MathML 2.0//EN"
135
+ "xmlchars/isobox.ent" >
136
+
137
+
138
+ <!-- ISO STANDARD DIACRITICAL MARKS -->
139
+ <!ENTITY % ISOdia PUBLIC
140
+ "-//W3C//ENTITIES Diacritical Marks for MathML 2.0//EN"
141
+ "xmlchars/isodia.ent" >
142
+
143
+
144
+ <!-- ISO STANDARD NUMERIC AND SPECIAL GRAPHIC -->
145
+ <!ENTITY % ISOnum PUBLIC
146
+ "-//W3C//ENTITIES Numeric and Special Graphic for MathML 2.0//EN"
147
+ "xmlchars/isonum.ent" >
148
+
149
+
150
+ <!-- ISO STANDARD PUBLISHING -->
151
+ <!ENTITY % ISOpub PUBLIC
152
+ "-//W3C//ENTITIES Publishing for MathML 2.0//EN"
153
+ "xmlchars/isopub.ent" >
154
+
155
+
156
+ <!-- ISO STANDARD GENERAL TECHNICAL -->
157
+ <!ENTITY % ISOtech PUBLIC
158
+ "-//W3C//ENTITIES General Technical for MathML 2.0//EN"
159
+ "xmlchars/isotech.ent" >
160
+
161
+
162
+ <!-- ISO STANDARD GREEK LETTERS -->
163
+ <!ENTITY % ISOgrk1 PUBLIC
164
+ "-//W3C//ENTITIES Greek Letters//EN"
165
+ "xmlchars/isogrk1.ent" >
166
+
167
+
168
+ <!-- ISO STANDARD MONOTONIKO GREEK -->
169
+ <!ENTITY % ISOgrk2 PUBLIC
170
+ "-//W3C//ENTITIES Monotoniko Greek//EN"
171
+ "xmlchars/isogrk2.ent" >
172
+
173
+
174
+ <!-- ISO STANDARD GREEK SYMBOLS -->
175
+ <!ENTITY % ISOgrk3 PUBLIC
176
+ "-//W3C//ENTITIES Greek Symbols for MathML 2.0//EN"
177
+ "xmlchars/isogrk3.ent" >
178
+
179
+
180
+ <!-- ISO STANDARD ALTERNATIVE GREEK SYMBOLS -->
181
+ <!ENTITY % ISOgrk4 PUBLIC
182
+ "-//W3C//ENTITIES Alternative Greek Symbols//EN"
183
+ "xmlchars/isogrk4.ent" >
184
+
185
+
186
+ <!-- ISO STANDARD RUSSIAN CYRILLIC -->
187
+ <!ENTITY % ISOcyr1 PUBLIC
188
+ "-//W3C//ENTITIES Russian Cyrillic for MathML 2.0//EN"
189
+ "xmlchars/isocyr1.ent" >
190
+
191
+
192
+ <!-- ISO STANDARD NON-RUSSIAN CYRILLIC -->
193
+ <!ENTITY % ISOcyr2 PUBLIC
194
+ "-//W3C//ENTITIES Non-Russian Cyrillic for MathML 2.0//EN"
195
+ "xmlchars/isocyr2.ent" >
196
+
197
+
198
+ <!-- ISO STANDARD MATH ALPHABETS (SCRIPT) -->
199
+ <!ENTITY % ISOmscr PUBLIC
200
+ "-//W3C//ENTITIES Math Alphabets: Script for MathML 2.0//EN"
201
+ "xmlchars/isomscr.ent" >
202
+
203
+
204
+ <!-- ISO STANDARD ADDED MATH SYMBOLS
205
+ (ARROW RELATIONS) -->
206
+ <!ENTITY % ISOamsa PUBLIC
207
+ "-//W3C//ENTITIES Added Math Symbols: Arrow Relations for MathML 2.0//EN"
208
+ "xmlchars/isoamsa.ent" >
209
+
210
+
211
+ <!-- ISO STANDARD ADDED MATH SYMBOLS
212
+ (BINARY OPERATORS) -->
213
+ <!ENTITY % ISOamsb PUBLIC
214
+ "-//W3C//ENTITIES Added Math Symbols: Binary Operators for MathML 2.0//EN"
215
+ "xmlchars/isoamsb.ent" >
216
+
217
+
218
+ <!-- ISO STANDARD ADDED MATH SYMBOLS
219
+ (DELIMITERS) -->
220
+ <!ENTITY % ISOamsc PUBLIC
221
+ "-//W3C//ENTITIES Added Math Symbols: Delimiters for MathML 2.0//EN"
222
+ "xmlchars/isoamsc.ent" >
223
+
224
+
225
+ <!-- ISO STANDARD ADDED MATH SYMBOLS
226
+ (NEGATED RELATIONS) -->
227
+ <!ENTITY % ISOamsn PUBLIC
228
+ "-//W3C//ENTITIES Added Math Symbols: Negated Relations for MathML 2.0//EN"
229
+ "xmlchars/isoamsn.ent" >
230
+
231
+
232
+ <!-- ISO STANDARD ADDED MATH SYMBOLS (ORDINARY) -->
233
+ <!ENTITY % ISOamso PUBLIC
234
+ "-//W3C//ENTITIES Added Math Symbols: Ordinary for MathML 2.0//EN"
235
+ "xmlchars/isoamso.ent" >
236
+
237
+
238
+ <!-- ISO STANDARD ADDED MATH SYMBOLS
239
+ (RELATIONS) -->
240
+ <!ENTITY % ISOamsr PUBLIC
241
+ "-//W3C//ENTITIES Added Math Symbols: Relations for MathML 2.0//EN"
242
+ "xmlchars/isoamsr.ent" >
243
+
244
+
245
+ <!-- ISO STANDARD MATH ALPHABETS (FRAKTUR) -->
246
+ <!ENTITY % ISOmfrk PUBLIC
247
+ "-//W3C//ENTITIES Math Alphabets: Fraktur for MathML 2.0//EN"
248
+ "xmlchars/isomfrk.ent" >
249
+
250
+
251
+ <!-- ISO STANDARD MATH ALPHABETS (OPEN FACE) -->
252
+ <!ENTITY % ISOmopf PUBLIC
253
+ "-//W3C//ENTITIES Math Alphabets: Open Face for MathML 2.0//EN"
254
+ "xmlchars/isomopf.ent" >
255
+
256
+
257
+ <!-- ============================================================= -->
258
+ <!-- ISO SPECIAL CHARACTER SETS INVOKED -->
259
+ <!-- ============================================================= -->
260
+
261
+
262
+ %ISOlat1;
263
+ %ISOlat2;
264
+ %ISObox;
265
+ %ISOdia;
266
+ %ISOnum;
267
+ %ISOpub;
268
+ %ISOtech;
269
+ %ISOgrk1;
270
+ %ISOgrk2;
271
+ %ISOgrk3;
272
+ %ISOgrk4;
273
+ %ISOcyr1;
274
+ %ISOcyr2;
275
+ %ISOamsa;
276
+ %ISOamsb;
277
+ %ISOamsc;
278
+ %ISOamsn;
279
+ %ISOamso;
280
+ %ISOamsr;
281
+ %ISOmscr;
282
+ %ISOmfrk;
283
+ %ISOmopf;
284
+
285
+
286
+ <!-- Custom special characters are declared
287
+ in a separate module %chars.ent; -->
288
+
289
+
290
+ <!-- ============ End of XML Special Characters Module =========== -->
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/Parser.py ADDED
@@ -0,0 +1,1165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2008-2014 by Michiel de Hoon. All rights reserved.
2
+ # Revisions copyright 2008-2015 by Peter Cock. All rights reserved.
3
+ #
4
+ # This file is part of the Biopython distribution and governed by your
5
+ # choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
6
+ # Please see the LICENSE file that should have been included as part of this
7
+ # package.
8
+
9
+ """Parser for XML results returned by NCBI's Entrez Utilities.
10
+
11
+ This parser is used by the read() function in Bio.Entrez, and is not
12
+ intended be used directly.
13
+
14
+ The question is how to represent an XML file as Python objects. Some
15
+ XML files returned by NCBI look like lists, others look like dictionaries,
16
+ and others look like a mix of lists and dictionaries.
17
+
18
+ My approach is to classify each possible element in the XML as a plain
19
+ string, an integer, a list, a dictionary, or a structure. The latter is a
20
+ dictionary where the same key can occur multiple times; in Python, it is
21
+ represented as a dictionary where that key occurs once, pointing to a list
22
+ of values found in the XML file.
23
+
24
+ The parser then goes through the XML and creates the appropriate Python
25
+ object for each element. The different levels encountered in the XML are
26
+ preserved on the Python side. So a subelement of a subelement of an element
27
+ is a value in a dictionary that is stored in a list which is a value in
28
+ some other dictionary (or a value in a list which itself belongs to a list
29
+ which is a value in a dictionary, and so on). Attributes encountered in
30
+ the XML are stored as a dictionary in a member .attributes of each element,
31
+ and the tag name is saved in a member .tag.
32
+
33
+ To decide which kind of Python object corresponds to each element in the
34
+ XML, the parser analyzes the DTD referred at the top of (almost) every
35
+ XML file returned by the Entrez Utilities. This is preferred over a hand-
36
+ written solution, since the number of DTDs is rather large and their
37
+ contents may change over time. About half the code in this parser deals
38
+ with parsing the DTD, and the other half with the XML itself.
39
+ """
40
+
41
+ import os
42
+ import warnings
43
+ import xml.etree.ElementTree as ET
44
+ from collections import Counter
45
+ from io import BytesIO
46
+ from urllib.parse import urlparse
47
+ from urllib.request import urlopen
48
+ from xml.parsers import expat
49
+ from xml.sax.saxutils import escape
50
+
51
+ from Bio import StreamModeError
52
+
53
+ # The following four classes are used to add a member .attributes to integers,
54
+ # strings, lists, and dictionaries, respectively.
55
+
56
+
57
+ class NoneElement:
58
+ """NCBI Entrez XML element mapped to None."""
59
+
60
+ def __init__(self, tag, attributes, key):
61
+ """Create a NoneElement."""
62
+ self.tag = tag
63
+ self.key = key
64
+ self.attributes = attributes
65
+
66
+ def __repr__(self):
67
+ """Return a string representation of the object."""
68
+ try:
69
+ attributes = self.attributes
70
+ except AttributeError:
71
+ return "NoneElement"
72
+ return "NoneElement(attributes=%r)" % attributes
73
+
74
+ def __eq__(self, other):
75
+ if isinstance(other, NoneElement):
76
+ return True
77
+ return False
78
+
79
+
80
+ class IntegerElement(int):
81
+ """NCBI Entrez XML element mapped to an integer."""
82
+
83
+ def __new__(cls, value, *args, **kwargs):
84
+ """Create an IntegerElement."""
85
+ return int.__new__(cls, value)
86
+
87
+ def __init__(self, value, tag, attributes, key):
88
+ """Initialize an IntegerElement."""
89
+ self.tag = tag
90
+ self.attributes = attributes
91
+ self.key = key
92
+
93
+ def __repr__(self):
94
+ """Return a string representation of the object."""
95
+ text = int.__repr__(self)
96
+ try:
97
+ attributes = self.attributes
98
+ except AttributeError:
99
+ return text
100
+ return f"IntegerElement({text}, attributes={attributes!r})"
101
+
102
+
103
+ class StringElement(str):
104
+ """NCBI Entrez XML element mapped to a string."""
105
+
106
+ def __new__(cls, value, *args, **kwargs):
107
+ """Create a StringElement."""
108
+ return str.__new__(cls, value)
109
+
110
+ def __init__(self, value, tag, attributes, key):
111
+ """Initialize a StringElement."""
112
+ self.tag = tag
113
+ self.attributes = attributes
114
+ self.key = key
115
+
116
+ def __repr__(self):
117
+ """Return a string representation of the object."""
118
+ text = str.__repr__(self)
119
+ attributes = self.attributes
120
+ if not attributes:
121
+ return text
122
+ return f"StringElement({text}, attributes={attributes!r})"
123
+
124
+
125
+ class ListElement(list):
126
+ """NCBI Entrez XML element mapped to a list."""
127
+
128
+ def __init__(self, tag, attributes, allowed_tags, key=None):
129
+ """Create a ListElement."""
130
+ self.tag = tag
131
+ if key is None:
132
+ self.key = tag
133
+ else:
134
+ self.key = key
135
+ self.attributes = attributes
136
+ self.allowed_tags = allowed_tags
137
+
138
+ def __repr__(self):
139
+ """Return a string representation of the object."""
140
+ text = list.__repr__(self)
141
+ attributes = self.attributes
142
+ if not attributes:
143
+ return text
144
+ return f"ListElement({text}, attributes={attributes!r})"
145
+
146
+ def store(self, value):
147
+ """Append an element to the list, checking tags."""
148
+ key = value.key
149
+ if self.allowed_tags is not None and key not in self.allowed_tags:
150
+ raise ValueError("Unexpected item '%s' in list" % key)
151
+ del value.key
152
+ self.append(value)
153
+
154
+
155
+ class DictionaryElement(dict):
156
+ """NCBI Entrez XML element mapped to a dictionaray."""
157
+
158
+ def __init__(self, tag, attrs, allowed_tags, repeated_tags=None, key=None):
159
+ """Create a DictionaryElement."""
160
+ self.tag = tag
161
+ if key is None:
162
+ self.key = tag
163
+ else:
164
+ self.key = key
165
+ self.attributes = attrs
166
+ self.allowed_tags = allowed_tags
167
+ self.repeated_tags = repeated_tags
168
+ if repeated_tags:
169
+ for key in repeated_tags:
170
+ self[key] = []
171
+
172
+ def __repr__(self):
173
+ """Return a string representation of the object."""
174
+ text = dict.__repr__(self)
175
+ attributes = self.attributes
176
+ if not attributes:
177
+ return text
178
+ return f"DictElement({text}, attributes={attributes!r})"
179
+
180
+ def store(self, value):
181
+ """Add an entry to the dictionary, checking tags."""
182
+ key = value.key
183
+ tag = value.tag
184
+ if self.allowed_tags is not None and tag not in self.allowed_tags:
185
+ raise ValueError("Unexpected item '%s' in dictionary" % key)
186
+ del value.key
187
+ if self.repeated_tags and key in self.repeated_tags:
188
+ self[key].append(value)
189
+ else:
190
+ self[key] = value
191
+
192
+
193
+ class OrderedListElement(list):
194
+ """NCBI Entrez XML element mapped to a list of lists.
195
+
196
+ OrderedListElement is used to describe a list of repeating elements such as
197
+ A, B, C, A, B, C, A, B, C ... where each set of A, B, C forms a group. This
198
+ is then stored as [[A, B, C], [A, B, C], [A, B, C], ...]
199
+ """
200
+
201
+ def __init__(self, tag, attributes, allowed_tags, first_tag, key=None):
202
+ """Create an OrderedListElement."""
203
+ self.tag = tag
204
+ if key is None:
205
+ self.key = tag
206
+ else:
207
+ self.key = key
208
+ self.attributes = attributes
209
+ self.allowed_tags = allowed_tags
210
+ self.first_tag = first_tag
211
+
212
+ def __repr__(self):
213
+ """Return a string representation of the object."""
214
+ text = list.__repr__(self)
215
+ attributes = self.attributes
216
+ if not attributes:
217
+ return text
218
+ return f"OrderedListElement({text}, attributes={attributes!r})"
219
+
220
+ def store(self, value):
221
+ """Append an element to the list, checking tags."""
222
+ key = value.key
223
+ if self.allowed_tags is not None and key not in self.allowed_tags:
224
+ raise ValueError("Unexpected item '%s' in list" % key)
225
+ if key == self.first_tag:
226
+ self.append([])
227
+ self[-1].append(value)
228
+
229
+
230
+ class ErrorElement(str):
231
+ """NCBI Entrez XML element containing an error message."""
232
+
233
+ def __new__(cls, value, *args, **kwargs):
234
+ """Create an ErrorElement."""
235
+ return str.__new__(cls, value)
236
+
237
+ def __init__(self, value, tag):
238
+ """Initialize an ErrorElement."""
239
+ self.tag = tag
240
+ self.key = tag
241
+
242
+ def __repr__(self):
243
+ """Return the error message as a string."""
244
+ text = str.__repr__(self)
245
+ return f"ErrorElement({text})"
246
+
247
+
248
+ class NotXMLError(ValueError):
249
+ """Failed to parse file as XML."""
250
+
251
+ def __init__(self, message):
252
+ """Initialize the class."""
253
+ self.msg = message
254
+
255
+ def __str__(self):
256
+ """Return a string summary of the exception."""
257
+ return (
258
+ "Failed to parse the XML data (%s). Please make sure that the input data "
259
+ "are in XML format." % self.msg
260
+ )
261
+
262
+
263
+ class CorruptedXMLError(ValueError):
264
+ """Corrupted XML."""
265
+
266
+ def __init__(self, message):
267
+ """Initialize the class."""
268
+ self.msg = message
269
+
270
+ def __str__(self):
271
+ """Return a string summary of the exception."""
272
+ return (
273
+ "Failed to parse the XML data (%s). Please make sure that the input data "
274
+ "are not corrupted." % self.msg
275
+ )
276
+
277
+
278
+ class ValidationError(ValueError):
279
+ """XML tag found which was not defined in the DTD.
280
+
281
+ Validating parsers raise this error if the parser finds a tag in the XML
282
+ that is not defined in the DTD. Non-validating parsers do not raise this
283
+ error. The Bio.Entrez.read and Bio.Entrez.parse functions use validating
284
+ parsers by default (see those functions for more information).
285
+ """
286
+
287
+ def __init__(self, name):
288
+ """Initialize the class."""
289
+ self.name = name
290
+
291
+ def __str__(self):
292
+ """Return a string summary of the exception."""
293
+ return (
294
+ "Failed to find tag '%s' in the DTD. To skip all tags that "
295
+ "are not represented in the DTD, please call Bio.Entrez.read "
296
+ "or Bio.Entrez.parse with validate=False." % self.name
297
+ )
298
+
299
+
300
+ class DataHandlerMeta(type):
301
+ """A metaclass is needed until Python supports @classproperty."""
302
+
303
+ def __init__(cls, *args, **kwargs):
304
+ """Initialize the class."""
305
+ from Bio import Entrez
306
+
307
+ try:
308
+ cls.directory = Entrez.local_cache # use default directory for local cache
309
+ except PermissionError:
310
+ cls._directory = Entrez.local_cache # no local cache
311
+ del Entrez
312
+
313
+ @property
314
+ def directory(cls):
315
+ """Directory for caching XSD and DTD files."""
316
+ return cls._directory
317
+
318
+ @directory.setter
319
+ def directory(cls, value):
320
+ """Set a custom directory for the local DTD/XSD directories."""
321
+ if value is None:
322
+ import platform
323
+
324
+ if platform.system() == "Windows":
325
+ value = os.path.join(os.getenv("APPDATA"), "biopython")
326
+ else: # Unix/Linux/Mac
327
+ home = os.path.expanduser("~")
328
+ value = os.path.join(home, ".config", "biopython")
329
+ # Create DTD local directory
330
+ cls.local_dtd_dir = os.path.join(value, "Bio", "Entrez", "DTDs")
331
+ os.makedirs(cls.local_dtd_dir, exist_ok=True)
332
+ # Create XSD local directory
333
+ cls.local_xsd_dir = os.path.join(value, "Bio", "Entrez", "XSDs")
334
+ os.makedirs(cls.local_xsd_dir, exist_ok=True)
335
+ # Save the directory name after creating the DTD and XSD local
336
+ # directories to ensure there was no PermissionError.
337
+ cls._directory = value
338
+
339
+
340
+ class DataHandler(metaclass=DataHandlerMeta):
341
+ """Data handler for parsing NCBI XML from Entrez."""
342
+
343
+ from Bio import Entrez
344
+
345
+ global_dtd_dir = os.path.join(Entrez.__path__[0], "DTDs")
346
+ global_xsd_dir = os.path.join(Entrez.__path__[0], "XSDs")
347
+ local_dtd_dir = None
348
+ local_xsd_dir = None
349
+
350
+ del Entrez
351
+
352
+ def __init__(self, validate, escape, ignore_errors):
353
+ """Create a DataHandler object."""
354
+ self.dtd_urls = []
355
+ self.element = None
356
+ self.level = 0
357
+ self.bypass_url_security = False
358
+ self.data = []
359
+ self.attributes = None
360
+ self.allowed_tags = None
361
+ self.constructors = {}
362
+ self.strings = {}
363
+ self.items = set()
364
+ self.errors = set()
365
+ self.validating = validate
366
+ self.ignore_errors = ignore_errors
367
+ self.parser = expat.ParserCreate(namespace_separator=" ")
368
+ self.parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_ALWAYS)
369
+ self.parser.XmlDeclHandler = self.xmlDeclHandler
370
+ self.schema_namespace = None
371
+ self.namespace_level = Counter()
372
+ self.namespace_prefix = {}
373
+ if escape:
374
+ self.characterDataHandler = self.characterDataHandlerEscape
375
+ else:
376
+ self.characterDataHandler = self.characterDataHandlerRaw
377
+
378
+ def read(self, source):
379
+ """Set up the parser and let it read the XML results."""
380
+ # Expat's parser.ParseFile function only accepts binary data;
381
+ # see also the comment below for Entrez.parse.
382
+ try:
383
+ stream = open(source, "rb")
384
+ except TypeError: # not a path, assume we received a stream
385
+ if source.read(0) != b"":
386
+ raise StreamModeError(
387
+ "the XML file must be opened in binary mode."
388
+ ) from None
389
+ stream = source
390
+ if stream.read(0) != b"":
391
+ raise TypeError("file should be opened in binary mode")
392
+ try:
393
+ self.parser.ParseFile(stream)
394
+ except expat.ExpatError as e:
395
+ if self.parser.StartElementHandler:
396
+ # We saw the initial <!xml declaration, so we can be sure that
397
+ # we are parsing XML data. Most likely, the XML file is
398
+ # corrupted.
399
+ raise CorruptedXMLError(e) from None
400
+ else:
401
+ # We have not seen the initial <!xml declaration, so probably
402
+ # the input data is not in XML format.
403
+ raise NotXMLError(e) from None
404
+ finally:
405
+ if stream is not source:
406
+ stream.close()
407
+ try:
408
+ record = self.record
409
+ except AttributeError:
410
+ if self.parser.StartElementHandler:
411
+ # We saw the initial <!xml declaration, and expat didn't notice
412
+ # any errors, so self.record should be defined. If not, this is
413
+ # a bug.
414
+ raise RuntimeError(
415
+ "Failed to parse the XML file correctly, possibly due to a bug "
416
+ "in Bio.Entrez. Please contact the Biopython developers via "
417
+ "the mailing list or GitHub for assistance."
418
+ ) from None
419
+ else:
420
+ # We did not see the initial <!xml declaration, so probably
421
+ # the input data is not in XML format.
422
+ raise NotXMLError("XML declaration not found") from None
423
+ else:
424
+ del record.key
425
+ return record
426
+
427
+ def parse(self, source):
428
+ """Set up the parser and let it read the XML results."""
429
+ # The source must be a filename, or a file-like object opened in binary
430
+ # mode. Data read from the file or file-like object as bytes. Expat will
431
+ # pick up the encoding from the XML declaration (or assume UTF-8 if it
432
+ # is missing), and use this encoding to convert the binary data to a
433
+ # string before giving it to characterDataHandler.
434
+ # While parser.ParseFile only accepts binary data, parser.Parse accepts
435
+ # both binary data and strings. However, a file in text mode may have
436
+ # been opened with an encoding different from the encoding specified in
437
+ # the XML declaration at the top of the file. If so, the data in the
438
+ # file will have been decoded with an incorrect encoding. To avoid
439
+ # this, and to be consistent with parser.ParseFile (which is used in
440
+ # the Entrez.read function above), we require the source data to be in
441
+ # binary mode here as well.
442
+ try:
443
+ stream = open(source, "rb")
444
+ except TypeError: # not a path, assume we received a stream
445
+ if source.read(0) != b"":
446
+ raise StreamModeError(
447
+ "the XML file must be opened in binary mode."
448
+ ) from None
449
+ stream = source
450
+ if stream.read(0) != b"":
451
+ raise TypeError("file should be opened in binary mode")
452
+ BLOCK = 1024
453
+ try:
454
+ while True:
455
+ # Read in another block of data from the file.
456
+ data = stream.read(BLOCK)
457
+ self.parser.Parse(data, False)
458
+ try:
459
+ records = self.record
460
+ except AttributeError:
461
+ if self.parser.StartElementHandler:
462
+ # We saw the initial <!xml declaration, and expat
463
+ # didn't notice any errors, so self.record should be
464
+ # defined. If not, this is a bug.
465
+
466
+ raise RuntimeError(
467
+ "Failed to parse the XML file correctly, possibly due to a "
468
+ "bug in Bio.Entrez. Please contact the Biopython "
469
+ "developers via the mailing list or GitHub for assistance."
470
+ ) from None
471
+ else:
472
+ # We did not see the initial <!xml declaration, so
473
+ # probably the input data is not in XML format.
474
+ raise NotXMLError("XML declaration not found") from None
475
+
476
+ if not isinstance(records, list):
477
+ raise ValueError(
478
+ "The XML file does not represent a list. Please use "
479
+ "Entrez.read instead of Entrez.parse."
480
+ )
481
+
482
+ if not data:
483
+ break
484
+
485
+ while len(records) >= 2:
486
+ # Then the first record is finished, while the second record
487
+ # is still a work in progress.
488
+ record = records.pop(0)
489
+ yield record
490
+
491
+ except expat.ExpatError as e:
492
+ if self.parser.StartElementHandler:
493
+ # We saw the initial <!xml declaration, so we can be sure
494
+ # that we are parsing XML data. Most likely, the XML file
495
+ # is corrupted.
496
+ raise CorruptedXMLError(e) from None
497
+ else:
498
+ # We have not seen the initial <!xml declaration, so
499
+ # probably the input data is not in XML format.
500
+ raise NotXMLError(e) from None
501
+ finally:
502
+ if stream is not source:
503
+ stream.close()
504
+
505
+ # We have reached the end of the XML file
506
+ self.parser = None
507
+ if self.element is not None:
508
+ # No more XML data, but there is still some unfinished business
509
+ raise CorruptedXMLError("Premature end of data")
510
+
511
+ # Send out the remaining records
512
+ yield from records
513
+
514
+ def xmlDeclHandler(self, version, encoding, standalone):
515
+ """Set XML handlers when an XML declaration is found."""
516
+ self.parser.CharacterDataHandler = self.characterDataHandler
517
+ self.parser.ExternalEntityRefHandler = self.externalEntityRefHandler
518
+ self.parser.StartNamespaceDeclHandler = self.startNamespaceDeclHandler
519
+ self.parser.EndNamespaceDeclHandler = self.endNamespaceDeclHandler
520
+ self.parser.StartElementHandler = self.handleMissingDocumentDefinition
521
+
522
+ def handleMissingDocumentDefinition(self, tag, attrs):
523
+ """Raise an Exception if neither a DTD nor an XML Schema is found."""
524
+ raise ValueError(
525
+ "As the XML data contained neither a Document Type Definition (DTD) nor an XML Schema, Bio.Entrez is unable to parse these data. We recommend using a generic XML parser from the Python standard library instead, for example ElementTree."
526
+ )
527
+
528
+ def startNamespaceDeclHandler(self, prefix, uri):
529
+ """Handle start of an XML namespace declaration."""
530
+ if prefix == "xsi":
531
+ # This is an xml schema
532
+ self.schema_namespace = uri
533
+ self.parser.StartElementHandler = self.schemaHandler
534
+ else:
535
+ # Note that the DTD for MathML specifies a default attribute
536
+ # that declares the namespace for each MathML element. This means
537
+ # that MathML element in the XML has an invisible MathML namespace
538
+ # declaration that triggers a call to startNamespaceDeclHandler
539
+ # and endNamespaceDeclHandler. Therefore we need to count how often
540
+ # startNamespaceDeclHandler and endNamespaceDeclHandler were called
541
+ # to find out their first and last invocation for each namespace.
542
+ if prefix == "mml":
543
+ assert uri == "http://www.w3.org/1998/Math/MathML"
544
+ elif prefix == "xlink":
545
+ assert uri == "http://www.w3.org/1999/xlink"
546
+ elif prefix == "ali":
547
+ assert uri.rstrip("/") == "http://www.niso.org/schemas/ali/1.0"
548
+ else:
549
+ raise ValueError(f"Unknown prefix '{prefix}' with uri '{uri}'")
550
+ self.namespace_level[prefix] += 1
551
+ self.namespace_prefix[uri] = prefix
552
+
553
+ def endNamespaceDeclHandler(self, prefix):
554
+ """Handle end of an XML namespace declaration."""
555
+ if prefix != "xsi":
556
+ self.namespace_level[prefix] -= 1
557
+ if self.namespace_level[prefix] == 0:
558
+ for key, value in self.namespace_prefix.items():
559
+ if value == prefix:
560
+ break
561
+ else:
562
+ raise RuntimeError("Failed to find namespace prefix")
563
+ del self.namespace_prefix[key]
564
+
565
+ def schemaHandler(self, name, attrs):
566
+ """Process the XML schema (before processing the element)."""
567
+ key = "%s noNamespaceSchemaLocation" % self.schema_namespace
568
+ schema = attrs[key]
569
+ self.verify_security(schema)
570
+ handle = self.open_xsd_file(os.path.basename(schema))
571
+ # if there is no local xsd file grab the url and parse the file
572
+ if not handle:
573
+ handle = urlopen(schema)
574
+ text = handle.read()
575
+ self.save_xsd_file(os.path.basename(schema), text)
576
+ handle.close()
577
+ self.parse_xsd(ET.fromstring(text))
578
+ else:
579
+ self.parse_xsd(ET.fromstring(handle.read()))
580
+ handle.close()
581
+ # continue handling the element
582
+ self.startElementHandler(name, attrs)
583
+ # reset the element handler
584
+ self.parser.StartElementHandler = self.startElementHandler
585
+
586
+ def startElementHandler(self, tag, attrs):
587
+ """Handle start of an XML element."""
588
+ prefix = None
589
+ if self.namespace_prefix:
590
+ try:
591
+ uri, name = tag.split()
592
+ except ValueError:
593
+ pass
594
+ else:
595
+ prefix = self.namespace_prefix[uri]
596
+ tag = f"{prefix}:{name}"
597
+ if tag in self.items:
598
+ assert tag == "Item"
599
+ name = attrs["Name"]
600
+ itemtype = attrs["Type"]
601
+ del attrs["Type"]
602
+ if itemtype == "Structure":
603
+ del attrs["Name"]
604
+ element = DictionaryElement(
605
+ name, attrs, allowed_tags=None, repeated_tags=None
606
+ )
607
+ parent = self.element
608
+ element.parent = parent
609
+ # For consistency with lists below, store the element here
610
+ if parent is None:
611
+ self.record = element
612
+ else:
613
+ parent.store(element)
614
+ self.element = element
615
+ self.parser.EndElementHandler = self.endElementHandler
616
+ self.parser.CharacterDataHandler = self.skipCharacterDataHandler
617
+ elif name in ("ArticleIds", "History"):
618
+ del attrs["Name"]
619
+ allowed_tags = None # allowed tags are unknown
620
+ repeated_tags = frozenset(["pubmed", "medline"])
621
+ element = DictionaryElement(
622
+ tag,
623
+ attrs,
624
+ allowed_tags=allowed_tags,
625
+ repeated_tags=repeated_tags,
626
+ key=name,
627
+ )
628
+ parent = self.element
629
+ element.parent = parent
630
+ # For consistency with lists below, store the element here
631
+ if parent is None:
632
+ self.record = element
633
+ else:
634
+ parent.store(element)
635
+ self.element = element
636
+ self.parser.EndElementHandler = self.endElementHandler
637
+ self.parser.CharacterDataHandler = self.skipCharacterDataHandler
638
+ elif itemtype == "List":
639
+ del attrs["Name"]
640
+ allowed_tags = None # allowed tags are unknown
641
+ element = ListElement(tag, attrs, allowed_tags, name)
642
+ parent = self.element
643
+ element.parent = parent
644
+ if self.element is None:
645
+ # Set self.record here to let Entrez.parse iterate over it
646
+ self.record = element
647
+ else:
648
+ parent.store(element)
649
+ self.element = element
650
+ self.parser.EndElementHandler = self.endElementHandler
651
+ self.parser.CharacterDataHandler = self.skipCharacterDataHandler
652
+ elif itemtype == "Integer":
653
+ self.parser.EndElementHandler = self.endIntegerElementHandler
654
+ self.parser.CharacterDataHandler = self.characterDataHandler
655
+ self.attributes = attrs
656
+ elif itemtype in ("String", "Unknown", "Date", "Enumerator"):
657
+ assert self.attributes is None
658
+ self.attributes = attrs
659
+ self.parser.StartElementHandler = self.startRawElementHandler
660
+ self.parser.EndElementHandler = self.endStringElementHandler
661
+ self.parser.CharacterDataHandler = self.characterDataHandler
662
+ else:
663
+ raise ValueError("Unknown item type %s" % name)
664
+ elif tag in self.errors:
665
+ self.parser.EndElementHandler = self.endErrorElementHandler
666
+ self.parser.CharacterDataHandler = self.characterDataHandler
667
+ elif tag in self.strings:
668
+ self.parser.StartElementHandler = self.startRawElementHandler
669
+ self.parser.EndElementHandler = self.endStringElementHandler
670
+ self.parser.CharacterDataHandler = self.characterDataHandler
671
+ assert self.allowed_tags is None
672
+ self.allowed_tags = self.strings[tag]
673
+ assert self.attributes is None
674
+ self.attributes = attrs
675
+ elif tag in self.constructors:
676
+ cls, allowed_tags = self.constructors[tag]
677
+ element = cls(tag, attrs, *allowed_tags)
678
+ parent = self.element
679
+ element.parent = parent
680
+ if parent is None:
681
+ # Set self.record here to let Entrez.parse iterate over it
682
+ self.record = element
683
+ else:
684
+ parent.store(element)
685
+ self.element = element
686
+ self.parser.EndElementHandler = self.endElementHandler
687
+ self.parser.CharacterDataHandler = self.skipCharacterDataHandler
688
+ else:
689
+ # Element not found in DTD
690
+ if tag == "processing-meta":
691
+ terms = []
692
+ dtd_version = "1.3"
693
+ if attrs["tagset-family"] == "jats":
694
+ terms.append("JATS")
695
+ if attrs["base-tagset"] == "archiving":
696
+ term = "archivearticle" + dtd_version.replace(".", "-")
697
+ terms.append(term)
698
+ if attrs.get("mathml-version") == "3.0":
699
+ terms.append("mathml3")
700
+ basename = "-".join(terms)
701
+ url = f"https://{attrs['tagset-family']}.nlm.nih.gov/{attrs['base-tagset']}/{dtd_version}/{basename}.dtd"
702
+ self.xmlDeclHandler(None, None, None)
703
+ self.externalEntityRefHandler(None, None, url, None)
704
+ # remainder will be ignored and will not be stored in the record
705
+ elif self.validating:
706
+ raise ValidationError(tag)
707
+ # this will not be stored in the record
708
+ self.parser.StartElementHandler = self.startSkipElementHandler
709
+ self.parser.EndElementHandler = self.endSkipElementHandler
710
+ self.parser.CharacterDataHandler = self.skipCharacterDataHandler
711
+ self.level = 1
712
+
713
+ def startRawElementHandler(self, name, attrs):
714
+ """Handle start of an XML raw element."""
715
+ # check if the name is in a namespace
716
+ prefix = None
717
+ if self.namespace_prefix:
718
+ try:
719
+ uri, name = name.split()
720
+ except ValueError:
721
+ pass
722
+ else:
723
+ prefix = self.namespace_prefix[uri]
724
+ if self.namespace_level[prefix] == 1:
725
+ attrs = {"xmlns": uri}
726
+ if prefix:
727
+ key = f"{prefix}:{name}"
728
+ else:
729
+ key = name
730
+ # self.allowed_tags is ignored for now. Anyway we know what to do
731
+ # with this tag.
732
+ tag = "<%s" % name
733
+ for key, value in attrs.items():
734
+ tag += f' {key}="{value}"'
735
+ tag += ">"
736
+ self.data.append(tag)
737
+ self.parser.EndElementHandler = self.endRawElementHandler
738
+ self.level += 1
739
+
740
+ def startSkipElementHandler(self, name, attrs):
741
+ """Handle start of an XML skip element."""
742
+ self.level += 1
743
+
744
+ def endStringElementHandler(self, tag):
745
+ """Handle end of an XML string element."""
746
+ element = self.element
747
+ if element is not None:
748
+ self.parser.StartElementHandler = self.startElementHandler
749
+ self.parser.EndElementHandler = self.endElementHandler
750
+ self.parser.CharacterDataHandler = self.skipCharacterDataHandler
751
+ data = "".join(self.data)
752
+ self.data = []
753
+ attributes = self.attributes
754
+ self.attributes = None
755
+ if self.namespace_prefix:
756
+ try:
757
+ uri, name = tag.split()
758
+ except ValueError:
759
+ pass
760
+ else:
761
+ prefix = self.namespace_prefix[uri]
762
+ tag = f"{prefix}:{name}"
763
+ if tag in self.items:
764
+ assert tag == "Item"
765
+ key = attributes["Name"]
766
+ del attributes["Name"]
767
+ else:
768
+ key = tag
769
+ value = StringElement(data, tag, attributes, key)
770
+ if element is None:
771
+ self.record = element
772
+ else:
773
+ element.store(value)
774
+ self.allowed_tags = None
775
+
776
+ def endRawElementHandler(self, name):
777
+ """Handle end of an XML raw element."""
778
+ self.level -= 1
779
+ if self.level == 0:
780
+ self.parser.EndElementHandler = self.endStringElementHandler
781
+ if self.namespace_prefix:
782
+ try:
783
+ uri, name = name.split()
784
+ except ValueError:
785
+ pass
786
+ tag = "</%s>" % name
787
+ self.data.append(tag)
788
+
789
+ def endSkipElementHandler(self, name):
790
+ """Handle end of an XML skip element."""
791
+ self.level -= 1
792
+ if self.level == 0:
793
+ self.parser.StartElementHandler = self.startElementHandler
794
+ self.parser.EndElementHandler = self.endElementHandler
795
+
796
+ def endErrorElementHandler(self, tag):
797
+ """Handle end of an XML error element."""
798
+ element = self.element
799
+ if element is not None:
800
+ self.parser.StartElementHandler = self.startElementHandler
801
+ self.parser.EndElementHandler = self.endElementHandler
802
+ self.parser.CharacterDataHandler = self.skipCharacterDataHandler
803
+ data = "".join(self.data)
804
+ if data == "":
805
+ return
806
+ if self.ignore_errors is False:
807
+ raise RuntimeError(data)
808
+ self.data = []
809
+ value = ErrorElement(data, tag)
810
+ if element is None:
811
+ self.record = element
812
+ else:
813
+ element.store(value)
814
+
815
+ def endElementHandler(self, name):
816
+ """Handle end of an XML element."""
817
+ element = self.element
818
+ self.element = element.parent
819
+ del element.parent
820
+
821
+ def endIntegerElementHandler(self, tag):
822
+ """Handle end of an XML integer element."""
823
+ attributes = self.attributes
824
+ self.attributes = None
825
+ assert tag == "Item"
826
+ key = attributes["Name"]
827
+ del attributes["Name"]
828
+ if self.data:
829
+ value = int("".join(self.data))
830
+ self.data = []
831
+ value = IntegerElement(value, tag, attributes, key)
832
+ else:
833
+ value = NoneElement(tag, attributes, key)
834
+ element = self.element
835
+ if element is None:
836
+ self.record = value
837
+ else:
838
+ self.parser.EndElementHandler = self.endElementHandler
839
+ self.parser.CharacterDataHandler = self.skipCharacterDataHandler
840
+ if value is None:
841
+ return
842
+ element.store(value)
843
+
844
+ def characterDataHandlerRaw(self, content):
845
+ """Handle character data as-is (raw)."""
846
+ self.data.append(content)
847
+
848
+ def characterDataHandlerEscape(self, content):
849
+ """Handle character data by encoding it."""
850
+ content = escape(content)
851
+ self.data.append(content)
852
+
853
+ def skipCharacterDataHandler(self, content):
854
+ """Handle character data by skipping it."""
855
+
856
+ def parse_xsd(self, root):
857
+ """Parse an XSD file."""
858
+ prefix = "{http://www.w3.org/2001/XMLSchema}"
859
+ for element in root:
860
+ isSimpleContent = False
861
+ attribute_keys = []
862
+ keys = []
863
+ multiple = []
864
+ assert element.tag == prefix + "element"
865
+ name = element.attrib["name"]
866
+ assert len(element) == 1
867
+ complexType = element[0]
868
+ assert complexType.tag == prefix + "complexType"
869
+ for component in complexType:
870
+ tag = component.tag
871
+ if tag == prefix + "attribute":
872
+ # we could distinguish by type; keeping string for now
873
+ attribute_keys.append(component.attrib["name"])
874
+ elif tag == prefix + "sequence":
875
+ maxOccurs = component.attrib.get("maxOccurs", "1")
876
+ for key in component:
877
+ assert key.tag == prefix + "element"
878
+ ref = key.attrib["ref"]
879
+ keys.append(ref)
880
+ if maxOccurs != "1" or key.attrib.get("maxOccurs", "1") != "1":
881
+ multiple.append(ref)
882
+ elif tag == prefix + "simpleContent":
883
+ assert len(component) == 1
884
+ extension = component[0]
885
+ assert extension.tag == prefix + "extension"
886
+ assert extension.attrib["base"] == "xs:string"
887
+ for attribute in extension:
888
+ assert attribute.tag == prefix + "attribute"
889
+ # we could distinguish by type; keeping string for now
890
+ attribute_keys.append(attribute.attrib["name"])
891
+ isSimpleContent = True
892
+ allowed_tags = frozenset(keys)
893
+ if len(keys) == 1 and keys == multiple:
894
+ assert not isSimpleContent
895
+ args = (allowed_tags,)
896
+ self.constructors[name] = (ListElement, args)
897
+ elif len(keys) >= 1:
898
+ assert not isSimpleContent
899
+ repeated_tags = frozenset(multiple)
900
+ args = (allowed_tags, repeated_tags)
901
+ self.constructors[name] = (DictionaryElement, args)
902
+ else:
903
+ self.strings[name] = allowed_tags
904
+
905
+ def elementDecl(self, name, model):
906
+ """Call a call-back function for each element declaration in a DTD.
907
+
908
+ This is used for each element declaration in a DTD like::
909
+
910
+ <!ELEMENT name (...)>
911
+
912
+ The purpose of this function is to determine whether this element
913
+ should be regarded as a string, integer, list, dictionary, structure,
914
+ or error.
915
+ """
916
+ if name.upper() == "ERROR":
917
+ self.errors.add(name)
918
+ return
919
+ if name == "Item" and model == (
920
+ expat.model.XML_CTYPE_MIXED,
921
+ expat.model.XML_CQUANT_REP,
922
+ None,
923
+ ((expat.model.XML_CTYPE_NAME, expat.model.XML_CQUANT_NONE, "Item", ()),),
924
+ ):
925
+ # Special case. As far as I can tell, this only occurs in the
926
+ # eSummary DTD.
927
+ self.items.add(name)
928
+ return
929
+ # First, remove ignorable parentheses around declarations
930
+ while (
931
+ model[0] in (expat.model.XML_CTYPE_SEQ, expat.model.XML_CTYPE_CHOICE)
932
+ and model[1] in (expat.model.XML_CQUANT_NONE, expat.model.XML_CQUANT_OPT)
933
+ and len(model[3]) == 1
934
+ ):
935
+ model = model[3][0]
936
+ # PCDATA declarations correspond to strings
937
+ if model[0] in (expat.model.XML_CTYPE_MIXED, expat.model.XML_CTYPE_EMPTY):
938
+ if model[1] == expat.model.XML_CQUANT_REP:
939
+ children = model[3]
940
+ allowed_tags = frozenset(child[2] for child in children)
941
+ else:
942
+ allowed_tags = frozenset()
943
+ self.strings[name] = allowed_tags
944
+ return
945
+ # Children can be anything; use a dictionary-type element
946
+ if model == (expat.model.XML_CTYPE_ANY, expat.model.XML_CQUANT_NONE, None, ()):
947
+ allowed_tags = None
948
+ repeated_tags = None
949
+ args = (allowed_tags, repeated_tags)
950
+ self.constructors[name] = (DictionaryElement, args)
951
+ return
952
+ # List-type elements
953
+ if model[0] in (
954
+ expat.model.XML_CTYPE_CHOICE,
955
+ expat.model.XML_CTYPE_SEQ,
956
+ ) and model[1] in (expat.model.XML_CQUANT_PLUS, expat.model.XML_CQUANT_REP):
957
+ children = model[3]
958
+ allowed_tags = frozenset(child[2] for child in children)
959
+ if model[0] == expat.model.XML_CTYPE_SEQ:
960
+ if len(children) > 1:
961
+ assert model[1] == expat.model.XML_CQUANT_PLUS
962
+ first_child = children[0]
963
+ assert first_child[1] == expat.model.XML_CQUANT_NONE
964
+ first_tag = first_child[2]
965
+ args = allowed_tags, first_tag
966
+ self.constructors[name] = (OrderedListElement, args)
967
+ return
968
+ assert len(children) == 1
969
+ self.constructors[name] = (ListElement, (allowed_tags,))
970
+ return
971
+ # This is the tricky case. Check which keys can occur multiple
972
+ # times. If only one key is possible, and it can occur multiple
973
+ # times, then this is a list. If more than one key is possible,
974
+ # but none of them can occur multiple times, then this is a
975
+ # dictionary. Otherwise, this is a structure.
976
+ # In 'single' and 'multiple', we keep track which keys can occur
977
+ # only once, and which can occur multiple times.
978
+ single = []
979
+ multiple = []
980
+ errors = []
981
+ # The 'count' function is called recursively to make sure all the
982
+ # children in this model are counted.
983
+
984
+ def count(model):
985
+ quantifier, key, children = model[1:]
986
+ if key is None:
987
+ if quantifier in (
988
+ expat.model.XML_CQUANT_PLUS,
989
+ expat.model.XML_CQUANT_REP,
990
+ ):
991
+ for child in children:
992
+ multiple.append(child[2])
993
+ else:
994
+ for child in children:
995
+ count(child)
996
+ elif key.upper() == "ERROR":
997
+ errors.append(key)
998
+ else:
999
+ if quantifier in (
1000
+ expat.model.XML_CQUANT_NONE,
1001
+ expat.model.XML_CQUANT_OPT,
1002
+ ):
1003
+ single.append(key)
1004
+ elif quantifier in (
1005
+ expat.model.XML_CQUANT_PLUS,
1006
+ expat.model.XML_CQUANT_REP,
1007
+ ):
1008
+ multiple.append(key)
1009
+
1010
+ count(model)
1011
+ if len(single) == 0 and len(multiple) == 1:
1012
+ allowed_tags = frozenset(multiple + errors)
1013
+ self.constructors[name] = (ListElement, (allowed_tags,))
1014
+ else:
1015
+ allowed_tags = frozenset(single + multiple + errors)
1016
+ repeated_tags = frozenset(multiple)
1017
+ args = (allowed_tags, repeated_tags)
1018
+ self.constructors[name] = (DictionaryElement, args)
1019
+
1020
+ def open_dtd_file(self, filename):
1021
+ """Open specified DTD file."""
1022
+ if DataHandler.local_dtd_dir is not None:
1023
+ path = os.path.join(DataHandler.local_dtd_dir, filename)
1024
+ try:
1025
+ handle = open(path, "rb")
1026
+ except FileNotFoundError:
1027
+ pass
1028
+ else:
1029
+ return handle
1030
+ path = os.path.join(DataHandler.global_dtd_dir, filename)
1031
+ try:
1032
+ handle = open(path, "rb")
1033
+ except FileNotFoundError:
1034
+ pass
1035
+ else:
1036
+ return handle
1037
+ return None
1038
+
1039
+ def open_xsd_file(self, filename):
1040
+ """Open specified XSD file."""
1041
+ if DataHandler.local_xsd_dir is not None:
1042
+ path = os.path.join(DataHandler.local_xsd_dir, filename)
1043
+ try:
1044
+ handle = open(path, "rb")
1045
+ except FileNotFoundError:
1046
+ pass
1047
+ else:
1048
+ return handle
1049
+ path = os.path.join(DataHandler.global_xsd_dir, filename)
1050
+ try:
1051
+ handle = open(path, "rb")
1052
+ except FileNotFoundError:
1053
+ pass
1054
+ else:
1055
+ return handle
1056
+ return None
1057
+
1058
+ def save_dtd_file(self, filename, text):
1059
+ """Save DTD file to cache."""
1060
+ if DataHandler.local_dtd_dir is None:
1061
+ return
1062
+ path = os.path.join(DataHandler.local_dtd_dir, filename)
1063
+ try:
1064
+ handle = open(path, "wb")
1065
+ except OSError:
1066
+ warnings.warn(f"Failed to save {filename} at {path}")
1067
+ else:
1068
+ handle.write(text)
1069
+ handle.close()
1070
+
1071
+ def save_xsd_file(self, filename, text):
1072
+ """Save XSD file to cache."""
1073
+ if DataHandler.local_xsd_dir is None:
1074
+ return
1075
+ path = os.path.join(DataHandler.local_xsd_dir, filename)
1076
+ try:
1077
+ handle = open(path, "wb")
1078
+ except OSError:
1079
+ warnings.warn(f"Failed to save {filename} at {path}")
1080
+ else:
1081
+ handle.write(text)
1082
+ handle.close()
1083
+
1084
+ def verify_security(self, url, verify_hostname=True):
1085
+ """Check if the given URL is from a trustable source.
1086
+
1087
+ When ``self.bypass_url_security`` evaluates to ``True``,
1088
+ all URL security checks will be skipped.
1089
+ """
1090
+ if not self.bypass_url_security:
1091
+ parts = urlparse(url)
1092
+ scheme = parts.scheme
1093
+ hostname = parts.hostname
1094
+ if scheme != "https" or (
1095
+ verify_hostname and not hostname.endswith(".nlm.nih.gov")
1096
+ ):
1097
+ raise ValueError(f"Expected secure URL to NCBI, found {url!r}")
1098
+
1099
+ def externalEntityRefHandler(self, context, base, systemId, publicId):
1100
+ """Handle external entity reference in order to cache DTD locally.
1101
+
1102
+ The purpose of this function is to load the DTD locally, instead
1103
+ of downloading it from the URL specified in the XML. Using the local
1104
+ DTD results in much faster parsing. If the DTD is not found locally,
1105
+ we try to download it. If new DTDs become available from NCBI,
1106
+ putting them in Bio/Entrez/DTDs will allow the parser to see them.
1107
+ """
1108
+ urlinfo = urlparse(systemId)
1109
+ if urlinfo.scheme in ["http", "https", "ftp"]:
1110
+ # Then this is an absolute path to the DTD.
1111
+ url = systemId
1112
+ elif urlinfo.scheme == "":
1113
+ # Then this is a relative path to the DTD.
1114
+ # Look at the parent URL to find the full path.
1115
+ try:
1116
+ source = self.dtd_urls[-1]
1117
+ except IndexError:
1118
+ # Assume the default URL for DTDs if the top parent
1119
+ # does not contain an absolute path
1120
+ source = "https://www.ncbi.nlm.nih.gov/dtd/"
1121
+ else:
1122
+ source = os.path.dirname(source)
1123
+ # urls always have a forward slash, don't use os.path.join
1124
+ url = source.rstrip("/") + "/" + systemId
1125
+ else:
1126
+ raise ValueError("Unexpected URL scheme %r" % urlinfo.scheme)
1127
+
1128
+ # NOTE: This trusts any external references from a trusted parent,
1129
+ # even if these external references go to unknown hosts,
1130
+ # e.g. when NCBI starts referencing things on a new host
1131
+ # from existing DTD files.
1132
+ # Needs to be checked *prior* to appending to ``self.dtd_urls``.
1133
+ self.verify_security(url, verify_hostname=not self.dtd_urls)
1134
+
1135
+ # NOTE: Since ``self.dtd_urls`` being non-empty has security
1136
+ # consequences with the check above, we use a ``finally`` wrap
1137
+ # here, in order to guarantee that push and pop are matched.
1138
+ self.dtd_urls.append(url)
1139
+ try:
1140
+ # First, try to load the local version of the DTD file
1141
+ location, filename = os.path.split(systemId)
1142
+ handle = self.open_dtd_file(filename)
1143
+ if not handle:
1144
+ # DTD is not available as a local file. Try accessing it through
1145
+ # the internet instead.
1146
+ try:
1147
+ handle = urlopen(url)
1148
+ except OSError:
1149
+ raise RuntimeError(
1150
+ f"Failed to access {filename} at {url}"
1151
+ ) from None
1152
+ text = handle.read()
1153
+ handle.close()
1154
+ self.save_dtd_file(filename, text)
1155
+ handle = BytesIO(text)
1156
+
1157
+ parser = self.parser.ExternalEntityParserCreate(context)
1158
+ parser.ElementDeclHandler = self.elementDecl
1159
+ parser.ParseFile(handle)
1160
+ handle.close()
1161
+ finally:
1162
+ self.dtd_urls.pop()
1163
+
1164
+ self.parser.StartElementHandler = self.startElementHandler
1165
+ return 1
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/._IPGReportSet.xsd ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/._NCBI_BlastOutput2.mod.xsd ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/._NCBI_BlastOutput2.xsd ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/IPGReportSet.xsd ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <xs:schema
3
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
+ xmlns:ncbi="http://www.ncbi.nlm.nih.gov"
5
+ elementFormDefault="unqualified"
6
+ attributeFormDefault="unqualified"
7
+ >
8
+ <xs:element name="CDS">
9
+ <xs:complexType>
10
+ <xs:attribute name="accver" type="xs:string" use="required"/>
11
+ <xs:attribute name="kingdom" type="xs:string" use="required"/>
12
+ <xs:attribute name="kingdom_taxid" type="xs:integer" use="required"/>
13
+ <xs:attribute name="org" type="xs:string" use="required"/>
14
+ <xs:attribute name="start" type="xs:integer" use="required"/>
15
+ <xs:attribute name="stop" type="xs:integer" use="required"/>
16
+ <xs:attribute name="strand" type="xs:string" use="required"/>
17
+ <xs:attribute name="strain" type="xs:string" use="optional"/>
18
+ <xs:attribute name="taxid" type="xs:integer" use="required"/>
19
+ </xs:complexType>
20
+ </xs:element>
21
+
22
+ <xs:element name="CDSList">
23
+ <xs:complexType>
24
+ <xs:sequence maxOccurs="unbounded">
25
+ <xs:element ref="CDS"/>
26
+ </xs:sequence>
27
+ </xs:complexType>
28
+ </xs:element>
29
+
30
+ <xs:element name="IPGReport">
31
+ <xs:complexType>
32
+ <xs:sequence>
33
+ <xs:element ref="Product"/>
34
+ <xs:element ref="ProteinList"/>
35
+ <xs:element ref="Statistics"/>
36
+ </xs:sequence>
37
+ <xs:attribute name="product_acc" type="xs:string" use="required"/>
38
+ <xs:attribute name="ipg" type="xs:integer" use="required"/>
39
+ </xs:complexType>
40
+ </xs:element>
41
+
42
+ <xs:element name="IPGReportSet">
43
+ <xs:complexType>
44
+ <xs:sequence>
45
+ <xs:element ref="IPGReport"/>
46
+ </xs:sequence>
47
+ </xs:complexType>
48
+ </xs:element>
49
+
50
+ <xs:element name="Product">
51
+ <xs:complexType>
52
+ <xs:simpleContent>
53
+ <xs:extension base="xs:string">
54
+ <xs:attribute name="accver" type="xs:string" use="required"/>
55
+ <xs:attribute name="name" type="xs:string" use="required"/>
56
+ <xs:attribute name="org" type="xs:string" use="required"/>
57
+ <xs:attribute name="kingdom" type="xs:string" use="required"/>
58
+ <xs:attribute name="taxid" type="xs:integer" use="optional"/>
59
+ <xs:attribute name="slen" type="xs:integer" use="required"/>
60
+ <xs:attribute name="kingdom_taxid" type="xs:integer" use="required"/>
61
+ </xs:extension>
62
+ </xs:simpleContent>
63
+ </xs:complexType>
64
+ </xs:element>
65
+
66
+ <xs:element name="Protein">
67
+ <xs:complexType>
68
+ <xs:sequence minOccurs="0">
69
+ <xs:element ref="CDSList"/>
70
+ </xs:sequence>
71
+ <xs:attribute name="accver" type="xs:string" use="required"/>
72
+ <xs:attribute name="source" type="xs:string" use="required"/>
73
+ <xs:attribute name="name" type="xs:string" use="required"/>
74
+ <xs:attribute name="org" type="xs:string" use="required"/>
75
+ <xs:attribute name="kingdom" type="xs:string" use="required"/>
76
+ <xs:attribute name="kingdom_taxid" type="xs:integer" use="required"/>
77
+ <xs:attribute name="taxid" type="xs:integer" use="optional"/>
78
+ <xs:attribute name="priority" type="xs:string" use="required"/>
79
+ </xs:complexType>
80
+ </xs:element>
81
+
82
+ <xs:element name="ProteinList">
83
+ <xs:complexType>
84
+ <xs:sequence maxOccurs="unbounded">
85
+ <xs:element ref="Protein"/>
86
+ </xs:sequence>
87
+ </xs:complexType>
88
+ </xs:element>
89
+
90
+ <xs:element name="Statistics">
91
+ <xs:complexType>
92
+ <xs:attribute name="nuc_count" type="xs:integer" use="required"/>
93
+ <xs:attribute name="prot_count" type="xs:integer" use="required"/>
94
+ </xs:complexType>
95
+ </xs:element>
96
+
97
+ </xs:schema>
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/NCBI_BlastOutput2.mod.xsd ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!-- ============================================
3
+ ::DATATOOL:: Generated from "blastxml2.asn"
4
+ ::DATATOOL:: by application DATATOOL version 2.4.4
5
+ ::DATATOOL:: on 09/23/2015 23:04:21
6
+ ============================================ -->
7
+
8
+ <xs:schema
9
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
10
+ xmlns:ncbi="http://www.ncbi.nlm.nih.gov"
11
+ xmlns="http://www.ncbi.nlm.nih.gov"
12
+ targetNamespace="http://www.ncbi.nlm.nih.gov"
13
+ elementFormDefault="qualified"
14
+ attributeFormDefault="unqualified">
15
+
16
+ <!-- ============================================ -->
17
+ <!-- This section is mapped from module "NCBI-BlastOutput2"
18
+ ================================================= -->
19
+
20
+
21
+ <xs:element name="BlastOutput2">
22
+ <xs:complexType>
23
+ <xs:sequence>
24
+ <xs:element name="report" minOccurs="0">
25
+ <xs:complexType>
26
+ <xs:sequence>
27
+ <xs:element ref="Report"/>
28
+ </xs:sequence>
29
+ </xs:complexType>
30
+ </xs:element>
31
+ <xs:element name="error" minOccurs="0">
32
+ <xs:complexType>
33
+ <xs:sequence>
34
+ <xs:element ref="Err"/>
35
+ </xs:sequence>
36
+ </xs:complexType>
37
+ </xs:element>
38
+ </xs:sequence>
39
+ </xs:complexType>
40
+ </xs:element>
41
+
42
+ <xs:element name="BlastXML2">
43
+ <xs:complexType>
44
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
45
+ <xs:element ref="BlastOutput2"/>
46
+ </xs:sequence>
47
+ </xs:complexType>
48
+ </xs:element>
49
+
50
+ <xs:element name="Report">
51
+ <xs:complexType>
52
+ <xs:sequence>
53
+ <!-- BLAST program: blastp, tblastx etc. -->
54
+ <xs:element name="program" type="xs:string"/>
55
+ <!-- Program version -->
56
+ <xs:element name="version" type="xs:string"/>
57
+ <!-- Steven, David, Tom and others -->
58
+ <xs:element name="reference" type="xs:string"/>
59
+ <xs:element name="search-target">
60
+ <xs:complexType>
61
+ <xs:sequence>
62
+ <xs:element ref="Target"/>
63
+ </xs:sequence>
64
+ </xs:complexType>
65
+ </xs:element>
66
+ <!-- search parameters -->
67
+ <xs:element name="params">
68
+ <xs:complexType>
69
+ <xs:sequence>
70
+ <xs:element ref="Parameters"/>
71
+ </xs:sequence>
72
+ </xs:complexType>
73
+ </xs:element>
74
+ <xs:element name="results">
75
+ <xs:complexType>
76
+ <xs:sequence>
77
+ <xs:element ref="Results"/>
78
+ </xs:sequence>
79
+ </xs:complexType>
80
+ </xs:element>
81
+ </xs:sequence>
82
+ </xs:complexType>
83
+ </xs:element>
84
+
85
+ <xs:element name="Err">
86
+ <xs:complexType>
87
+ <xs:sequence>
88
+ <xs:element name="code" type="xs:integer"/>
89
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
90
+ </xs:sequence>
91
+ </xs:complexType>
92
+ </xs:element>
93
+
94
+ <xs:element name="Target">
95
+ <xs:complexType>
96
+ <xs:choice>
97
+ <!-- BLAST Database name -->
98
+ <xs:element name="db" type="xs:string"/>
99
+ <!-- Subject IDs -->
100
+ <xs:element name="subjects" type="xs:string" maxOccurs="unbounded"/>
101
+ </xs:choice>
102
+ </xs:complexType>
103
+ </xs:element>
104
+
105
+ <xs:element name="Results">
106
+ <xs:complexType>
107
+ <xs:choice>
108
+ <xs:element name="iterations">
109
+ <xs:complexType>
110
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
111
+ <xs:element ref="Iteration"/>
112
+ </xs:sequence>
113
+ </xs:complexType>
114
+ </xs:element>
115
+ <!--
116
+ iterative search (psi and delta blast)
117
+ db search
118
+ -->
119
+ <xs:element name="search">
120
+ <xs:complexType>
121
+ <xs:sequence>
122
+ <xs:element ref="Search"/>
123
+ </xs:sequence>
124
+ </xs:complexType>
125
+ </xs:element>
126
+ <!-- bl2seq -->
127
+ <xs:element name="bl2seq">
128
+ <xs:complexType>
129
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
130
+ <xs:element ref="Search"/>
131
+ </xs:sequence>
132
+ </xs:complexType>
133
+ </xs:element>
134
+ </xs:choice>
135
+ </xs:complexType>
136
+ </xs:element>
137
+
138
+ <xs:element name="Iteration">
139
+ <xs:complexType>
140
+ <xs:sequence>
141
+ <!-- iteration number (use with psiblast) -->
142
+ <xs:element name="iter-num" type="xs:integer"/>
143
+ <xs:element name="search">
144
+ <xs:complexType>
145
+ <xs:sequence>
146
+ <xs:element ref="Search"/>
147
+ </xs:sequence>
148
+ </xs:complexType>
149
+ </xs:element>
150
+ </xs:sequence>
151
+ </xs:complexType>
152
+ </xs:element>
153
+
154
+ <xs:element name="Search">
155
+ <xs:complexType>
156
+ <xs:sequence>
157
+ <!-- SeqId of query -->
158
+ <xs:element name="query-id" type="xs:string" minOccurs="0"/>
159
+ <!-- Definition line of query -->
160
+ <xs:element name="query-title" type="xs:string" minOccurs="0"/>
161
+ <!-- length of query sequence -->
162
+ <xs:element name="query-len" type="xs:integer" minOccurs="0"/>
163
+ <!-- Masked offsets. -->
164
+ <xs:element name="query-masking" minOccurs="0">
165
+ <xs:complexType>
166
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
167
+ <xs:element ref="Range"/>
168
+ </xs:sequence>
169
+ </xs:complexType>
170
+ </xs:element>
171
+ <!-- Hits one for every db sequence -->
172
+ <xs:element name="hits" minOccurs="0">
173
+ <xs:complexType>
174
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
175
+ <xs:element ref="Hit"/>
176
+ </xs:sequence>
177
+ </xs:complexType>
178
+ </xs:element>
179
+ <!-- search statistics -->
180
+ <xs:element name="stat" minOccurs="0">
181
+ <xs:complexType>
182
+ <xs:sequence>
183
+ <xs:element ref="Statistics"/>
184
+ </xs:sequence>
185
+ </xs:complexType>
186
+ </xs:element>
187
+ <!-- Some (error?) information -->
188
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
189
+ </xs:sequence>
190
+ </xs:complexType>
191
+ </xs:element>
192
+
193
+ <xs:element name="Parameters">
194
+ <xs:complexType>
195
+ <xs:sequence>
196
+ <!-- Matrix used (-M) -->
197
+ <xs:element name="matrix" type="xs:string" minOccurs="0"/>
198
+ <!-- Expectation threshold (-e) -->
199
+ <xs:element name="expect" type="xs:double"/>
200
+ <!-- Inclusion threshold (-h) -->
201
+ <xs:element name="include" type="xs:double" minOccurs="0"/>
202
+ <!-- match score for NT (-r) -->
203
+ <xs:element name="sc-match" type="xs:integer" minOccurs="0"/>
204
+ <!-- mismatch score for NT (-q) -->
205
+ <xs:element name="sc-mismatch" type="xs:integer" minOccurs="0"/>
206
+ <!-- Gap opening cost (-G) -->
207
+ <xs:element name="gap-open" type="xs:integer" minOccurs="0"/>
208
+ <!-- Gap extension cost (-E) -->
209
+ <xs:element name="gap-extend" type="xs:integer" minOccurs="0"/>
210
+ <!-- Filtering options (-F) -->
211
+ <xs:element name="filter" type="xs:string" minOccurs="0"/>
212
+ <!-- PHI-BLAST pattern -->
213
+ <xs:element name="pattern" type="xs:string" minOccurs="0"/>
214
+ <!-- Limit of request to Entrez query -->
215
+ <xs:element name="entrez-query" type="xs:string" minOccurs="0"/>
216
+ <!--
217
+ composition-based stats (numbers correspond to
218
+ numbering in stand-alone application parameter -comp_based_stats).
219
+ -->
220
+ <xs:element name="cbs" type="xs:integer" minOccurs="0"/>
221
+ <!-- genetic code for query (blastx or tblastx) -->
222
+ <xs:element name="query-gencode" type="xs:integer" minOccurs="0"/>
223
+ <!-- genetic code for db or subjects (tblastn or tblastx) -->
224
+ <xs:element name="db-gencode" type="xs:integer" minOccurs="0"/>
225
+ <!-- bl2seq mode -->
226
+ <xs:element name="bl2seq-mode" type="xs:string" minOccurs="0"/>
227
+ </xs:sequence>
228
+ </xs:complexType>
229
+ </xs:element>
230
+
231
+ <!-- Used to specify start/stop of masking on query. -->
232
+ <xs:element name="Range">
233
+ <xs:complexType>
234
+ <xs:sequence>
235
+ <!-- Beginning of masked range (one-offset) -->
236
+ <xs:element name="from" type="xs:integer"/>
237
+ <!-- End of masked range (one-offset) -->
238
+ <xs:element name="to" type="xs:integer"/>
239
+ </xs:sequence>
240
+ </xs:complexType>
241
+ </xs:element>
242
+
243
+ <xs:element name="Statistics">
244
+ <xs:complexType>
245
+ <xs:sequence>
246
+ <!-- Number of sequences in BLAST db -->
247
+ <xs:element name="db-num" type="xs:long" minOccurs="0"/>
248
+ <!-- Length of BLAST db -->
249
+ <xs:element name="db-len" type="xs:long" minOccurs="0"/>
250
+ <!-- Effective HSP length -->
251
+ <xs:element name="hsp-len" type="xs:integer"/>
252
+ <!-- Effective search space -->
253
+ <xs:element name="eff-space" type="xs:long"/>
254
+ <!-- Karlin-Altschul parameter K -->
255
+ <xs:element name="kappa" type="xs:double"/>
256
+ <!-- Karlin-Altschul parameter Lambda -->
257
+ <xs:element name="lambda" type="xs:double"/>
258
+ <!-- Karlin-Altschul parameter H -->
259
+ <xs:element name="entropy" type="xs:double"/>
260
+ </xs:sequence>
261
+ </xs:complexType>
262
+ </xs:element>
263
+
264
+ <!-- Description of entries for this (possibly non-redundant) sequence. -->
265
+ <xs:element name="HitDescr">
266
+ <xs:complexType>
267
+ <xs:sequence>
268
+ <!-- SeqId of subject -->
269
+ <xs:element name="id" type="xs:string"/>
270
+ <!-- accession -->
271
+ <xs:element name="accession" type="xs:string" minOccurs="0"/>
272
+ <!-- title (definition line) of subject -->
273
+ <xs:element name="title" type="xs:string" minOccurs="0"/>
274
+ <!-- NCBI taxid (9606 for human) -->
275
+ <xs:element name="taxid" type="xs:integer" minOccurs="0"/>
276
+ <!-- binomial scientific name ("Homo sapiens" for human). -->
277
+ <xs:element name="sciname" type="xs:string" minOccurs="0"/>
278
+ </xs:sequence>
279
+ </xs:complexType>
280
+ </xs:element>
281
+
282
+ <xs:element name="Hit">
283
+ <xs:complexType>
284
+ <xs:sequence>
285
+ <!-- hit number -->
286
+ <xs:element name="num" type="xs:integer"/>
287
+ <!-- ID, title, and taxonomy for each entry in the PIG -->
288
+ <xs:element name="description">
289
+ <xs:complexType>
290
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
291
+ <xs:element ref="HitDescr"/>
292
+ </xs:sequence>
293
+ </xs:complexType>
294
+ </xs:element>
295
+ <!-- length of subject -->
296
+ <xs:element name="len" type="xs:integer"/>
297
+ <!-- all HSP regions for the given subject -->
298
+ <xs:element name="hsps" minOccurs="0">
299
+ <xs:complexType>
300
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
301
+ <xs:element ref="Hsp"/>
302
+ </xs:sequence>
303
+ </xs:complexType>
304
+ </xs:element>
305
+ </xs:sequence>
306
+ </xs:complexType>
307
+ </xs:element>
308
+
309
+ <xs:element name="Hsp">
310
+ <xs:complexType>
311
+ <xs:sequence>
312
+ <!-- HSP number -->
313
+ <xs:element name="num" type="xs:integer"/>
314
+ <!-- score (in bits) of HSP -->
315
+ <xs:element name="bit-score" type="xs:double"/>
316
+ <!-- score of HSP -->
317
+ <xs:element name="score" type="xs:double"/>
318
+ <!-- e-value of HSP -->
319
+ <xs:element name="evalue" type="xs:double"/>
320
+ <!-- number of identities in HSP -->
321
+ <xs:element name="identity" type="xs:integer" minOccurs="0"/>
322
+ <!-- number of positives in HSP -->
323
+ <xs:element name="positive" type="xs:integer" minOccurs="0"/>
324
+ <!-- score density -->
325
+ <xs:element name="density" type="xs:integer" minOccurs="0"/>
326
+ <!-- start of PHI-BLAST pattern -->
327
+ <xs:element name="pattern-from" type="xs:integer" minOccurs="0"/>
328
+ <!-- end of PHI-BLAST pattern -->
329
+ <xs:element name="pattern-to" type="xs:integer" minOccurs="0"/>
330
+ <!-- start of HSP in query -->
331
+ <xs:element name="query-from" type="xs:integer"/>
332
+ <!-- end of HSP -->
333
+ <xs:element name="query-to" type="xs:integer"/>
334
+ <!-- Strand of query (blastn) -->
335
+ <xs:element name="query-strand" type="xs:string" minOccurs="0"/>
336
+ <!-- translation frame of query (blastx, tblastx) -->
337
+ <xs:element name="query-frame" type="xs:integer" minOccurs="0"/>
338
+ <!-- start of HSP in subject -->
339
+ <xs:element name="hit-from" type="xs:integer"/>
340
+ <!-- end of HSP in subject -->
341
+ <xs:element name="hit-to" type="xs:integer"/>
342
+ <!-- Strand of subject (blastn) -->
343
+ <xs:element name="hit-strand" type="xs:string" minOccurs="0"/>
344
+ <!-- translation frame of subject (tblastn, tblastx) -->
345
+ <xs:element name="hit-frame" type="xs:integer" minOccurs="0"/>
346
+ <!-- length of the alignment used -->
347
+ <xs:element name="align-len" type="xs:integer" minOccurs="0"/>
348
+ <!-- number of gaps in HSP -->
349
+ <xs:element name="gaps" type="xs:integer" minOccurs="0"/>
350
+ <!-- alignment string for the query (with gaps) -->
351
+ <xs:element name="qseq" type="xs:string"/>
352
+ <!-- alignment string for subject (with gaps) -->
353
+ <xs:element name="hseq" type="xs:string"/>
354
+ <!-- formating middle line -->
355
+ <xs:element name="midline" type="xs:string" minOccurs="0"/>
356
+ </xs:sequence>
357
+ </xs:complexType>
358
+ </xs:element>
359
+
360
+ </xs:schema>
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/XSDs/NCBI_BlastOutput2.xsd ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!-- ============================================
3
+ ::DATATOOL:: Generated from "blastxml2.asn"
4
+ ::DATATOOL:: by application DATATOOL version 2.4.4
5
+ ::DATATOOL:: on 04/22/2015 11:04:30
6
+ ============================================ -->
7
+
8
+ <xs:schema
9
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
10
+ xmlns:ncbi="http://www.ncbi.nlm.nih.gov"
11
+ xmlns="http://www.ncbi.nlm.nih.gov"
12
+ targetNamespace="http://www.ncbi.nlm.nih.gov"
13
+ elementFormDefault="qualified"
14
+ attributeFormDefault="unqualified">
15
+
16
+ <!-- NCBI_BlastOutput2.xsd
17
+ This file is built from a series of basic modules.
18
+ The actual declarations are in the modules.
19
+ This file is used to put them together.
20
+ -->
21
+ <xs:include schemaLocation="NCBI_BlastOutput2.mod.xsd"/>
22
+ </xs:schema>
.venv_haddock/lib/python3.12/site-packages/Bio/Entrez/__init__.py ADDED
@@ -0,0 +1,747 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 1999-2000 by Jeffrey Chang. All rights reserved.
2
+ # Copyright 2008-2013 by Michiel de Hoon. All rights reserved.
3
+ # Revisions copyright 2011-2016 by Peter Cock. All rights reserved.
4
+ # Revisions copyright 2015 by Eric Rasche. All rights reserved.
5
+ # Revisions copyright 2015 by Carlos Pena. All rights reserved.
6
+ #
7
+ # This file is part of the Biopython distribution and governed by your
8
+ # choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
9
+ # Please see the LICENSE file that should have been included as part of this
10
+ # package.
11
+
12
+ """Provides code to access NCBI over the WWW.
13
+
14
+ The main Entrez web page is available at:
15
+ https://www.ncbi.nlm.nih.gov/search/
16
+
17
+ Entrez Programming Utilities web page is available at:
18
+ https://www.ncbi.nlm.nih.gov/books/NBK25501/
19
+
20
+ This module provides a number of functions like ``efetch`` (short for
21
+ Entrez Fetch) which will return the data as a handle object. This is
22
+ a standard interface used in Python for reading data from a file, or
23
+ in this case a remote network connection, and provides methods like
24
+ ``.read()`` or offers iteration over the contents line by line. See
25
+ also "What the heck is a handle?" in the Biopython Tutorial and
26
+ Cookbook: https://biopython.org/docs/latest/Tutorial/index.html
27
+
28
+ The handle returned by these functions can be either in text mode or
29
+ in binary mode, depending on the data requested and the results
30
+ returned by NCBI Entrez. Typically, XML data will be in binary mode
31
+ while other data will be in text mode, as required by the downstream
32
+ parser to parse the data.
33
+
34
+ Unlike a handle to a file on disk from the ``open(filename)`` function,
35
+ which has a ``.name`` attribute giving the filename, the handles from
36
+ ``Bio.Entrez`` all have a ``.url`` attribute instead giving the URL
37
+ used to connect to the NCBI Entrez API.
38
+
39
+ The ``epost``, ``efetch``, and ``esummary`` tools take an "id" parameter
40
+ which corresponds to one or more database UIDs (or accession.version
41
+ identifiers in the case of sequence databases such as "nuccore" or
42
+ "protein"). The Python value of the "id" keyword passed to these functions
43
+ may be either a single ID as a string or integer or multiple IDs as an
44
+ iterable of strings/integers. You may also pass a single string containing
45
+ multiple IDs delimited by commas. The ``elink`` tool also accepts multiple
46
+ IDs but the argument is handled differently than the other three. See that
47
+ function's docstring for more information.
48
+
49
+ All the functions that send requests to the NCBI Entrez API will
50
+ automatically respect the NCBI rate limit (of 3 requests per second
51
+ without an API key, or 10 requests per second with an API key) and
52
+ will automatically retry when encountering transient failures
53
+ (i.e. connection failures or HTTP 5XX codes). By default, Biopython
54
+ does a maximum of three tries before giving up, and sleeps for 15
55
+ seconds between tries. You can tweak these parameters by setting
56
+ ``Bio.Entrez.max_tries`` and ``Bio.Entrez.sleep_between_tries``.
57
+
58
+ The Entrez module also provides an XML parser which takes a handle
59
+ as input.
60
+
61
+ Variables:
62
+
63
+ - email Set the Entrez email parameter (default is not set).
64
+ - tool Set the Entrez tool parameter (default is ``biopython``).
65
+ - api_key Personal API key from NCBI. If not set, only 3 queries per
66
+ second are allowed. 10 queries per seconds otherwise with a
67
+ valid API key.
68
+ - max_tries Configures how many times failed requests will be
69
+ automatically retried on error (default is 3).
70
+ - sleep_between_tries The delay, in seconds, before retrying a request on
71
+ error (default is 15).
72
+
73
+ Functions:
74
+
75
+ - efetch Retrieves records in the requested format from a list of one or
76
+ more primary IDs or from the user's environment
77
+ - epost Posts a file containing a list of primary IDs for future use in
78
+ the user's environment to use with subsequent search strategies
79
+ - esearch Searches and retrieves primary IDs (for use in EFetch, ELink,
80
+ and ESummary) and term translations and optionally retains
81
+ results for future use in the user's environment.
82
+ - elink Checks for the existence of an external or Related Articles link
83
+ from a list of one or more primary IDs. Retrieves primary IDs
84
+ and relevancy scores for links to Entrez databases or Related
85
+ Articles; creates a hyperlink to the primary LinkOut provider
86
+ for a specific ID and database, or lists LinkOut URLs
87
+ and Attributes for multiple IDs.
88
+ - einfo Provides field index term counts, last update, and available
89
+ links for each database.
90
+ - esummary Retrieves document summaries from a list of primary IDs or from
91
+ the user's environment.
92
+ - egquery Provides Entrez database counts in XML for a single search
93
+ using Global Query.
94
+ - espell Retrieves spelling suggestions.
95
+ - ecitmatch Retrieves PubMed IDs (PMIDs) that correspond to a set of
96
+ input citation strings.
97
+
98
+ - read Parses the XML results returned by any of the above functions.
99
+ Alternatively, the XML data can be read from a file opened in binary mode.
100
+ Typical usage is:
101
+
102
+ >>> from Bio import Entrez
103
+ >>> Entrez.email = "Your.Name.Here@example.org"
104
+ >>> handle = Entrez.einfo() # or esearch, efetch, ...
105
+ >>> record = Entrez.read(handle)
106
+ >>> handle.close()
107
+
108
+ where record is now a Python dictionary or list.
109
+
110
+ - parse Parses the XML results returned by those of the above functions
111
+ which can return multiple records - such as efetch, esummary
112
+ and elink. Typical usage is:
113
+
114
+ >>> handle = Entrez.efetch(db="taxonomy", id="9615,9685", retmode="xml")
115
+ >>> records = Entrez.parse(handle)
116
+ >>> for record in records:
117
+ ... print(record['TaxId'], record["OtherNames"]['GenbankCommonName'])
118
+ ...
119
+ 9615 dog
120
+ 9685 domestic cat
121
+ >>> handle.close()
122
+
123
+ This function is appropriate only if the XML file contains
124
+ multiple records, and is particular useful for large files.
125
+
126
+ - _open Internally used function.
127
+
128
+ """
129
+
130
+ import io
131
+ import time
132
+ import warnings
133
+ from urllib.error import HTTPError
134
+ from urllib.error import URLError
135
+ from urllib.parse import urlencode
136
+ from urllib.request import Request
137
+ from urllib.request import urlopen
138
+
139
+ from Bio._utils import function_with_previous
140
+
141
+ email = None
142
+ max_tries = 3
143
+ sleep_between_tries = 15
144
+ tool = "biopython"
145
+ api_key = None
146
+ local_cache = None
147
+
148
+
149
+ # XXX retmode?
150
+ def epost(db, **keywds):
151
+ """Post a file of identifiers for future use.
152
+
153
+ Posts a file containing a list of UIs for future use in the user's
154
+ environment to use with subsequent search strategies.
155
+
156
+ See the online documentation for an explanation of the parameters:
157
+ https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EPost
158
+
159
+ :returns: Handle to the results.
160
+ :raises urllib.error.URLError: If there's a network error.
161
+ """
162
+ cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi"
163
+ variables = {"db": db}
164
+ variables.update(keywds)
165
+ request = _build_request(cgi, variables, post=True)
166
+ return _open(request)
167
+
168
+
169
+ def efetch(db, **keywords):
170
+ """Fetch Entrez results which are returned as a handle.
171
+
172
+ EFetch retrieves records in the requested format from a list or set of one or
173
+ more UIs or from user's environment.
174
+
175
+ See the online documentation for an explanation of the parameters:
176
+ https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EFetch
177
+
178
+ Short example:
179
+
180
+ >>> from Bio import Entrez
181
+ >>> Entrez.email = "Your.Name.Here@example.org"
182
+ >>> handle = Entrez.efetch(db="nucleotide", id="AY851612", rettype="gb", retmode="text")
183
+ >>> print(handle.readline().strip())
184
+ LOCUS AY851612 892 bp DNA linear PLN 10-APR-2007
185
+ >>> handle.close()
186
+
187
+ This will automatically use an HTTP POST rather than HTTP GET if there
188
+ are over 200 identifiers as recommended by the NCBI.
189
+
190
+ **Warning:** The NCBI changed the default retmode in Feb 2012, so many
191
+ databases which previously returned text output now give XML.
192
+
193
+ :returns: Handle to the results.
194
+ :raises urllib.error.URLError: If there's a network error.
195
+ """
196
+ cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi"
197
+ variables = {"db": db}
198
+ variables.update(keywords)
199
+ request = _build_request(cgi, variables)
200
+ return _open(request)
201
+
202
+
203
+ def esearch(db, term, **keywds):
204
+ """Run an Entrez search and return a handle to the results.
205
+
206
+ ESearch searches and retrieves primary IDs (for use in EFetch, ELink
207
+ and ESummary) and term translations, and optionally retains results
208
+ for future use in the user's environment.
209
+
210
+ See the online documentation for an explanation of the parameters:
211
+ https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch
212
+
213
+ Short example:
214
+
215
+ >>> from Bio import Entrez
216
+ >>> Entrez.email = "Your.Name.Here@example.org"
217
+ >>> handle = Entrez.esearch(
218
+ ... db="nucleotide", retmax=10, idtype="acc",
219
+ ... term="opuntia[ORGN] accD 2007[Publication Date]"
220
+ ... )
221
+ ...
222
+ >>> record = Entrez.read(handle)
223
+ >>> handle.close()
224
+ >>> int(record["Count"]) >= 2
225
+ True
226
+ >>> "EF590893.1" in record["IdList"]
227
+ True
228
+ >>> "EF590892.1" in record["IdList"]
229
+ True
230
+
231
+ :returns: Handle to the results, which are always in XML format.
232
+ :raises urllib.error.URLError: If there's a network error.
233
+ """
234
+ cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi"
235
+ variables = {"db": db, "term": term}
236
+ variables.update(keywds)
237
+ request = _build_request(cgi, variables)
238
+ return _open(request)
239
+
240
+
241
+ def elink(**keywds):
242
+ """Check for linked external articles and return a handle.
243
+
244
+ ELink checks for the existence of an external or Related Articles link
245
+ from a list of one or more primary IDs; retrieves IDs and relevancy
246
+ scores for links to Entrez databases or Related Articles; creates a
247
+ hyperlink to the primary LinkOut provider for a specific ID and
248
+ database, or lists LinkOut URLs and attributes for multiple IDs.
249
+
250
+ See the online documentation for an explanation of the parameters:
251
+ https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ELink
252
+
253
+ Note that ELink treats the "id" parameter differently than the other
254
+ tools when multiple values are given. You should generally pass multiple
255
+ UIDs as a list of strings or integers. This will provide a "one-to-one"
256
+ mapping from source database UIDs to destination database UIDs in the
257
+ result. If multiple source UIDs are passed as a single comma-delimited
258
+ string all destination UIDs will be mixed together in the result.
259
+
260
+ This example finds articles related to the Biopython application
261
+ note's entry in the PubMed database:
262
+
263
+ >>> from Bio import Entrez
264
+ >>> Entrez.email = "Your.Name.Here@example.org"
265
+ >>> pmid = "19304878"
266
+ >>> handle = Entrez.elink(dbfrom="pubmed", id=pmid, linkname="pubmed_pubmed")
267
+ >>> record = Entrez.read(handle)
268
+ >>> handle.close()
269
+ >>> print(record[0]["LinkSetDb"][0]["LinkName"])
270
+ pubmed_pubmed
271
+ >>> linked = [link["Id"] for link in record[0]["LinkSetDb"][0]["Link"]]
272
+ >>> "14630660" in linked
273
+ True
274
+
275
+ This is explained in much more detail in the Biopython Tutorial.
276
+
277
+ :returns: Handle to the results, by default in XML format.
278
+ :raises urllib.error.URLError: If there's a network error.
279
+ """
280
+ cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi"
281
+ variables = {}
282
+ variables.update(keywds)
283
+ request = _build_request(cgi, variables, join_ids=False)
284
+ return _open(request)
285
+
286
+
287
+ def einfo(**keywds):
288
+ """Return a summary of the Entrez databases as a results handle.
289
+
290
+ EInfo provides field names, index term counts, last update, and
291
+ available links for each Entrez database.
292
+
293
+ See the online documentation for an explanation of the parameters:
294
+ https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EInfo
295
+
296
+ Short example:
297
+
298
+ >>> from Bio import Entrez
299
+ >>> Entrez.email = "Your.Name.Here@example.org"
300
+ >>> record = Entrez.read(Entrez.einfo())
301
+ >>> 'pubmed' in record['DbList']
302
+ True
303
+
304
+ :returns: Handle to the results, by default in XML format.
305
+ :raises urllib.error.URLError: If there's a network error.
306
+ """
307
+ cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi"
308
+ variables = {}
309
+ variables.update(keywds)
310
+ request = _build_request(cgi, variables)
311
+ return _open(request)
312
+
313
+
314
+ def esummary(**keywds):
315
+ """Retrieve document summaries as a results handle.
316
+
317
+ ESummary retrieves document summaries from a list of primary IDs or
318
+ from the user's environment.
319
+
320
+ See the online documentation for an explanation of the parameters:
321
+ https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESummary
322
+
323
+ This example discovers more about entry 19923 in the structure
324
+ database:
325
+
326
+ >>> from Bio import Entrez
327
+ >>> Entrez.email = "Your.Name.Here@example.org"
328
+ >>> handle = Entrez.esummary(db="structure", id="19923")
329
+ >>> record = Entrez.read(handle)
330
+ >>> handle.close()
331
+ >>> print(record[0]["Id"])
332
+ 19923
333
+ >>> print(record[0]["PdbDescr"])
334
+ CRYSTAL STRUCTURE OF E. COLI ACONITASE B
335
+
336
+
337
+ :returns: Handle to the results, by default in XML format.
338
+ :raises urllib.error.URLError: If there's a network error.
339
+ """
340
+ cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi"
341
+ variables = {}
342
+ variables.update(keywds)
343
+ request = _build_request(cgi, variables)
344
+ return _open(request)
345
+
346
+
347
+ def espell(**keywds):
348
+ """Retrieve spelling suggestions as a results handle.
349
+
350
+ ESpell retrieves spelling suggestions, if available.
351
+
352
+ See the online documentation for an explanation of the parameters:
353
+ https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESpell
354
+
355
+ Short example:
356
+
357
+ >>> from Bio import Entrez
358
+ >>> Entrez.email = "Your.Name.Here@example.org"
359
+ >>> record = Entrez.read(Entrez.espell(term="biopythooon"))
360
+ >>> print(record["Query"])
361
+ biopythooon
362
+ >>> print(record["CorrectedQuery"])
363
+ biopython
364
+
365
+ :returns: Handle to the results, by default in XML format.
366
+ :raises urllib.error.URLError: If there's a network error.
367
+ """
368
+ cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/espell.fcgi"
369
+ variables = {}
370
+ variables.update(keywds)
371
+ request = _build_request(cgi, variables)
372
+ return _open(request)
373
+
374
+
375
+ def _update_ecitmatch_variables(keywds):
376
+ # XML is the only supported value, and it actually returns TXT.
377
+ variables = {"retmode": "xml"}
378
+ citation_keys = (
379
+ "journal_title",
380
+ "year",
381
+ "volume",
382
+ "first_page",
383
+ "author_name",
384
+ "key",
385
+ )
386
+
387
+ # Accept pre-formatted strings
388
+ if isinstance(keywds["bdata"], str):
389
+ variables.update(keywds)
390
+ else:
391
+ # Alternatively accept a nicer interface
392
+ variables["db"] = keywds["db"]
393
+ bdata = []
394
+ for citation in keywds["bdata"]:
395
+ formatted_citation = "|".join(
396
+ [citation.get(key, "") for key in citation_keys]
397
+ )
398
+ bdata.append(formatted_citation)
399
+ variables["bdata"] = "\r".join(bdata)
400
+ return variables
401
+
402
+
403
+ def ecitmatch(**keywds):
404
+ """Retrieve PMIDs for input citation strings, returned as a handle.
405
+
406
+ ECitMatch retrieves PubMed IDs (PMIDs) that correspond to a set of input
407
+ citation strings.
408
+
409
+ See the online documentation for an explanation of the parameters:
410
+ https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ECitMatch
411
+
412
+ Short example:
413
+
414
+ >>> from Bio import Entrez
415
+ >>> Entrez.email = "Your.Name.Here@example.org"
416
+ >>> citation_1 = {"journal_title": "proc natl acad sci u s a",
417
+ ... "year": "1991", "volume": "88", "first_page": "3248",
418
+ ... "author_name": "mann bj", "key": "citation_1"}
419
+ >>> handle = Entrez.ecitmatch(db="pubmed", bdata=[citation_1])
420
+ >>> print(handle.read().strip().split("|"))
421
+ ['proc natl acad sci u s a', '1991', '88', '3248', 'mann bj', 'citation_1', '2014248']
422
+ >>> handle.close()
423
+
424
+ :returns: Handle to the results, by default in plain text.
425
+ :raises urllib.error.URLError: If there's a network error.
426
+ """
427
+ cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/ecitmatch.cgi"
428
+ variables = _update_ecitmatch_variables(keywds)
429
+ request = _build_request(cgi, variables, ecitmatch=True)
430
+ return _open(request)
431
+
432
+
433
+ def read(source, validate=True, escape=False, ignore_errors=False):
434
+ """Parse an XML file from the NCBI Entrez Utilities into python objects.
435
+
436
+ This function parses an XML file created by NCBI's Entrez Utilities,
437
+ returning a multilevel data structure of Python lists and dictionaries.
438
+ Most XML files returned by NCBI's Entrez Utilities can be parsed by
439
+ this function, provided its DTD is available. Biopython includes the
440
+ DTDs for most commonly used Entrez Utilities.
441
+
442
+ The argument ``source`` must be a file or file-like object opened in binary
443
+ mode, or a filename. The parser detects the encoding from the XML file, and
444
+ uses it to convert all text in the XML to the correct Unicode string. The
445
+ functions in Bio.Entrez to access NCBI Entrez will automatically return XML
446
+ data in binary mode. For files, use mode "rb" when opening the file, as in
447
+
448
+ >>> from Bio import Entrez
449
+ >>> path = "Entrez/esearch1.xml"
450
+ >>> stream = open(path, "rb") # opened in binary mode
451
+ >>> record = Entrez.read(stream)
452
+ >>> print(record['QueryTranslation'])
453
+ "biopython"[All Fields]
454
+ >>> stream.close()
455
+
456
+ Alternatively, you can use the filename directly, as in
457
+
458
+ >>> record = Entrez.read(path)
459
+ >>> print(record['QueryTranslation'])
460
+ "biopython"[All Fields]
461
+
462
+ which is safer, as the file stream will automatically be closed after the
463
+ record has been read, or if an error occurs.
464
+
465
+ If validate is True (default), the parser will validate the XML file
466
+ against the DTD, and raise an error if the XML file contains tags that
467
+ are not represented in the DTD. If validate is False, the parser will
468
+ simply skip such tags.
469
+
470
+ If escape is True, all characters that are not valid HTML are replaced
471
+ by HTML escape characters to guarantee that the returned strings are
472
+ valid HTML fragments. For example, a less-than sign (<) is replaced by
473
+ &lt;. If escape is False (default), the string is returned as is.
474
+
475
+ If ignore_errors is False (default), any error messages in the XML file
476
+ will raise a RuntimeError. If ignore_errors is True, error messages will
477
+ be stored as ErrorElement items, without raising an exception.
478
+
479
+ Whereas the data structure seems to consist of generic Python lists,
480
+ dictionaries, strings, and so on, each of these is actually a class
481
+ derived from the base type. This allows us to store the attributes
482
+ (if any) of each element in a dictionary my_element.attributes, and
483
+ the tag name in my_element.tag.
484
+ """
485
+ from .Parser import DataHandler
486
+
487
+ handler = DataHandler(validate, escape, ignore_errors)
488
+ record = handler.read(source)
489
+ return record
490
+
491
+
492
+ def parse(source, validate=True, escape=False, ignore_errors=False):
493
+ """Parse an XML file from the NCBI Entrez Utilities into python objects.
494
+
495
+ This function parses an XML file created by NCBI's Entrez Utilities,
496
+ returning a multilevel data structure of Python lists and dictionaries.
497
+ This function is suitable for XML files that (in Python) can be represented
498
+ as a list of individual records. Whereas 'read' reads the complete file
499
+ and returns a single Python list, 'parse' is a generator function that
500
+ returns the records one by one. This function is therefore particularly
501
+ useful for parsing large files.
502
+
503
+ Most XML files returned by NCBI's Entrez Utilities can be parsed by
504
+ this function, provided its DTD is available. Biopython includes the
505
+ DTDs for most commonly used Entrez Utilities.
506
+
507
+ The argument ``source`` must be a file or file-like object opened in binary
508
+ mode, or a filename. The parser detects the encoding from the XML file, and
509
+ uses it to convert all text in the XML to the correct Unicode string. The
510
+ functions in Bio.Entrez to access NCBI Entrez will automatically return XML
511
+ data in binary mode. For files, use mode "rb" when opening the file, as in
512
+
513
+ >>> from Bio import Entrez
514
+ >>> path = "Entrez/taxonomy.xml"
515
+ >>> stream = open(path, "rb") # opened in binary mode
516
+ >>> records = Entrez.parse(stream)
517
+ >>> for record in records:
518
+ ... print(record['TaxId'], record["OtherNames"]['GenbankCommonName'])
519
+ ...
520
+ 9615 dog
521
+ 9685 domestic cat
522
+ >>> stream.close()
523
+
524
+ Alternatively, you can use the filename directly, as in
525
+
526
+ >>> records = Entrez.parse(path)
527
+ >>> for record in records:
528
+ ... print(record['TaxId'], record["OtherNames"]['GenbankCommonName'])
529
+ ...
530
+ 9615 dog
531
+ 9685 domestic cat
532
+
533
+ which is safer, as the file stream will automatically be closed after all
534
+ the records have been read, or if an error occurs.
535
+
536
+ If validate is True (default), the parser will validate the XML file
537
+ against the DTD, and raise an error if the XML file contains tags that
538
+ are not represented in the DTD. If validate is False, the parser will
539
+ simply skip such tags.
540
+
541
+ If escape is True, all characters that are not valid HTML are replaced
542
+ by HTML escape characters to guarantee that the returned strings are
543
+ valid HTML fragments. For example, a less-than sign (<) is replaced by
544
+ &lt;. If escape is False (default), the string is returned as is.
545
+
546
+ If ignore_errors is False (default), any error messages in the XML file
547
+ will raise a RuntimeError. If ignore_errors is True, error messages will
548
+ be stored as ErrorElement items, without raising an exception.
549
+
550
+ Whereas the data structure seems to consist of generic Python lists,
551
+ dictionaries, strings, and so on, each of these is actually a class
552
+ derived from the base type. This allows us to store the attributes
553
+ (if any) of each element in a dictionary my_element.attributes, and
554
+ the tag name in my_element.tag.
555
+ """
556
+ from .Parser import DataHandler
557
+
558
+ handler = DataHandler(validate, escape, ignore_errors)
559
+ records = handler.parse(source)
560
+ return records
561
+
562
+
563
+ @function_with_previous
564
+ def _open(request):
565
+ """Make an HTTP request to Entrez, handling errors and enforcing rate limiting (PRIVATE).
566
+
567
+ Does some simple error checking and will try again after certain types of errors, up to
568
+ ``max_retries`` times. This function also enforces the "up to three queries per second
569
+ rule" to avoid abusing the NCBI servers (this limit is increased to 10 if using an API key).
570
+
571
+ :param req_or_cgi: A Request object returned by ``_build_request``.
572
+ :type req_or_cgi: urllib.request.Request
573
+ :returns: Handle to HTTP response as returned by ``urllib.request.urlopen``. Will be wrapped in
574
+ an ``io.TextIOWrapper`` if its content type is plain text.
575
+ :rtype: http.client.HTTPResponse or io.TextIOWrapper
576
+ :raises urllib.error.URLError: Errors raised by ``urlopen`` past the maximum number of retries.
577
+ """
578
+ # NCBI requirement: At most three queries per second if no API key is provided.
579
+ # Equivalently, at least a third of second between queries
580
+ # Using just 0.333333334 seconds sometimes hit the NCBI rate limit,
581
+ # the slightly longer pause of 0.37 seconds has been more reliable.
582
+ delay = 0.1 if _has_api_key(request) else 0.37
583
+ current = time.time()
584
+ wait = _open.previous + delay - current
585
+ if wait > 0:
586
+ time.sleep(wait)
587
+ _open.previous = current + wait
588
+ else:
589
+ _open.previous = current
590
+
591
+ for i in range(max_tries):
592
+ try:
593
+ handle = urlopen(request)
594
+ except HTTPError as exception:
595
+ # Reraise if the final try fails
596
+ if i >= max_tries - 1:
597
+ raise
598
+ # Reraise if the exception is triggered by a HTTP 4XX error
599
+ # indicating some kind of bad request, UNLESS it's specifically a
600
+ # 429 "Too Many Requests" response. NCBI seems to sometimes
601
+ # erroneously return 429s even when their rate limit is
602
+ # honored (and indeed even with the rate-limit-related fudging
603
+ # higher up in this function in place), so the best we can do is
604
+ # treat them as a serverside error and try again after sleeping
605
+ # for a bit.
606
+ if exception.code // 100 == 4 and exception.code != 429:
607
+ raise
608
+ except URLError:
609
+ # Reraise if the final try fails
610
+ if i >= max_tries - 1:
611
+ raise
612
+ # Treat as a transient error and try again after a brief delay:
613
+ time.sleep(sleep_between_tries)
614
+ else:
615
+ break
616
+
617
+ subtype = handle.headers.get_content_subtype()
618
+ if subtype == "plain":
619
+ url = handle.url
620
+ handle = io.TextIOWrapper(handle, encoding="UTF-8")
621
+ handle.url = url
622
+ return handle
623
+
624
+
625
+ _open.previous = 0
626
+
627
+
628
+ def _build_request(cgi, params=None, post=None, ecitmatch=False, join_ids=True):
629
+ """Build a Request object for an E-utility.
630
+
631
+ :param str cgi: base URL for the CGI script to access.
632
+ :param params: Mapping containing options to pass to the CGI script. Keys must be strings.
633
+ :type params: dict or None
634
+ :param bool post: Whether to use the HTTP POST method rather than GET. By default (``post=None``),
635
+ POST is used if the URL encoded parameters would be over 1000 characters long, as is
636
+ suggested in the E-Utilities documentation.
637
+ :param bool ecitmatch: Don't URL-encode pipe ("|") characters, this is expected by the ecitmatch
638
+ tool.
639
+ :param bool join_ids: Passed to ``_construct_params``.
640
+ :returns: A request object ready to be passed to ``_open``.
641
+ :rtype: urllib.request.Request
642
+ """
643
+ params = _construct_params(params, join_ids=join_ids)
644
+
645
+ params_str = urlencode(params, doseq=True)
646
+ if ecitmatch:
647
+ params_str = params_str.replace("%7C", "|")
648
+
649
+ # By default, post is None. Set to a boolean to over-ride length choice:
650
+ if post is None and len(params_str) > 1000:
651
+ post = True
652
+
653
+ # NCBI prefers an HTTP POST instead of an HTTP GET if there are more than about 200 IDs
654
+ if post is None and "id" in params:
655
+ idcount = params["id"].count(",") + 1
656
+ if idcount >= 200:
657
+ post = True
658
+
659
+ if post:
660
+ return Request(cgi, data=params_str.encode("utf8"), method="POST")
661
+ else:
662
+ return Request(cgi + "?" + params_str, method="GET")
663
+
664
+
665
+ def _construct_params(params, join_ids=True):
666
+ """Construct/format parameter dict for an Entrez request.
667
+
668
+ :param params: User-supplied parameters.
669
+ :type params: dict or None
670
+ :param bool join_ids: If True and the "id" key of ``params`` is a list
671
+ containing multiple UIDs, join them into a single comma-delimited string.
672
+ :returns: Parameters with defaults added and keys with None values removed.
673
+ :rtype: dict
674
+ """
675
+ if params is None:
676
+ params = {}
677
+
678
+ # Tell Entrez that we are using Biopython (or whatever the user has
679
+ # specified explicitly in the parameters or by changing the default)
680
+ params.setdefault("tool", tool)
681
+
682
+ # Tell Entrez who we are
683
+ params.setdefault("email", email)
684
+ params.setdefault("api_key", api_key)
685
+
686
+ # Remove None values from the parameters
687
+ for key, value in list(params.items()):
688
+ if value is None:
689
+ del params[key]
690
+
691
+ # Warn if email not set
692
+ if "email" not in params:
693
+ warnings.warn(
694
+ """
695
+ Email address is not specified.
696
+
697
+ To make use of NCBI's E-utilities, NCBI requires you to specify your
698
+ email address with each request. As an example, if your email address
699
+ is A.N.Other@example.com, you can specify it as follows:
700
+ from Bio import Entrez
701
+ Entrez.email = 'A.N.Other@example.com'
702
+ In case of excessive usage of the E-utilities, NCBI will attempt to contact
703
+ a user at the email address provided before blocking access to the
704
+ E-utilities.""",
705
+ UserWarning,
706
+ )
707
+
708
+ # Format "id" parameter properly
709
+ if join_ids and "id" in params:
710
+ params["id"] = _format_ids(params["id"])
711
+
712
+ return params
713
+
714
+
715
+ def _format_ids(ids):
716
+ """Convert one or more UIDs to a single comma-delimited string.
717
+
718
+ Input may be a single ID as an integer or string, an iterable of strings/ints,
719
+ or a string of IDs already separated by commas.
720
+ """
721
+ if isinstance(ids, int):
722
+ # Single integer, just convert to str
723
+ return str(ids)
724
+
725
+ if isinstance(ids, str):
726
+ # String which represents one or more IDs joined by commas
727
+ # Remove any whitespace around commas if they are present
728
+ return ",".join(id.strip() for id in ids.split(","))
729
+
730
+ # Not a string or integer, assume iterable
731
+ return ",".join(map(str, ids))
732
+
733
+
734
+ def _has_api_key(request):
735
+ """Check if a Request has the api_key parameter set, to set the rate limit.
736
+
737
+ Works with GET or POST requests.
738
+ """
739
+ if request.method == "POST":
740
+ return b"api_key=" in request.data
741
+ return "api_key=" in request.full_url
742
+
743
+
744
+ if __name__ == "__main__":
745
+ from Bio._utils import run_doctest
746
+
747
+ run_doctest()
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._Enzyme.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._Prodoc.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._Prosite.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._ScanProsite.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/.___init__.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/.___pycache__ ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/._cellosaurus.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/Enzyme.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 1999 by Jeffrey Chang. All rights reserved.
2
+ # Copyright 2009 by Michiel de Hoon. All rights reserved.
3
+ # This code is part of the Biopython distribution and governed by its
4
+ # license. Please see the LICENSE file that should have been included
5
+ # as part of this package.
6
+
7
+ """Parse the enzyme.dat file from Enzyme at ExPASy.
8
+
9
+ See https://www.expasy.org/enzyme/
10
+
11
+ Tested with the release of 03-Mar-2009.
12
+
13
+ Functions:
14
+ - read Reads a file containing one ENZYME entry
15
+ - parse Reads a file containing multiple ENZYME entries
16
+
17
+ Classes:
18
+ - Record Holds ENZYME data.
19
+
20
+ """
21
+
22
+
23
+ def parse(handle):
24
+ """Parse ENZYME records.
25
+
26
+ This function is for parsing ENZYME files containing multiple
27
+ records.
28
+
29
+ Arguments:
30
+ - handle - handle to the file.
31
+
32
+ """
33
+ while True:
34
+ record = __read(handle)
35
+ if not record:
36
+ break
37
+ yield record
38
+
39
+
40
+ def read(handle):
41
+ """Read one ENZYME record.
42
+
43
+ This function is for parsing ENZYME files containing
44
+ exactly one record.
45
+
46
+ Arguments:
47
+ - handle - handle to the file.
48
+
49
+ """
50
+ record = __read(handle)
51
+ # We should have reached the end of the record by now
52
+ remainder = handle.read()
53
+ if remainder:
54
+ raise ValueError("More than one ENZYME record found")
55
+ return record
56
+
57
+
58
+ class Record(dict):
59
+ """Holds information from an ExPASy ENZYME record as a Python dictionary.
60
+
61
+ Each record contains the following keys:
62
+
63
+ - ID: EC number
64
+ - DE: Recommended name
65
+ - AN: Alternative names (if any)
66
+ - CA: Catalytic activity
67
+ - CF: Cofactors (if any)
68
+ - PR: Pointers to any Prosite documentation entries that correspond to the
69
+ enzyme
70
+ - DR: Pointers to any Swiss-Prot protein sequence entries that correspond
71
+ to the enzyme
72
+ - CC: Comments
73
+
74
+ """
75
+
76
+ def __init__(self):
77
+ """Initialize the class."""
78
+ dict.__init__(self)
79
+ self["ID"] = ""
80
+ self["DE"] = ""
81
+ self["AN"] = []
82
+ self["CA"] = ""
83
+ self["CF"] = ""
84
+ self["CC"] = [] # one comment per line
85
+ self["PR"] = []
86
+ self["DR"] = []
87
+
88
+ def __repr__(self):
89
+ """Return the canonical string representation of the Record object."""
90
+ if self["ID"]:
91
+ if self["DE"]:
92
+ return f"{self.__class__.__name__} ({self['ID']}, {self['DE']})"
93
+ else:
94
+ return f"{self.__class__.__name__} ({self['ID']})"
95
+ else:
96
+ return f"{self.__class__.__name__} ( )"
97
+
98
+ def __str__(self):
99
+ """Return a readable string representation of the Record object."""
100
+ output = [
101
+ "ID: " + self["ID"],
102
+ "DE: " + self["DE"],
103
+ "AN: " + repr(self["AN"]),
104
+ "CA: '" + self["CA"] + "'",
105
+ "CF: " + self["CF"],
106
+ "CC: " + repr(self["CC"]),
107
+ "PR: " + repr(self["PR"]),
108
+ "DR: %d Records" % len(self["DR"]),
109
+ ]
110
+ return "\n".join(output)
111
+
112
+
113
+ # Everything below is private
114
+
115
+
116
+ def __read(handle):
117
+ record = None
118
+ for line in handle:
119
+ key, value = line[:2], line[5:].rstrip()
120
+ if key == "ID":
121
+ record = Record()
122
+ record["ID"] = value
123
+ elif key == "DE":
124
+ record["DE"] += value
125
+ elif key == "AN":
126
+ if record["AN"] and not record["AN"][-1].endswith("."):
127
+ record["AN"][-1] += " " + value
128
+ else:
129
+ record["AN"].append(value)
130
+ elif key == "CA":
131
+ record["CA"] += value
132
+ elif key == "DR":
133
+ pair_data = value.rstrip(";").split(";")
134
+ for pair in pair_data:
135
+ t1, t2 = pair.split(",")
136
+ row = [t1.strip(), t2.strip()]
137
+ record["DR"].append(row)
138
+ elif key == "CF":
139
+ if record["CF"]:
140
+ record["CF"] += " " + value
141
+ else:
142
+ record["CF"] = value
143
+ elif key == "PR":
144
+ assert value.startswith("PROSITE; ")
145
+ value = value[9:].rstrip(";")
146
+ record["PR"].append(value)
147
+ elif key == "CC":
148
+ if value.startswith("-!- "):
149
+ record["CC"].append(value[4:])
150
+ elif value.startswith(" ") and record["CC"]:
151
+ record["CC"][-1] += value[3:]
152
+ # copyright notice is silently skipped
153
+ elif key == "//":
154
+ if record:
155
+ return record
156
+ else: # This was the copyright notice
157
+ continue
158
+ if record:
159
+ raise ValueError("Unexpected end of stream")
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/Prodoc.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2000 by Jeffrey Chang. All rights reserved.
2
+ # This code is part of the Biopython distribution and governed by its
3
+ # license. Please see the LICENSE file that should have been included
4
+ # as part of this package.
5
+
6
+ """Code to work with the prosite.doc file from Prosite.
7
+
8
+ See https://www.expasy.org/prosite/
9
+
10
+ Tested with:
11
+ - Release 15.0, July 1998
12
+ - Release 16.0, July 1999
13
+ - Release 20.22, 13 November 2007
14
+ - Release 20.43, 10 February 2009
15
+
16
+ Functions:
17
+ - read Read a Prodoc file containing exactly one Prodoc entry.
18
+ - parse Iterates over entries in a Prodoc file.
19
+
20
+ Classes:
21
+ - Record Holds Prodoc data.
22
+ - Reference Holds data from a Prodoc reference.
23
+
24
+ """
25
+
26
+
27
+ def read(handle):
28
+ """Read in a record from a file with exactly one Prodoc record."""
29
+ record = __read(handle)
30
+ # We should have reached the end of the record by now
31
+ line = handle.readline()
32
+ if line:
33
+ raise ValueError("More than one Prodoc record found")
34
+ return record
35
+
36
+
37
+ def parse(handle):
38
+ """Iterate over the records in a Prodoc file."""
39
+ while True:
40
+ record = __read(handle)
41
+ if not record:
42
+ return
43
+ yield record
44
+
45
+
46
+ class Record:
47
+ """Holds information from a Prodoc record.
48
+
49
+ Attributes:
50
+ - accession Accession number of the record.
51
+ - prosite_refs List of tuples (prosite accession, prosite name).
52
+ - text Free format text.
53
+ - references List of reference objects.
54
+
55
+ """
56
+
57
+ def __init__(self):
58
+ """Initialize the class."""
59
+ self.accession = ""
60
+ self.prosite_refs = []
61
+ self.text = ""
62
+ self.references = []
63
+
64
+
65
+ class Reference:
66
+ """Holds information from a Prodoc citation.
67
+
68
+ Attributes:
69
+ - number Number of the reference. (string)
70
+ - authors Names of the authors.
71
+ - citation Describes the citation.
72
+
73
+ """
74
+
75
+ def __init__(self):
76
+ """Initialize the class."""
77
+ self.number = ""
78
+ self.authors = ""
79
+ self.citation = ""
80
+
81
+
82
+ # Below are private functions
83
+
84
+
85
+ def __read_prosite_reference_line(record, line):
86
+ line = line.rstrip()
87
+ if line[-1] != "}":
88
+ raise ValueError(f"I don't understand the Prosite reference on line\n{line}")
89
+ acc, name = line[1:-1].split("; ")
90
+ record.prosite_refs.append((acc, name))
91
+
92
+
93
+ def __read_text_line(record, line):
94
+ record.text += line
95
+ return True
96
+
97
+
98
+ def __read_reference_start(record, line):
99
+ # Read the references
100
+ reference = Reference()
101
+ reference.number = line[1:3].strip()
102
+ if line[1] == "E":
103
+ # If it's an electronic reference, then the URL is on the
104
+ # line, instead of the author.
105
+ reference.citation = line[4:].strip()
106
+ else:
107
+ reference.authors = line[4:].strip()
108
+ record.references.append(reference)
109
+
110
+
111
+ def __read_reference_line(record, line):
112
+ if not line.strip():
113
+ return False
114
+ reference = record.references[-1]
115
+ if line.startswith(" "):
116
+ if reference.authors[-1] == ",":
117
+ reference.authors += line[4:].rstrip()
118
+ else:
119
+ reference.citation += line[5:]
120
+ return True
121
+ raise Exception(f"I don't understand the reference line\n{line}")
122
+
123
+
124
+ def __read_copyright_line(record, line):
125
+ # Skip the copyright statement
126
+ if line.startswith("+----"):
127
+ return False
128
+ return True
129
+
130
+
131
+ def __read(handle):
132
+ # Skip blank lines between records
133
+ for line in handle:
134
+ line = line.rstrip()
135
+ if line and not line.startswith("//"):
136
+ break
137
+ else:
138
+ return None
139
+ record = Record()
140
+ # Read the accession number
141
+ if not line.startswith("{PDOC"):
142
+ raise ValueError("Line does not start with '{PDOC':\n%s" % line)
143
+ if line[-1] != "}":
144
+ raise ValueError(f"I don't understand accession line\n{line}")
145
+ record.accession = line[1:-1]
146
+ # Read the Prosite references
147
+ for line in handle:
148
+ if line.startswith("{PS"):
149
+ __read_prosite_reference_line(record, line)
150
+ else:
151
+ break
152
+ else:
153
+ raise ValueError("Unexpected end of stream.")
154
+ # Read the actual text
155
+ if not line.startswith("{BEGIN"):
156
+ raise ValueError("Line does not start with '{BEGIN':\n%s" % line)
157
+ read_line = __read_text_line
158
+ for line in handle:
159
+ if line.startswith("{END}"):
160
+ # Clean up the record and return
161
+ for reference in record.references:
162
+ reference.citation = reference.citation.rstrip()
163
+ reference.authors = reference.authors.rstrip()
164
+ return record
165
+ elif line[0] == "[" and line[3] == "]" and line[4] == " ":
166
+ __read_reference_start(record, line)
167
+ read_line = __read_reference_line
168
+ elif line.startswith("+----"):
169
+ read_line = __read_copyright_line
170
+ elif read_line:
171
+ if not read_line(record, line):
172
+ read_line = None
173
+ raise ValueError("Unexpected end of stream.")
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/Prosite.py ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 1999 by Jeffrey Chang. All rights reserved.
2
+ # Copyright 2000 by Jeffrey Chang. All rights reserved.
3
+ # Revisions Copyright 2007 by Peter Cock. All rights reserved.
4
+ # Revisions Copyright 2009 by Michiel de Hoon. All rights reserved.
5
+ # This code is part of the Biopython distribution and governed by its
6
+ # license. Please see the LICENSE file that should have been included
7
+ # as part of this package.
8
+ """Parser for the prosite dat file from Prosite at ExPASy.
9
+
10
+ See https://www.expasy.org/prosite/
11
+
12
+ Tested with:
13
+ - Release 20.43, 10-Feb-2009
14
+ - Release 2017_03 of 15-Mar-2017.
15
+
16
+ Functions:
17
+ - read Reads a Prosite file containing one Prosite record
18
+ - parse Iterates over records in a Prosite file.
19
+
20
+ Classes:
21
+ - Record Holds Prosite data.
22
+
23
+ """
24
+
25
+
26
+ def parse(handle):
27
+ """Parse Prosite records.
28
+
29
+ This function is for parsing Prosite files containing multiple
30
+ records.
31
+
32
+ Arguments:
33
+ - handle - handle to the file.
34
+
35
+ """
36
+ while True:
37
+ record = __read(handle)
38
+ if not record:
39
+ break
40
+ yield record
41
+
42
+
43
+ def read(handle):
44
+ """Read one Prosite record.
45
+
46
+ This function is for parsing Prosite files containing
47
+ exactly one record.
48
+
49
+ Arguments:
50
+ - handle - handle to the file.
51
+
52
+ """
53
+ record = __read(handle)
54
+ # We should have reached the end of the record by now
55
+ remainder = handle.read()
56
+ if remainder:
57
+ raise ValueError("More than one Prosite record found")
58
+ return record
59
+
60
+
61
+ class Record:
62
+ """Holds information from a Prosite record.
63
+
64
+ Main attributes:
65
+ - name ID of the record. e.g. ADH_ZINC
66
+ - type Type of entry. e.g. PATTERN, MATRIX, or RULE
67
+ - accession e.g. PS00387
68
+ - created Date the entry was created. (MMM-YYYY for releases
69
+ before January 2017, DD-MMM-YYYY since January 2017)
70
+ - data_update Date the 'primary' data was last updated.
71
+ - info_update Date data other than 'primary' data was last updated.
72
+ - pdoc ID of the PROSITE DOCumentation.
73
+ - description Free-format description.
74
+ - pattern The PROSITE pattern. See docs.
75
+ - matrix List of strings that describes a matrix entry.
76
+ - rules List of rule definitions (from RU lines). (strings)
77
+ - prorules List of prorules (from PR lines). (strings)
78
+
79
+ NUMERICAL RESULTS:
80
+ - nr_sp_release SwissProt release.
81
+ - nr_sp_seqs Number of seqs in that release of Swiss-Prot. (int)
82
+ - nr_total Number of hits in Swiss-Prot. tuple of (hits, seqs)
83
+ - nr_positive True positives. tuple of (hits, seqs)
84
+ - nr_unknown Could be positives. tuple of (hits, seqs)
85
+ - nr_false_pos False positives. tuple of (hits, seqs)
86
+ - nr_false_neg False negatives. (int)
87
+ - nr_partial False negatives, because they are fragments. (int)
88
+
89
+ COMMENTS:
90
+ - cc_taxo_range Taxonomic range. See docs for format
91
+ - cc_max_repeat Maximum number of repetitions in a protein
92
+ - cc_site Interesting site. list of tuples (pattern pos, desc.)
93
+ - cc_skip_flag Can this entry be ignored?
94
+ - cc_matrix_type
95
+ - cc_scaling_db
96
+ - cc_author
97
+ - cc_ft_key
98
+ - cc_ft_desc
99
+ - cc_version version number (introduced in release 19.0)
100
+
101
+ The following are all lists if tuples (swiss-prot accession, swiss-prot name).
102
+
103
+ DATA BANK REFERENCES:
104
+ - dr_positive
105
+ - dr_false_neg
106
+ - dr_false_pos
107
+ - dr_potential Potential hits, but fingerprint region not yet available.
108
+ - dr_unknown Could possibly belong
109
+ - pdb_structs List of PDB entries.
110
+
111
+ """
112
+
113
+ def __init__(self):
114
+ """Initialize the class."""
115
+ self.name = ""
116
+ self.type = ""
117
+ self.accession = ""
118
+ self.created = ""
119
+ self.data_update = ""
120
+ self.info_update = ""
121
+ self.pdoc = ""
122
+
123
+ self.description = ""
124
+ self.pattern = ""
125
+ self.matrix = []
126
+ self.rules = []
127
+ self.prorules = []
128
+ self.postprocessing = []
129
+
130
+ self.nr_sp_release = ""
131
+ self.nr_sp_seqs = ""
132
+ self.nr_total = (None, None)
133
+ self.nr_positive = (None, None)
134
+ self.nr_unknown = (None, None)
135
+ self.nr_false_pos = (None, None)
136
+ self.nr_false_neg = None
137
+ self.nr_partial = None
138
+
139
+ self.cc_taxo_range = ""
140
+ self.cc_max_repeat = ""
141
+ self.cc_site = []
142
+ self.cc_skip_flag = ""
143
+
144
+ self.dr_positive = []
145
+ self.dr_false_neg = []
146
+ self.dr_false_pos = []
147
+ self.dr_potential = []
148
+ self.dr_unknown = []
149
+
150
+ self.pdb_structs = []
151
+
152
+
153
+ # Everything below are private functions
154
+
155
+
156
+ def __read(handle):
157
+ import re
158
+
159
+ record = None
160
+ for line in handle:
161
+ keyword, value = line[:2], line[5:].rstrip()
162
+ if keyword == "ID":
163
+ record = Record()
164
+ cols = value.split("; ")
165
+ if len(cols) != 2:
166
+ raise ValueError(f"I don't understand identification line\n{line}")
167
+ record.name = cols[0]
168
+ record.type = cols[1].rstrip(".") # don't want '.'
169
+ elif keyword == "AC":
170
+ record.accession = value.rstrip(";")
171
+ elif keyword == "DT":
172
+ # e.g. from January 2017,
173
+ # DT 01-APR-1990 CREATED; 01-APR-1990 DATA UPDATE; 01-APR-1990 INFO UPDATE.
174
+ # Older files had brackets round the date descriptions and used MMM-YYYY
175
+ dates = value.rstrip(".").split("; ")
176
+ if dates[0].endswith((" (CREATED)", " CREATED")):
177
+ # Remove last word
178
+ record.created = dates[0].rsplit(" ", 1)[0]
179
+ else:
180
+ raise ValueError(f"I don't understand date line\n{line}")
181
+ if dates[1].endswith((" (DATA UPDATE)", " DATA UPDATE")):
182
+ # Remove last two words
183
+ record.data_update = dates[1].rsplit(" ", 2)[0]
184
+ else:
185
+ raise ValueError(f"I don't understand date line\n{line}")
186
+ if dates[2].endswith((" (INFO UPDATE)", " INFO UPDATE")):
187
+ # Remove last two words
188
+ record.info_update = dates[2].rsplit(" ", 2)[0]
189
+ else:
190
+ raise ValueError(f"I don't understand date line\n{line}")
191
+ elif keyword == "DE":
192
+ record.description = value
193
+ elif keyword == "PA":
194
+ record.pattern += value
195
+ elif keyword == "MA":
196
+ record.matrix.append(value)
197
+ elif keyword == "PP":
198
+ record.postprocessing.extend(value.split(";"))
199
+ elif keyword == "RU":
200
+ record.rules.append(value)
201
+ elif keyword == "NR":
202
+ cols = value.split(";")
203
+ for col in cols:
204
+ if not col:
205
+ continue
206
+ qual, data = (word.lstrip() for word in col.split("="))
207
+ if qual == "/RELEASE":
208
+ release, seqs = data.split(",")
209
+ record.nr_sp_release = release
210
+ record.nr_sp_seqs = int(seqs)
211
+ elif qual == "/FALSE_NEG":
212
+ record.nr_false_neg = int(data)
213
+ elif qual == "/PARTIAL":
214
+ record.nr_partial = int(data)
215
+ elif qual in ["/TOTAL", "/POSITIVE", "/UNKNOWN", "/FALSE_POS"]:
216
+ m = re.match(r"(\d+)\((\d+)\)", data)
217
+ if not m:
218
+ raise Exception(f"Broken data {data} in comment line\n{line!r}")
219
+ hits = tuple(map(int, m.groups()))
220
+ if qual == "/TOTAL":
221
+ record.nr_total = hits
222
+ elif qual == "/POSITIVE":
223
+ record.nr_positive = hits
224
+ elif qual == "/UNKNOWN":
225
+ record.nr_unknown = hits
226
+ elif qual == "/FALSE_POS":
227
+ record.nr_false_pos = hits
228
+ else:
229
+ raise ValueError(f"Unknown qual {qual} in comment line\n{line!r}")
230
+ elif keyword == "CC":
231
+ # Expect CC lines like this:
232
+ # CC /TAXO-RANGE=??EPV; /MAX-REPEAT=2;
233
+ # Can (normally) split on ";" and then on "="
234
+ cols = value.split(";")
235
+ for col in cols:
236
+ if not col or col[:17] == "Automatic scaling":
237
+ # DNAJ_2 in Release 15 has a non-standard comment line:
238
+ # CC Automatic scaling using reversed database
239
+ # Throw it away. (Should I keep it?)
240
+ continue
241
+ if col.count("=") == 0:
242
+ # Missing qualifier! Can we recover gracefully?
243
+ # For example, from Bug 2403, in PS50293 have:
244
+ # CC /AUTHOR=K_Hofmann; N_Hulo
245
+ continue
246
+ qual, data = (word.lstrip() for word in col.split("="))
247
+ if qual == "/TAXO-RANGE":
248
+ record.cc_taxo_range = data
249
+ elif qual == "/MAX-REPEAT":
250
+ record.cc_max_repeat = data
251
+ elif qual == "/SITE":
252
+ pos, desc = data.split(",")
253
+ record.cc_site.append((int(pos), desc))
254
+ elif qual == "/SKIP-FLAG":
255
+ record.cc_skip_flag = data
256
+ elif qual == "/MATRIX_TYPE":
257
+ record.cc_matrix_type = data
258
+ elif qual == "/SCALING_DB":
259
+ record.cc_scaling_db = data
260
+ elif qual == "/AUTHOR":
261
+ record.cc_author = data
262
+ elif qual == "/FT_KEY":
263
+ record.cc_ft_key = data
264
+ elif qual == "/FT_DESC":
265
+ record.cc_ft_desc = data
266
+ elif qual == "/VERSION":
267
+ record.cc_version = data
268
+ else:
269
+ raise ValueError(f"Unknown qual {qual} in comment line\n{line!r}")
270
+ elif keyword == "DR":
271
+ refs = value.split(";")
272
+ for ref in refs:
273
+ if not ref:
274
+ continue
275
+ acc, name, type = (word.strip() for word in ref.split(","))
276
+ if type == "T":
277
+ record.dr_positive.append((acc, name))
278
+ elif type == "F":
279
+ record.dr_false_pos.append((acc, name))
280
+ elif type == "N":
281
+ record.dr_false_neg.append((acc, name))
282
+ elif type == "P":
283
+ record.dr_potential.append((acc, name))
284
+ elif type == "?":
285
+ record.dr_unknown.append((acc, name))
286
+ else:
287
+ raise ValueError(f"I don't understand type flag {type}")
288
+ elif keyword == "3D":
289
+ cols = value.split()
290
+ for id in cols:
291
+ record.pdb_structs.append(id.rstrip(";"))
292
+ elif keyword == "PR":
293
+ rules = value.split(";")
294
+ record.prorules.extend(rules)
295
+ elif keyword == "DO":
296
+ record.pdoc = value.rstrip(";")
297
+ elif keyword == "//":
298
+ if not record:
299
+ # Then this was the copyright statement
300
+ continue
301
+ break
302
+ else:
303
+ raise ValueError(f"Unknown keyword {keyword} found")
304
+ else:
305
+ return
306
+ if not record:
307
+ raise ValueError("Unexpected end of stream.")
308
+ return record
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/ScanProsite.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2009 by Michiel de Hoon. All rights reserved.
2
+ # This code is part of the Biopython distribution and governed by its
3
+ # license. Please see the LICENSE file that should have been included
4
+ # as part of this package.
5
+
6
+ """Code for calling and parsing ScanProsite from ExPASy."""
7
+
8
+ from urllib.parse import urlencode
9
+ from urllib.request import urlopen
10
+ from xml.sax import handler
11
+ from xml.sax.expatreader import ExpatParser
12
+
13
+ # October 28th 2020 it was recognised that between October 10th 2020 and October
14
+ # 28th the main url of prosite changed from https://www.expasy.org to
15
+ # https://prosite.expasy.org. Thus a change in the mirror was issued from
16
+ # https://www.expasy.org to https://prosite.expasy.org.
17
+ PROSITE_URL = "https://prosite.expasy.org"
18
+
19
+
20
+ class Record(list):
21
+ """Represents search results returned by ScanProsite.
22
+
23
+ This record is a list containing the search results returned by
24
+ ScanProsite. The record also contains the data members n_match,
25
+ n_seq, capped, and warning.
26
+ """
27
+
28
+ def __init__(self):
29
+ """Initialize the class."""
30
+ self.n_match = None
31
+ self.n_seq = None
32
+ self.capped = None
33
+ self.warning = None
34
+
35
+
36
+ def scan(seq="", mirror=PROSITE_URL, output="xml", **keywords):
37
+ """Execute a ScanProsite search.
38
+
39
+ Arguments:
40
+ - mirror: The ScanProsite mirror to be used
41
+ (default: PROSITE_URL).
42
+ - seq: The query sequence, or UniProtKB (Swiss-Prot,
43
+ TrEMBL) accession
44
+ - output: Format of the search results
45
+ (default: xml)
46
+
47
+ Further search parameters can be passed as keywords; see the
48
+ documentation for programmatic access to ScanProsite at
49
+ https://prosite.expasy.org/scanprosite/scanprosite_doc.html
50
+ for a description of such parameters.
51
+
52
+ This function returns a handle to the search results returned by
53
+ ScanProsite. Search results in the XML format can be parsed into a
54
+ Python object, by using the Bio.ExPASy.ScanProsite.read function.
55
+
56
+ """
57
+ if output != "xml":
58
+ raise NotImplementedError("Only output='xml' is supported currently.")
59
+ parameters = {"seq": seq, "output": output}
60
+ for key, value in keywords.items():
61
+ if value is not None:
62
+ parameters[key] = value
63
+ command = urlencode(parameters)
64
+ url = f"{mirror}/cgi-bin/prosite/scanprosite/PSScan.cgi?{command}"
65
+ handle = urlopen(url)
66
+ return handle
67
+
68
+
69
+ def read(handle):
70
+ """Parse search results returned by ScanProsite into a Python object."""
71
+ content_handler = ContentHandler()
72
+ saxparser = Parser()
73
+ saxparser.setContentHandler(content_handler)
74
+ saxparser.parse(handle)
75
+ record = content_handler.record
76
+ return record
77
+
78
+
79
+ # The classes below are considered private
80
+
81
+
82
+ class Parser(ExpatParser):
83
+ """Process the result from a ScanProsite search (PRIVATE)."""
84
+
85
+ def __init__(self):
86
+ """Initialize the class."""
87
+ ExpatParser.__init__(self)
88
+ self.firsttime = True
89
+
90
+ def feed(self, data, isFinal=0):
91
+ """Raise an Error if plain text is received in the data.
92
+
93
+ This is to show the Error messages returned by ScanProsite.
94
+ """
95
+ # Error messages returned by the ScanProsite server are formatted as
96
+ # as plain text instead of an XML document. To catch such error
97
+ # messages, we override the feed method of the Expat parser.
98
+ # The error message is (hopefully) contained in the data that was just
99
+ # fed to the parser.
100
+ if self.firsttime:
101
+ if data[:22].decode("utf-8") != "<scanprosite_response>":
102
+ raise ValueError(data)
103
+ self.firsttime = False
104
+ return ExpatParser.feed(self, data, isFinal)
105
+
106
+
107
+ class ContentHandler(handler.ContentHandler):
108
+ """Process and fill in the records, results of the search (PRIVATE)."""
109
+
110
+ integers = ("start", "stop")
111
+ strings = (
112
+ "sequence_ac",
113
+ "sequence_id",
114
+ "sequence_db",
115
+ "signature_ac",
116
+ "level",
117
+ "level_tag",
118
+ )
119
+
120
+ def __init__(self):
121
+ """Initialize the class."""
122
+ self.element = []
123
+
124
+ def startElement(self, name, attrs):
125
+ """Define the beginning of a record and stores the search record."""
126
+ self.element.append(name)
127
+ self.content = ""
128
+ if self.element == ["scanprosite_response", "matchset"]:
129
+ self.record = Record()
130
+ self.record.n_match = int(attrs["n_match"])
131
+ self.record.n_seq = int(attrs["n_seq"])
132
+ elif self.element == ["scanprosite_response", "matchset", "match"]:
133
+ match = {}
134
+ self.record.append(match)
135
+
136
+ def endElement(self, name):
137
+ """Define the end of the search record."""
138
+ assert name == self.element.pop()
139
+ if self.element == ["scanprosite_response", "matchset", "match"]:
140
+ match = self.record[-1]
141
+ if name in ContentHandler.integers:
142
+ match[name] = int(self.content)
143
+ elif name in ContentHandler.strings:
144
+ match[name] = self.content
145
+ else:
146
+ # Unknown type, treat it as a string
147
+ match[name] = self.content
148
+
149
+ def characters(self, content):
150
+ """Store the record content."""
151
+ self.content += content
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/__init__.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2000 by Jeffrey Chang. All rights reserved.
2
+ # This code is part of the Biopython distribution and governed by its
3
+ # license. Please see the LICENSE file that should have been included
4
+ # as part of this package.
5
+
6
+ """Code to access resources at ExPASy over the WWW.
7
+
8
+ See https://www.expasy.org/
9
+
10
+
11
+ Functions:
12
+ - get_prodoc_entry Interface to the get-prodoc-entry CGI script.
13
+ - get_prosite_entry Interface to the get-prosite-entry CGI script.
14
+ - get_prosite_raw Interface to the get-prosite-raw CGI script.
15
+ - get_sprot_raw Interface to the get-sprot-raw CGI script.
16
+
17
+ """
18
+
19
+ import io
20
+ from urllib.error import HTTPError
21
+ from urllib.request import urlopen
22
+
23
+
24
+ def get_prodoc_entry(
25
+ id, cgi="https://prosite.expasy.org/cgi-bin/prosite/get-prodoc-entry"
26
+ ):
27
+ """Get a text handle to a PRODOC entry at ExPASy in HTML format.
28
+
29
+ >>> from Bio import ExPASy
30
+ >>> import os
31
+ >>> with ExPASy.get_prodoc_entry('PDOC00001') as in_handle:
32
+ ... html = in_handle.read()
33
+ ...
34
+ >>> with open("myprodocrecord.html", "w") as out_handle:
35
+ ... length = out_handle.write(html)
36
+ ...
37
+ >>> os.remove("myprodocrecord.html") # tidy up
38
+
39
+ For a non-existing key XXX, ExPASy returns an HTML-formatted page
40
+ containing this text: 'There is currently no PROSITE entry for'
41
+ """
42
+ return _open(f"{cgi}?{id}")
43
+
44
+
45
+ def get_prosite_entry(
46
+ id, cgi="https://prosite.expasy.org/cgi-bin/prosite/get-prosite-entry"
47
+ ):
48
+ """Get a text handle to a PROSITE entry at ExPASy in HTML format.
49
+
50
+ >>> from Bio import ExPASy
51
+ >>> import os
52
+ >>> with ExPASy.get_prosite_entry('PS00001') as in_handle:
53
+ ... html = in_handle.read()
54
+ ...
55
+ >>> with open("myprositerecord.html", "w") as out_handle:
56
+ ... length = out_handle.write(html)
57
+ ...
58
+ >>> os.remove("myprositerecord.html") # tidy up
59
+
60
+ For a non-existing key XXX, ExPASy returns an HTML-formatted page
61
+ containing this text: 'There is currently no PROSITE entry for'
62
+ """
63
+ return _open(f"{cgi}?{id}")
64
+
65
+
66
+ def get_prosite_raw(id, cgi=None):
67
+ """Get a text handle to a raw PROSITE or PRODOC record at ExPASy.
68
+
69
+ The cgi argument is deprecated due to changes in the ExPASy
70
+ website.
71
+
72
+ >>> from Bio import ExPASy
73
+ >>> from Bio.ExPASy import Prosite
74
+ >>> with ExPASy.get_prosite_raw('PS00001') as handle:
75
+ ... record = Prosite.read(handle)
76
+ ...
77
+ >>> print(record.accession)
78
+ PS00001
79
+
80
+ This function raises a ValueError if the identifier does not exist:
81
+
82
+ >>> handle = ExPASy.get_prosite_raw("DOES_NOT_EXIST")
83
+ Traceback (most recent call last):
84
+ ...
85
+ ValueError: Failed to find entry 'DOES_NOT_EXIST' on ExPASy
86
+
87
+ """
88
+ try:
89
+ handle = _open(f"https://prosite.expasy.org/{id}.txt")
90
+ except HTTPError as exception:
91
+ if exception.code == 404:
92
+ raise ValueError("Failed to find entry '%s' on ExPASy" % id) from None
93
+ else:
94
+ raise
95
+ # This has happened historically, redirected to main page:
96
+ if handle.url == "https://www.expasy.org/":
97
+ raise ValueError(f"Failed to find entry '{id}' on ExPASy") from None
98
+ return handle
99
+
100
+
101
+ def get_sprot_raw(id):
102
+ """Get a text handle to a raw SwissProt entry at ExPASy.
103
+
104
+ For an ID of XXX, fetches http://www.uniprot.org/uniprot/XXX.txt
105
+ (as per the https://www.expasy.org/expasy_urls.html documentation).
106
+
107
+ >>> from Bio import ExPASy
108
+ >>> from Bio import SwissProt
109
+ >>> with ExPASy.get_sprot_raw("O23729") as handle:
110
+ ... record = SwissProt.read(handle)
111
+ ...
112
+ >>> print(record.entry_name)
113
+ CHS3_BROFI
114
+
115
+ This function raises a ValueError if the identifier does not exist:
116
+
117
+ >>> ExPASy.get_sprot_raw("DOES_NOT_EXIST")
118
+ Traceback (most recent call last):
119
+ ...
120
+ ValueError: Failed to find SwissProt entry 'DOES_NOT_EXIST'
121
+
122
+ """
123
+ try:
124
+ handle = _open(f"http://www.uniprot.org/uniprot/{id}.txt")
125
+ except HTTPError as exception:
126
+ if exception.code in (400, 404):
127
+ raise ValueError(f"Failed to find SwissProt entry '{id}'") from None
128
+ else:
129
+ raise
130
+ return handle
131
+
132
+
133
+ def _open(url):
134
+ """Open URL and convert to text assuming UTF-8 encoding (PRIVATE)."""
135
+ handle = urlopen(url)
136
+ text_handle = io.TextIOWrapper(handle, encoding="UTF-8")
137
+ text_handle.url = handle.url
138
+ return text_handle
.venv_haddock/lib/python3.12/site-packages/Bio/ExPASy/cellosaurus.py ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2016 by Stephen Marshall. All rights reserved.
2
+ # This code is part of the Biopython distribution and governed by its
3
+ # license. Please see the LICENSE file that should have been included
4
+ # as part of this package.
5
+
6
+ """Parser for the cellosaurus.txt file from ExPASy.
7
+
8
+ See https://web.expasy.org/cellosaurus/
9
+
10
+ Tested with the release of Version 18 (July 2016).
11
+
12
+ Functions:
13
+ - read Reads a file containing one cell line entry
14
+ - parse Reads a file containing multiple cell line entries
15
+
16
+ Classes:
17
+ - Record Holds cell line data.
18
+
19
+ Examples
20
+ --------
21
+ This example downloads the Cellosaurus database and parses it. Note that
22
+ urlopen returns a stream of bytes, while the parser expects a stream of plain
23
+ string, so we use TextIOWrapper to convert bytes to string using the UTF-8
24
+ encoding. This is not needed if you download the cellosaurus.txt file in
25
+ advance and open it (see the comment below).
26
+
27
+ >>> from urllib.request import urlopen
28
+ >>> from io import TextIOWrapper
29
+ >>> from Bio.ExPASy import cellosaurus
30
+ >>> url = "ftp://ftp.expasy.org/databases/cellosaurus/cellosaurus.txt"
31
+ >>> bytestream = urlopen(url)
32
+ >>> textstream = TextIOWrapper(bytestream, "UTF-8")
33
+ >>> # alternatively, use
34
+ >>> # textstream = open("cellosaurus.txt")
35
+ >>> # if you downloaded the cellosaurus.txt file in advance.
36
+ >>> records = cellosaurus.parse(textstream)
37
+ >>> for record in records:
38
+ ... if 'Homo sapiens' in record['OX'][0]:
39
+ ... print(record['ID']) # doctest:+ELLIPSIS
40
+ ...
41
+ #15310-LN
42
+ #W7079
43
+ (L)PC6
44
+ 0.5alpha
45
+ ...
46
+
47
+ """
48
+
49
+
50
+ def parse(handle):
51
+ """Parse cell line records.
52
+
53
+ This function is for parsing cell line files containing multiple
54
+ records.
55
+
56
+ Arguments:
57
+ - handle - handle to the file.
58
+
59
+ """
60
+ while True:
61
+ record = __read(handle)
62
+ if not record:
63
+ break
64
+ yield record
65
+
66
+
67
+ def read(handle):
68
+ """Read one cell line record.
69
+
70
+ This function is for parsing cell line files containing
71
+ exactly one record.
72
+
73
+ Arguments:
74
+ - handle - handle to the file.
75
+
76
+ """
77
+ record = __read(handle)
78
+ # We should have reached the end of the record by now
79
+ remainder = handle.read()
80
+ if remainder:
81
+ raise ValueError("More than one cell line record found")
82
+ return record
83
+
84
+
85
+ class Record(dict):
86
+ """Holds information from an ExPASy Cellosaurus record as a Python dictionary.
87
+
88
+ Each record contains the following keys:
89
+
90
+ ========= ============================== =======================
91
+ Line code Content Occurrence in an entry
92
+ ========= ============================== =======================
93
+ ID Identifier (cell line name) Once; starts an entry
94
+ AC Accession (CVCL_xxxx) Once
95
+ AS Secondary accession number(s) Optional; once
96
+ SY Synonyms Optional; once
97
+ DR Cross-references Optional; once or more
98
+ RX References identifiers Optional: once or more
99
+ WW Web pages Optional; once or more
100
+ CC Comments Optional; once or more
101
+ ST STR profile data Optional; twice or more
102
+ DI Diseases Optional; once or more
103
+ OX Species of origin Once or more
104
+ HI Hierarchy Optional; once or more
105
+ OI Originate from same individual Optional; once or more
106
+ SX Sex of cell Optional; once
107
+ AG Age of donor at sampling Optional; once
108
+ CA Category Once
109
+ DT Date (entry history) Once
110
+ // Terminator Once; ends an entry
111
+ ========= ============================== =======================
112
+
113
+ """
114
+
115
+ def __init__(self):
116
+ """Initialize the class."""
117
+ dict.__init__(self)
118
+ self["ID"] = ""
119
+ self["AC"] = ""
120
+ self["AS"] = ""
121
+ self["SY"] = ""
122
+ self["DR"] = []
123
+ self["RX"] = []
124
+ self["WW"] = []
125
+ self["CC"] = []
126
+ self["ST"] = []
127
+ self["DI"] = []
128
+ self["OX"] = []
129
+ self["HI"] = []
130
+ self["OI"] = []
131
+ self["SX"] = ""
132
+ self["AG"] = ""
133
+ self["CA"] = ""
134
+ self["DT"] = ""
135
+
136
+ def __repr__(self):
137
+ """Return the canonical string representation of the Record object."""
138
+ if self["ID"]:
139
+ if self["AC"]:
140
+ return f"{self.__class__.__name__} ({self['ID']}, {self['AC']})"
141
+ else:
142
+ return f"{self.__class__.__name__} ({self['ID']})"
143
+ else:
144
+ return f"{self.__class__.__name__} ( )"
145
+
146
+ def __str__(self):
147
+ """Return a readable string representation of the Record object."""
148
+ output = "ID: " + self["ID"]
149
+ output += " AC: " + self["AC"]
150
+ output += " AS: " + self["AS"]
151
+ output += " SY: " + self["SY"]
152
+ output += " DR: " + repr(self["DR"])
153
+ output += " RX: " + repr(self["RX"])
154
+ output += " WW: " + repr(self["WW"])
155
+ output += " CC: " + repr(self["CC"])
156
+ output += " ST: " + repr(self["ST"])
157
+ output += " DI: " + repr(self["DI"])
158
+ output += " OX: " + repr(self["OX"])
159
+ output += " HI: " + repr(self["HI"])
160
+ output += " OI: " + repr(self["OI"])
161
+ output += " SX: " + self["SX"]
162
+ output += " AG: " + self["AG"]
163
+ output += " CA: " + self["CA"]
164
+ output += " DT: " + self["DT"]
165
+ return output
166
+
167
+
168
+ # Everything below is private
169
+
170
+
171
+ def __read(handle):
172
+ record = None
173
+
174
+ for line in handle:
175
+ key, value = line[:2], line[5:].rstrip()
176
+ if key == "ID":
177
+ record = Record()
178
+ record["ID"] = value
179
+ elif key in ["AC", "AS", "SY", "SX", "AG", "CA", "DT"]:
180
+ record[key] += value
181
+ elif key in [
182
+ # just append to the fields defined as lists, not to strings
183
+ "RX",
184
+ "WW",
185
+ "CC",
186
+ "ST",
187
+ "DI",
188
+ "OX",
189
+ "HI",
190
+ "OI",
191
+ ]:
192
+ record[key].append(value)
193
+ elif key == "DR":
194
+ k, v = value.split(";")
195
+ record["DR"].append((k.strip(), v.strip()))
196
+ elif key == "//":
197
+ if record:
198
+ return record
199
+ else:
200
+ continue
201
+ if record:
202
+ raise ValueError("Unexpected end of stream")
203
+
204
+
205
+ if __name__ == "__main__":
206
+ from Bio._utils import run_doctest
207
+
208
+ run_doctest()
.venv_haddock/lib/python3.12/site-packages/Bio/File.py ADDED
@@ -0,0 +1,626 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 1999 by Jeffrey Chang. All rights reserved.
2
+ # Copyright 2009-2018 by Peter Cock. All rights reserved.
3
+ #
4
+ # This file is part of the Biopython distribution and governed by your
5
+ # choice of the "Biopython License Agreement" or the "BSD 3-Clause License".
6
+ # Please see the LICENSE file that should have been included as part of this
7
+ # package.
8
+ """Code for more fancy file handles.
9
+
10
+ Bio.File defines private classes used in Bio.SeqIO and Bio.SearchIO for
11
+ indexing files. These are not intended for direct use.
12
+ """
13
+
14
+ import collections.abc
15
+ import contextlib
16
+ import itertools
17
+ import os
18
+ from abc import ABC
19
+ from abc import abstractmethod
20
+
21
+ try:
22
+ import sqlite3
23
+ except ImportError:
24
+ # May be missing if Python was compiled from source without its dependencies
25
+ sqlite3 = None # type: ignore
26
+
27
+
28
+ @contextlib.contextmanager
29
+ def as_handle(handleish, mode="r", **kwargs):
30
+ r"""Context manager to ensure we are using a handle.
31
+
32
+ Context manager for arguments that can be passed to SeqIO and AlignIO read, write,
33
+ and parse methods: either file objects or path-like objects (strings, pathlib.Path
34
+ instances, or more generally, anything that can be handled by the builtin 'open'
35
+ function).
36
+
37
+ When given a path-like object, returns an open file handle to that path, with provided
38
+ mode, which will be closed when the manager exits.
39
+
40
+ All other inputs are returned, and are *not* closed.
41
+
42
+ Arguments:
43
+ - handleish - Either a file handle or path-like object (anything which can be
44
+ passed to the builtin 'open' function, such as str, bytes,
45
+ pathlib.Path, and os.DirEntry objects)
46
+ - mode - Mode to open handleish (used only if handleish is a string)
47
+ - kwargs - Further arguments to pass to open(...)
48
+
49
+ Examples
50
+ --------
51
+ >>> from Bio import File
52
+ >>> import os
53
+ >>> with File.as_handle('seqs.fasta', 'w') as fp:
54
+ ... fp.write('>test\nACGT')
55
+ ...
56
+ 10
57
+ >>> fp.closed
58
+ True
59
+
60
+ >>> handle = open('seqs.fasta', 'w')
61
+ >>> with File.as_handle(handle) as fp:
62
+ ... fp.write('>test\nACGT')
63
+ ...
64
+ 10
65
+ >>> fp.closed
66
+ False
67
+ >>> fp.close()
68
+ >>> os.remove("seqs.fasta") # tidy up
69
+
70
+ """
71
+ try:
72
+ with open(handleish, mode, **kwargs) as fp:
73
+ yield fp
74
+ except TypeError:
75
+ yield handleish
76
+
77
+
78
+ def _open_for_random_access(filename):
79
+ """Open a file in binary mode, spot if it is BGZF format etc (PRIVATE).
80
+
81
+ This functionality is used by the Bio.SeqIO and Bio.SearchIO index
82
+ and index_db functions.
83
+
84
+ If the file is gzipped but not BGZF, a specific ValueError is raised.
85
+ """
86
+ handle = open(filename, "rb")
87
+ magic = handle.read(2)
88
+ handle.seek(0)
89
+
90
+ if magic == b"\x1f\x8b":
91
+ # This is a gzipped file, but is it BGZF?
92
+ from . import bgzf
93
+
94
+ try:
95
+ # If it is BGZF, we support that
96
+ return bgzf.BgzfReader(mode="rb", fileobj=handle)
97
+ except ValueError as e:
98
+ assert "BGZF" in str(e)
99
+ # Not a BGZF file after all,
100
+ handle.close()
101
+ raise ValueError(
102
+ "Gzipped files are not suitable for indexing, "
103
+ "please use BGZF (blocked gzip format) instead."
104
+ ) from None
105
+
106
+ return handle
107
+
108
+
109
+ # The rest of this file defines code used in Bio.SeqIO and Bio.SearchIO
110
+ # for indexing
111
+
112
+
113
+ class _IndexedSeqFileProxy(ABC):
114
+ """Abstract base class for file format specific random access (PRIVATE).
115
+
116
+ This is subclasses in both Bio.SeqIO for indexing as SeqRecord
117
+ objects, and in Bio.SearchIO for indexing QueryResult objects.
118
+
119
+ Subclasses for each file format should define '__iter__', 'get'
120
+ and optionally 'get_raw' methods.
121
+ """
122
+
123
+ @abstractmethod
124
+ def __iter__(self):
125
+ """Return (identifier, offset, length in bytes) tuples.
126
+
127
+ The length can be zero where it is not implemented or not
128
+ possible for a particular file format.
129
+ """
130
+ raise NotImplementedError
131
+
132
+ @abstractmethod
133
+ def get(self, offset):
134
+ """Return parsed object for this entry."""
135
+ # Most file formats with self contained records can be handled by
136
+ # parsing StringIO(self.get_raw(offset).decode())
137
+ raise NotImplementedError
138
+
139
+ def get_raw(self, offset):
140
+ """Return the raw record from the file as a bytes string (if implemented).
141
+
142
+ If the key is not found, a KeyError exception is raised.
143
+
144
+ This may not have been implemented for all file formats.
145
+ """
146
+ # Should be done by each sub-class (if possible)
147
+ raise NotImplementedError("Not available for this file format.")
148
+
149
+
150
+ class _IndexedSeqFileDict(collections.abc.Mapping):
151
+ """Read only dictionary interface to a sequential record file.
152
+
153
+ This code is used in both Bio.SeqIO for indexing as SeqRecord
154
+ objects, and in Bio.SearchIO for indexing QueryResult objects.
155
+
156
+ Keeps the keys and associated file offsets in memory, reads the file
157
+ to access entries as objects parsing them on demand. This approach
158
+ is memory limited, but will work even with millions of records.
159
+
160
+ Note duplicate keys are not allowed. If this happens, a ValueError
161
+ exception is raised.
162
+
163
+ As used in Bio.SeqIO, by default the SeqRecord's id string is used
164
+ as the dictionary key. In Bio.SearchIO, the query's id string is
165
+ used. This can be changed by supplying an optional key_function,
166
+ a callback function which will be given the record id and must
167
+ return the desired key. For example, this allows you to parse
168
+ NCBI style FASTA identifiers, and extract the GI number to use
169
+ as the dictionary key.
170
+
171
+ Note that this dictionary is essentially read only. You cannot
172
+ add or change values, pop values, nor clear the dictionary.
173
+ """
174
+
175
+ def __init__(self, random_access_proxy, key_function, repr, obj_repr):
176
+ """Initialize the class."""
177
+ # Use key_function=None for default value
178
+ self._proxy = random_access_proxy
179
+ self._key_function = key_function
180
+ self._repr = repr
181
+ self._obj_repr = obj_repr
182
+ self._cached_prev_record = (None, None) # (key, record)
183
+ if key_function:
184
+ offset_iter = (
185
+ (key_function(key), offset, length)
186
+ for (key, offset, length) in random_access_proxy
187
+ )
188
+ else:
189
+ offset_iter = random_access_proxy
190
+ offsets = {}
191
+ for key, offset, length in offset_iter:
192
+ # Note - we don't store the length because I want to minimise the
193
+ # memory requirements. With the SQLite backend the length is kept
194
+ # and is used to speed up the get_raw method (by about 3 times).
195
+ # The length should be provided by all the current backends except
196
+ # SFF where there is an existing Roche index we can reuse (very fast
197
+ # but lacks the record lengths)
198
+ # assert length or format in ["sff", "sff-trim"], \
199
+ # "%s at offset %i given length %r (%s format %s)" \
200
+ # % (key, offset, length, filename, format)
201
+ if key in offsets:
202
+ self._proxy._handle.close()
203
+ raise ValueError(f"Duplicate key '{key}'")
204
+ else:
205
+ offsets[key] = offset
206
+ self._offsets = offsets
207
+
208
+ def __repr__(self):
209
+ """Return a string representation of the File object."""
210
+ return self._repr
211
+
212
+ def __str__(self):
213
+ """Create a string representation of the File object."""
214
+ # TODO - How best to handle the __str__ for SeqIO and SearchIO?
215
+ if self:
216
+ return f"{{{list(self.keys())[0]!r} : {self._obj_repr}(...), ...}}"
217
+ else:
218
+ return "{}"
219
+
220
+ def __len__(self):
221
+ """Return the number of records."""
222
+ return len(self._offsets)
223
+
224
+ def __iter__(self):
225
+ """Iterate over the keys."""
226
+ return iter(self._offsets)
227
+
228
+ def __getitem__(self, key):
229
+ """Return record for the specified key.
230
+
231
+ As an optimization when repeatedly asked to look up the same record,
232
+ the key and record are cached so that if the *same* record is
233
+ requested next time, it can be returned without going to disk.
234
+ """
235
+ if key == self._cached_prev_record[0]:
236
+ return self._cached_prev_record[1]
237
+ # Pass the offset to the proxy
238
+ record = self._proxy.get(self._offsets[key])
239
+ if self._key_function:
240
+ key2 = self._key_function(record.id)
241
+ else:
242
+ key2 = record.id
243
+ if key != key2:
244
+ raise ValueError(f"Key did not match ({key} vs {key2})")
245
+ self._cached_prev_record = (key, record)
246
+ return record
247
+
248
+ def get_raw(self, key):
249
+ """Return the raw record from the file as a bytes string.
250
+
251
+ If the key is not found, a KeyError exception is raised.
252
+ """
253
+ # Pass the offset to the proxy
254
+ return self._proxy.get_raw(self._offsets[key])
255
+
256
+ def close(self):
257
+ """Close the file handle being used to read the data.
258
+
259
+ Once called, further use of the index won't work. The sole purpose
260
+ of this method is to allow explicit handle closure - for example
261
+ if you wish to delete the file, on Windows you must first close
262
+ all open handles to that file.
263
+ """
264
+ self._proxy._handle.close()
265
+
266
+
267
+ class _SQLiteManySeqFilesDict(_IndexedSeqFileDict):
268
+ """Read only dictionary interface to many sequential record files.
269
+
270
+ This code is used in both Bio.SeqIO for indexing as SeqRecord
271
+ objects, and in Bio.SearchIO for indexing QueryResult objects.
272
+
273
+ Keeps the keys, file-numbers and offsets in an SQLite database. To access
274
+ a record by key, reads from the offset in the appropriate file and then
275
+ parses the record into an object.
276
+
277
+ There are OS limits on the number of files that can be open at once,
278
+ so a pool are kept. If a record is required from a closed file, then
279
+ one of the open handles is closed first.
280
+ """
281
+
282
+ def __init__(
283
+ self,
284
+ index_filename,
285
+ filenames,
286
+ proxy_factory,
287
+ fmt,
288
+ key_function,
289
+ repr,
290
+ max_open=10,
291
+ ):
292
+ """Initialize the class."""
293
+ # TODO? - Don't keep filename list in memory (just in DB)?
294
+ # Should save a chunk of memory if dealing with 1000s of files.
295
+ # Furthermore could compare a generator to the DB on reloading
296
+ # (no need to turn it into a list)
297
+
298
+ if sqlite3 is None:
299
+ # Python was compiled without sqlite3 support
300
+ from Bio import MissingPythonDependencyError
301
+
302
+ raise MissingPythonDependencyError(
303
+ "Python was compiled without the sqlite3 module"
304
+ )
305
+ if filenames is not None:
306
+ filenames = list(filenames) # In case it was a generator
307
+
308
+ # Cache the arguments as private variables
309
+ self._index_filename = index_filename
310
+ self._filenames = filenames
311
+ self._format = fmt
312
+ self._key_function = key_function
313
+ self._proxy_factory = proxy_factory
314
+ self._repr = repr
315
+ self._max_open = max_open
316
+ self._proxies = {}
317
+
318
+ # Note if using SQLite :memory: trick index filename, this will
319
+ # give $PWD as the relative path (which is fine).
320
+ self._relative_path = os.path.abspath(os.path.dirname(index_filename))
321
+
322
+ if os.path.isfile(index_filename):
323
+ self._load_index()
324
+ else:
325
+ self._build_index()
326
+
327
+ def _load_index(self):
328
+ """Call from __init__ to reuse an existing index (PRIVATE)."""
329
+ index_filename = self._index_filename
330
+ relative_path = self._relative_path
331
+ filenames = self._filenames
332
+ fmt = self._format
333
+ proxy_factory = self._proxy_factory
334
+
335
+ con = sqlite3.dbapi2.connect(index_filename, check_same_thread=False)
336
+ self._con = con
337
+ # Check the count...
338
+ try:
339
+ (count,) = con.execute(
340
+ "SELECT value FROM meta_data WHERE key=?;", ("count",)
341
+ ).fetchone()
342
+ self._length = int(count)
343
+ if self._length == -1:
344
+ con.close()
345
+ raise ValueError("Unfinished/partial database") from None
346
+
347
+ # use MAX(_ROWID_) to obtain the number of sequences in the database
348
+ # using COUNT(key) is quite slow in SQLITE
349
+ # (https://stackoverflow.com/questions/8988915/sqlite-count-slow-on-big-tables)
350
+ (count,) = con.execute("SELECT MAX(_ROWID_) FROM offset_data;").fetchone()
351
+ if self._length != int(count):
352
+ con.close()
353
+ raise ValueError(
354
+ "Corrupt database? %i entries not %i" % (int(count), self._length)
355
+ ) from None
356
+ (self._format,) = con.execute(
357
+ "SELECT value FROM meta_data WHERE key=?;", ("format",)
358
+ ).fetchone()
359
+ if fmt and fmt != self._format:
360
+ con.close()
361
+ raise ValueError(
362
+ f"Index file says format {self._format}, not {fmt}"
363
+ ) from None
364
+ try:
365
+ (filenames_relative_to_index,) = con.execute(
366
+ "SELECT value FROM meta_data WHERE key=?;",
367
+ ("filenames_relative_to_index",),
368
+ ).fetchone()
369
+ filenames_relative_to_index = (
370
+ filenames_relative_to_index.upper() == "TRUE"
371
+ )
372
+ except TypeError:
373
+ # Original behaviour, assume if meta_data missing
374
+ filenames_relative_to_index = False
375
+ self._filenames = [
376
+ row[0]
377
+ for row in con.execute(
378
+ "SELECT name FROM file_data ORDER BY file_number;"
379
+ ).fetchall()
380
+ ]
381
+ if filenames_relative_to_index:
382
+ # Not implicitly relative to $PWD, explicitly relative to index file
383
+ relative_path = os.path.abspath(os.path.dirname(index_filename))
384
+ tmp = []
385
+ for f in self._filenames:
386
+ if os.path.isabs(f):
387
+ tmp.append(f)
388
+ else:
389
+ # Would be stored with Unix / path separator, so convert
390
+ # it to the local OS path separator here:
391
+ tmp.append(
392
+ os.path.join(relative_path, f.replace("/", os.path.sep))
393
+ )
394
+ self._filenames = tmp
395
+ del tmp
396
+ if filenames and len(filenames) != len(self._filenames):
397
+ con.close()
398
+ raise ValueError(
399
+ "Index file says %i files, not %i"
400
+ % (len(self._filenames), len(filenames))
401
+ ) from None
402
+ if filenames and filenames != self._filenames:
403
+ for old, new in zip(self._filenames, filenames):
404
+ # Want exact match (after making relative to the index above)
405
+ if os.path.abspath(old) != os.path.abspath(new):
406
+ con.close()
407
+ if filenames_relative_to_index:
408
+ raise ValueError(
409
+ "Index file has different filenames, e.g. %r != %r"
410
+ % (os.path.abspath(old), os.path.abspath(new))
411
+ ) from None
412
+ else:
413
+ raise ValueError(
414
+ "Index file has different filenames "
415
+ "[This is an old index where any relative paths "
416
+ "were relative to the original working directory]. "
417
+ "e.g. %r != %r"
418
+ % (os.path.abspath(old), os.path.abspath(new))
419
+ ) from None
420
+ # Filenames are equal (after imposing abspath)
421
+ except sqlite3.OperationalError as err:
422
+ con.close()
423
+ raise ValueError(f"Not a Biopython index database? {err}") from None
424
+ # Now we have the format (from the DB if not given to us),
425
+ if not proxy_factory(self._format):
426
+ con.close()
427
+ raise ValueError(f"Unsupported format '{self._format}'")
428
+
429
+ def _build_index(self):
430
+ """Call from __init__ to create a new index (PRIVATE)."""
431
+ index_filename = self._index_filename
432
+ relative_path = self._relative_path
433
+ filenames = self._filenames
434
+ fmt = self._format
435
+ key_function = self._key_function
436
+ proxy_factory = self._proxy_factory
437
+ max_open = self._max_open
438
+ random_access_proxies = self._proxies
439
+
440
+ if not fmt or not filenames:
441
+ raise ValueError(
442
+ f"Filenames to index and format required to build {index_filename!r}"
443
+ )
444
+ if not proxy_factory(fmt):
445
+ raise ValueError(f"Unsupported format '{fmt}'")
446
+ # Create the index
447
+ con = sqlite3.dbapi2.connect(index_filename)
448
+ self._con = con
449
+ # print("Creating index")
450
+ # Sqlite PRAGMA settings for speed
451
+ con.execute("PRAGMA synchronous=OFF")
452
+ con.execute("PRAGMA locking_mode=EXCLUSIVE")
453
+ # Don't index the key column until the end (faster)
454
+ # con.execute("CREATE TABLE offset_data (key TEXT PRIMARY KEY, "
455
+ # "offset INTEGER);")
456
+ con.execute("CREATE TABLE meta_data (key TEXT, value TEXT);")
457
+ con.execute("INSERT INTO meta_data (key, value) VALUES (?,?);", ("count", -1))
458
+ con.execute("INSERT INTO meta_data (key, value) VALUES (?,?);", ("format", fmt))
459
+ con.execute(
460
+ "INSERT INTO meta_data (key, value) VALUES (?,?);",
461
+ ("filenames_relative_to_index", "True"),
462
+ )
463
+ # TODO - Record the file size and modified date?
464
+ con.execute("CREATE TABLE file_data (file_number INTEGER, name TEXT);")
465
+ con.execute(
466
+ "CREATE TABLE offset_data (key TEXT, "
467
+ "file_number INTEGER, offset INTEGER, length INTEGER);"
468
+ )
469
+ count = 0
470
+ for file_index, filename in enumerate(filenames):
471
+ # Default to storing as an absolute path,
472
+ f = os.path.abspath(filename)
473
+ if not os.path.isabs(filename) and not os.path.isabs(index_filename):
474
+ # Since user gave BOTH filename & index as relative paths,
475
+ # we will store this relative to the index file even though
476
+ # if it may now start ../ (meaning up a level)
477
+ # Note for cross platform use (e.g. shared drive over SAMBA),
478
+ # convert any Windows slash into Unix style for rel paths.
479
+ f = os.path.relpath(filename, relative_path).replace(os.path.sep, "/")
480
+ elif (os.path.dirname(os.path.abspath(filename)) + os.path.sep).startswith(
481
+ relative_path + os.path.sep
482
+ ):
483
+ # Since sequence file is in same directory or sub directory,
484
+ # might as well make this into a relative path:
485
+ f = os.path.relpath(filename, relative_path).replace(os.path.sep, "/")
486
+ assert not f.startswith("../"), f
487
+ # print("DEBUG - storing %r as [%r] %r" % (filename, relative_path, f))
488
+ con.execute(
489
+ "INSERT INTO file_data (file_number, name) VALUES (?,?);",
490
+ (file_index, f),
491
+ )
492
+ random_access_proxy = proxy_factory(fmt, filename)
493
+ if key_function:
494
+ offset_iter = (
495
+ (key_function(key), file_index, offset, length)
496
+ for (key, offset, length) in random_access_proxy
497
+ )
498
+ else:
499
+ offset_iter = (
500
+ (key, file_index, offset, length)
501
+ for (key, offset, length) in random_access_proxy
502
+ )
503
+ while True:
504
+ batch = list(itertools.islice(offset_iter, 100))
505
+ if not batch:
506
+ break
507
+ # print("Inserting batch of %i offsets, %s ... %s"
508
+ # % (len(batch), batch[0][0], batch[-1][0]))
509
+ con.executemany(
510
+ "INSERT INTO offset_data (key,file_number,offset,length) VALUES (?,?,?,?);",
511
+ batch,
512
+ )
513
+ con.commit()
514
+ count += len(batch)
515
+ if len(random_access_proxies) < max_open:
516
+ random_access_proxies[file_index] = random_access_proxy
517
+ else:
518
+ random_access_proxy._handle.close()
519
+ self._length = count
520
+ # print("About to index %i entries" % count)
521
+ try:
522
+ con.execute(
523
+ "CREATE UNIQUE INDEX IF NOT EXISTS key_index ON offset_data(key);"
524
+ )
525
+ except sqlite3.IntegrityError as err:
526
+ self._proxies = random_access_proxies
527
+ self.close()
528
+ con.close()
529
+ raise ValueError(f"Duplicate key? {err}") from None
530
+ con.execute("PRAGMA locking_mode=NORMAL")
531
+ con.execute("UPDATE meta_data SET value = ? WHERE key = ?;", (count, "count"))
532
+ con.commit()
533
+ # print("Index created")
534
+
535
+ def __repr__(self):
536
+ return self._repr
537
+
538
+ def __contains__(self, key):
539
+ return bool(
540
+ self._con.execute(
541
+ "SELECT key FROM offset_data WHERE key=?;", (key,)
542
+ ).fetchone()
543
+ )
544
+
545
+ def __len__(self):
546
+ """Return the number of records indexed."""
547
+ return self._length
548
+ # return self._con.execute("SELECT COUNT(key) FROM offset_data;").fetchone()[0]
549
+
550
+ def __iter__(self):
551
+ """Iterate over the keys."""
552
+ for row in self._con.execute(
553
+ "SELECT key FROM offset_data ORDER BY file_number, offset;"
554
+ ):
555
+ yield str(row[0])
556
+
557
+ def __getitem__(self, key):
558
+ """Return record for the specified key."""
559
+ # Pass the offset to the proxy
560
+ row = self._con.execute(
561
+ "SELECT file_number, offset FROM offset_data WHERE key=?;", (key,)
562
+ ).fetchone()
563
+ if not row:
564
+ raise KeyError
565
+ file_number, offset = row
566
+ proxies = self._proxies
567
+ if file_number in proxies:
568
+ record = proxies[file_number].get(offset)
569
+ else:
570
+ if len(proxies) >= self._max_open:
571
+ # Close an old handle...
572
+ proxies.popitem()[1]._handle.close()
573
+ # Open a new handle...
574
+ proxy = self._proxy_factory(self._format, self._filenames[file_number])
575
+ record = proxy.get(offset)
576
+ proxies[file_number] = proxy
577
+ if self._key_function:
578
+ key2 = self._key_function(record.id)
579
+ else:
580
+ key2 = record.id
581
+ if key != key2:
582
+ raise ValueError(f"Key did not match ({key} vs {key2})")
583
+ return record
584
+
585
+ def get_raw(self, key):
586
+ """Return the raw record from the file as a bytes string.
587
+
588
+ If the key is not found, a KeyError exception is raised.
589
+ """
590
+ # Pass the offset to the proxy
591
+ row = self._con.execute(
592
+ "SELECT file_number, offset, length FROM offset_data WHERE key=?;", (key,)
593
+ ).fetchone()
594
+ if not row:
595
+ raise KeyError
596
+ file_number, offset, length = row
597
+ proxies = self._proxies
598
+ if file_number in proxies:
599
+ if length:
600
+ # Shortcut if we have the length
601
+ h = proxies[file_number]._handle
602
+ h.seek(offset)
603
+ return h.read(length)
604
+ else:
605
+ return proxies[file_number].get_raw(offset)
606
+ else:
607
+ # This code is duplicated from __getitem__ to avoid a function call
608
+ if len(proxies) >= self._max_open:
609
+ # Close an old handle...
610
+ proxies.popitem()[1]._handle.close()
611
+ # Open a new handle...
612
+ proxy = self._proxy_factory(self._format, self._filenames[file_number])
613
+ proxies[file_number] = proxy
614
+ if length:
615
+ # Shortcut if we have the length
616
+ h = proxy._handle
617
+ h.seek(offset)
618
+ return h.read(length)
619
+ else:
620
+ return proxy.get_raw(offset)
621
+
622
+ def close(self):
623
+ """Close any open file handles."""
624
+ proxies = self._proxies
625
+ while proxies:
626
+ proxies.popitem()[1]._handle.close()
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/._Record.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/._Scanner.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/.___init__.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/.___pycache__ ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/._utils.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/Record.py ADDED
@@ -0,0 +1,669 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This code is part of the Biopython distribution and governed by its
2
+ # license. Please see the LICENSE file that should have been included
3
+ # as part of this package.
4
+ #
5
+
6
+ """Hold GenBank data in a straightforward format.
7
+
8
+ Classes:
9
+ - Record - All of the information in a GenBank record.
10
+ - Reference - hold reference data for a record.
11
+ - Feature - Hold the information in a Feature Table.
12
+ - Qualifier - Qualifiers on a Feature.
13
+
14
+ """
15
+
16
+ import Bio.GenBank
17
+
18
+
19
+ def _wrapped_genbank(information, indent, wrap_space=1, split_char=" "):
20
+ """Write a line of GenBank info that can wrap over multiple lines (PRIVATE).
21
+
22
+ This takes a line of information which can potentially wrap over
23
+ multiple lines, and breaks it up with carriage returns and
24
+ indentation so it fits properly into a GenBank record.
25
+
26
+ Arguments:
27
+ - information - The string holding the information we want
28
+ wrapped in GenBank method.
29
+ - indent - The indentation on the lines we are writing.
30
+ - wrap_space - Whether or not to wrap only on spaces in the
31
+ information.
32
+ - split_char - A specific character to split the lines on. By default
33
+ spaces are used.
34
+
35
+ """
36
+ info_length = Record.GB_LINE_LENGTH - indent
37
+
38
+ if not information:
39
+ # GenBank files use "." for missing data
40
+ return ".\n"
41
+
42
+ if wrap_space:
43
+ info_parts = information.split(split_char)
44
+ else:
45
+ cur_pos = 0
46
+ info_parts = []
47
+ while cur_pos < len(information):
48
+ info_parts.append(information[cur_pos : cur_pos + info_length])
49
+ cur_pos += info_length
50
+
51
+ # first get the information string split up by line
52
+ output_parts = []
53
+ cur_part = ""
54
+ for info_part in info_parts:
55
+ if len(cur_part) + 1 + len(info_part) > info_length:
56
+ if cur_part:
57
+ if split_char != " ":
58
+ cur_part += split_char
59
+ output_parts.append(cur_part)
60
+ cur_part = info_part
61
+ else:
62
+ if cur_part == "":
63
+ cur_part = info_part
64
+ else:
65
+ cur_part += split_char + info_part
66
+
67
+ # add the last bit of information to the output
68
+ if cur_part:
69
+ output_parts.append(cur_part)
70
+
71
+ # now format the information string for return
72
+ output_info = output_parts[0] + "\n"
73
+ for output_part in output_parts[1:]:
74
+ output_info += " " * indent + output_part + "\n"
75
+
76
+ return output_info
77
+
78
+
79
+ def _indent_genbank(information, indent):
80
+ """Write out information with the specified indent (PRIVATE).
81
+
82
+ Unlike _wrapped_genbank, this function makes no attempt to wrap
83
+ lines -- it assumes that the information already has newlines in the
84
+ appropriate places, and will add the specified indent to the start of
85
+ each line.
86
+ """
87
+ # split the info into lines based on line breaks
88
+ info_parts = information.split("\n")
89
+
90
+ # the first line will have no indent
91
+ output_info = info_parts[0] + "\n"
92
+ for info_part in info_parts[1:]:
93
+ output_info += " " * indent + info_part + "\n"
94
+
95
+ return output_info
96
+
97
+
98
+ class Record:
99
+ """Hold GenBank information in a format similar to the original record.
100
+
101
+ The Record class is meant to make data easy to get to when you are
102
+ just interested in looking at GenBank data.
103
+
104
+ Attributes:
105
+ - locus - The name specified after the LOCUS keyword in the GenBank
106
+ record. This may be the accession number, or a clone id or something else.
107
+ - size - The size of the record.
108
+ - residue_type - The type of residues making up the sequence in this
109
+ record. Normally something like RNA, DNA or PROTEIN, but may be as
110
+ esoteric as 'ss-RNA circular'.
111
+ - data_file_division - The division this record is stored under in
112
+ GenBank (ie. PLN -> plants; PRI -> humans, primates; BCT -> bacteria...)
113
+ - date - The date of submission of the record, in a form like '28-JUL-1998'
114
+ - accession - list of all accession numbers for the sequence.
115
+ - nid - Nucleotide identifier number.
116
+ - pid - Proteint identifier number
117
+ - version - The accession number + version (ie. AB01234.2)
118
+ - db_source - Information about the database the record came from
119
+ - gi - The NCBI gi identifier for the record.
120
+ - keywords - A list of keywords related to the record.
121
+ - segment - If the record is one of a series, this is info about which
122
+ segment this record is (something like '1 of 6').
123
+ - source - The source of material where the sequence came from.
124
+ - organism - The genus and species of the organism (ie. 'Homo sapiens')
125
+ - taxonomy - A listing of the taxonomic classification of the organism,
126
+ starting general and getting more specific.
127
+ - references - A list of Reference objects.
128
+ - comment - Text with any kind of comment about the record.
129
+ - features - A listing of Features making up the feature table.
130
+ - base_counts - A string with the counts of bases for the sequence.
131
+ - origin - A string specifying info about the origin of the sequence.
132
+ - sequence - A string with the sequence itself.
133
+ - contig - A string of location information for a CONTIG in a RefSeq file
134
+ - project - The genome sequencing project numbers
135
+ (will be replaced by the dblink cross-references in 2009).
136
+ - dblinks - The genome sequencing project number(s) and other links.
137
+ (will replace the project information in 2009).
138
+
139
+ """
140
+
141
+ # constants for outputting GenBank information
142
+ GB_LINE_LENGTH = 79
143
+ GB_BASE_INDENT = 12
144
+ GB_FEATURE_INDENT = 21
145
+ GB_INTERNAL_INDENT = 2
146
+ GB_OTHER_INTERNAL_INDENT = 3
147
+ GB_FEATURE_INTERNAL_INDENT = 5
148
+ GB_SEQUENCE_INDENT = 9
149
+
150
+ BASE_FORMAT = "%-" + str(GB_BASE_INDENT) + "s"
151
+ INTERNAL_FORMAT = (
152
+ " " * GB_INTERNAL_INDENT + "%-" + str(GB_BASE_INDENT - GB_INTERNAL_INDENT) + "s"
153
+ )
154
+ OTHER_INTERNAL_FORMAT = (
155
+ " " * GB_OTHER_INTERNAL_INDENT
156
+ + "%-"
157
+ + str(GB_BASE_INDENT - GB_OTHER_INTERNAL_INDENT)
158
+ + "s"
159
+ )
160
+
161
+ BASE_FEATURE_FORMAT = "%-" + str(GB_FEATURE_INDENT) + "s"
162
+ INTERNAL_FEATURE_FORMAT = (
163
+ " " * GB_FEATURE_INTERNAL_INDENT
164
+ + "%-"
165
+ + str(GB_FEATURE_INDENT - GB_FEATURE_INTERNAL_INDENT)
166
+ + "s"
167
+ )
168
+ SEQUENCE_FORMAT = "%" + str(GB_SEQUENCE_INDENT) + "s"
169
+
170
+ def __init__(self):
171
+ """Initialize the class."""
172
+ self.accession = []
173
+ self.base_counts = ""
174
+ self.comment = ""
175
+ self.contig = ""
176
+ self.data_file_division = ""
177
+ self.date = ""
178
+ self.db_source = ""
179
+ self.dblinks = []
180
+ self.definition = ""
181
+ self.features = []
182
+ self.gi = ""
183
+ self.keywords = []
184
+ self.locus = ""
185
+ self.molecule_type = ""
186
+ self.nid = ""
187
+ self.organism = ""
188
+ self.origin = ""
189
+ self.pid = ""
190
+ self.primary = []
191
+ self.projects = []
192
+ self.references = []
193
+ self.residue_type = ""
194
+ self.segment = ""
195
+ self.sequence = ""
196
+ self.size = ""
197
+ self.source = ""
198
+ self.taxonomy = []
199
+ self.topology = ""
200
+ self.version = ""
201
+ self.wgs = ""
202
+ self.wgs_scafld = []
203
+
204
+ def __str__(self):
205
+ """Provide a GenBank formatted output option for a Record.
206
+
207
+ The objective of this is to provide an easy way to read in a GenBank
208
+ record, modify it somehow, and then output it in 'GenBank format.'
209
+ We are striving to make this work so that a parsed Record that is
210
+ output using this function will look exactly like the original
211
+ record.
212
+
213
+ Much of the output is based on format description info at:
214
+
215
+ ftp://ncbi.nlm.nih.gov/genbank/gbrel.txt
216
+ """
217
+ output = self._locus_line()
218
+ output += self._definition_line()
219
+ output += self._accession_line()
220
+ output += self._version_line()
221
+ output += self._project_line()
222
+ output += self._dblink_line()
223
+ output += self._nid_line()
224
+ output += self._pid_line()
225
+ output += self._keywords_line()
226
+ output += self._db_source_line()
227
+ output += self._segment_line()
228
+ output += self._source_line()
229
+ output += self._organism_line()
230
+ for reference in self.references:
231
+ output += str(reference)
232
+ output += self._comment_line()
233
+ output += self._features_line()
234
+ for feature in self.features:
235
+ output += str(feature)
236
+ output += self._base_count_line()
237
+ output += self._origin_line()
238
+ output += self._sequence_line()
239
+ output += self._wgs_line()
240
+ output += self._wgs_scafld_line()
241
+ output += self._contig_line()
242
+ output += "//"
243
+ return output
244
+
245
+ def _locus_line(self):
246
+ """Provide the output string for the LOCUS line (PRIVATE)."""
247
+ output = "LOCUS"
248
+ output += " " * 7 # 6-12 spaces
249
+ output += "%-9s" % self.locus
250
+ output += " " # 22 space
251
+ output += "%7s" % self.size
252
+ if "PROTEIN" in self.residue_type:
253
+ output += " aa"
254
+ else:
255
+ output += " bp "
256
+
257
+ # treat circular types differently, since they'll have long residue
258
+ # types
259
+ if "circular" in self.residue_type:
260
+ output += "%17s" % self.residue_type
261
+ # second case: ss-DNA types of records
262
+ elif "-" in self.residue_type:
263
+ output += "%7s" % self.residue_type
264
+ output += " " * 10 # spaces for circular
265
+ else:
266
+ output += " " * 3 # spaces for stuff like ss-
267
+ output += "%-4s" % self.residue_type
268
+ output += " " * 10 # spaces for circular
269
+
270
+ output += " " * 2
271
+ output += "%3s" % self.data_file_division
272
+ output += " " * 7 # spaces for 56-63
273
+ output += "%11s" % self.date
274
+ output += "\n"
275
+ return output
276
+
277
+ def _definition_line(self):
278
+ """Provide output for the DEFINITION line (PRIVATE)."""
279
+ output = Record.BASE_FORMAT % "DEFINITION"
280
+ output += _wrapped_genbank(self.definition + ".", Record.GB_BASE_INDENT)
281
+ return output
282
+
283
+ def _accession_line(self):
284
+ """Output for the ACCESSION line (PRIVATE)."""
285
+ if self.accession:
286
+ output = Record.BASE_FORMAT % "ACCESSION"
287
+
288
+ acc_info = ""
289
+ for accession in self.accession:
290
+ acc_info += f"{accession} "
291
+ # strip off an extra space at the end
292
+ acc_info = acc_info.rstrip()
293
+ output += _wrapped_genbank(acc_info, Record.GB_BASE_INDENT)
294
+ else:
295
+ output = ""
296
+
297
+ return output
298
+
299
+ def _version_line(self):
300
+ """Output for the VERSION line (PRIVATE)."""
301
+ if self.version:
302
+ output = Record.BASE_FORMAT % "VERSION"
303
+ output += self.version
304
+ output += " GI:"
305
+ output += f"{self.gi}\n"
306
+ else:
307
+ output = ""
308
+ return output
309
+
310
+ def _project_line(self):
311
+ output = ""
312
+ if len(self.projects) > 0:
313
+ output = Record.BASE_FORMAT % "PROJECT"
314
+ output += f"{' '.join(self.projects)}\n"
315
+ return output
316
+
317
+ def _dblink_line(self):
318
+ output = ""
319
+ if len(self.dblinks) > 0:
320
+ output = Record.BASE_FORMAT % "DBLINK"
321
+ dblink_info = "\n".join(self.dblinks)
322
+ output += _wrapped_genbank(dblink_info, Record.GB_BASE_INDENT)
323
+ return output
324
+
325
+ def _nid_line(self):
326
+ """Output for the NID line. Use of NID is obsolete in GenBank files (PRIVATE)."""
327
+ if self.nid:
328
+ output = Record.BASE_FORMAT % "NID"
329
+ output += f"{self.nid}\n"
330
+ else:
331
+ output = ""
332
+ return output
333
+
334
+ def _pid_line(self):
335
+ """Output for PID line. Presumedly, PID usage is also obsolete (PRIVATE)."""
336
+ if self.pid:
337
+ output = Record.BASE_FORMAT % "PID"
338
+ output += f"{self.pid}\n"
339
+ else:
340
+ output = ""
341
+ return output
342
+
343
+ def _keywords_line(self):
344
+ """Output for the KEYWORDS line (PRIVATE)."""
345
+ output = ""
346
+ if self.keywords:
347
+ output += Record.BASE_FORMAT % "KEYWORDS"
348
+ keyword_info = ""
349
+ for keyword in self.keywords:
350
+ keyword_info += f"{keyword}; "
351
+ # replace the ; at the end with a period
352
+ keyword_info = keyword_info[:-2]
353
+ keyword_info += "."
354
+
355
+ output += _wrapped_genbank(keyword_info, Record.GB_BASE_INDENT)
356
+
357
+ return output
358
+
359
+ def _db_source_line(self):
360
+ """Output for DBSOURCE line (PRIVATE)."""
361
+ if self.db_source:
362
+ output = Record.BASE_FORMAT % "DBSOURCE"
363
+ output += f"{self.db_source}\n"
364
+ else:
365
+ output = ""
366
+ return output
367
+
368
+ def _segment_line(self):
369
+ """Output for the SEGMENT line (PRIVATE)."""
370
+ output = ""
371
+ if self.segment:
372
+ output += Record.BASE_FORMAT % "SEGMENT"
373
+ output += _wrapped_genbank(self.segment, Record.GB_BASE_INDENT)
374
+ return output
375
+
376
+ def _source_line(self):
377
+ """Output for SOURCE line on where the sample came from (PRIVATE)."""
378
+ output = Record.BASE_FORMAT % "SOURCE"
379
+ output += _wrapped_genbank(self.source, Record.GB_BASE_INDENT)
380
+ return output
381
+
382
+ def _organism_line(self):
383
+ """Output for ORGANISM line with taxonomy info (PRIVATE)."""
384
+ output = Record.INTERNAL_FORMAT % "ORGANISM"
385
+ # Now that species names can be too long, this line can wrap (Bug 2591)
386
+ output += _wrapped_genbank(self.organism, Record.GB_BASE_INDENT)
387
+ output += " " * Record.GB_BASE_INDENT
388
+ taxonomy_info = ""
389
+ for tax in self.taxonomy:
390
+ taxonomy_info += f"{tax}; "
391
+ # replace the ; at the end with a period
392
+ taxonomy_info = taxonomy_info[:-2]
393
+ taxonomy_info += "."
394
+ output += _wrapped_genbank(taxonomy_info, Record.GB_BASE_INDENT)
395
+
396
+ return output
397
+
398
+ def _comment_line(self):
399
+ """Output for the COMMENT lines (PRIVATE)."""
400
+ output = ""
401
+ if self.comment:
402
+ output += Record.BASE_FORMAT % "COMMENT"
403
+ output += _indent_genbank(self.comment, Record.GB_BASE_INDENT)
404
+ return output
405
+
406
+ def _features_line(self):
407
+ """Output for the FEATURES line (PRIVATE)."""
408
+ output = ""
409
+ if len(self.features) > 0:
410
+ output += Record.BASE_FEATURE_FORMAT % "FEATURES"
411
+ output += "Location/Qualifiers\n"
412
+ return output
413
+
414
+ def _base_count_line(self):
415
+ """Output for the BASE COUNT line with base information (PRIVATE)."""
416
+ output = ""
417
+ if self.base_counts:
418
+ output += Record.BASE_FORMAT % "BASE COUNT "
419
+ # split up the base counts into their individual parts
420
+ count_parts = self.base_counts.split(" ")
421
+ while "" in count_parts:
422
+ count_parts.remove("")
423
+ # deal with the standard case, with a normal origin line
424
+ # like: 474 a 356 c 428 g 364 t
425
+ if len(count_parts) % 2 == 0:
426
+ while len(count_parts) > 0:
427
+ count_info = count_parts.pop(0)
428
+ count_type = count_parts.pop(0)
429
+
430
+ output += f"{count_info:>7} {count_type}"
431
+ # deal with ugly ORIGIN lines like:
432
+ # 1311257 a2224835 c2190093 g1309889 t
433
+ # by just outputting the raw information
434
+ else:
435
+ output += self.base_counts
436
+ output += "\n"
437
+ return output
438
+
439
+ def _origin_line(self):
440
+ """Output for the ORIGIN line (PRIVATE)."""
441
+ output = ""
442
+ # only output the ORIGIN line if we have a sequence
443
+ if self.sequence:
444
+ output += Record.BASE_FORMAT % "ORIGIN"
445
+ if self.origin:
446
+ output += _wrapped_genbank(self.origin, Record.GB_BASE_INDENT)
447
+ else:
448
+ output += "\n"
449
+ return output
450
+
451
+ def _sequence_line(self):
452
+ """Output for all of the sequence (PRIVATE)."""
453
+ output = ""
454
+ if self.sequence:
455
+ cur_seq_pos = 0
456
+ while cur_seq_pos < len(self.sequence):
457
+ output += Record.SEQUENCE_FORMAT % str(cur_seq_pos + 1)
458
+
459
+ for section in range(6):
460
+ start_pos = cur_seq_pos + section * 10
461
+ end_pos = start_pos + 10
462
+ seq_section = self.sequence[start_pos:end_pos]
463
+ output += f" {seq_section.lower()}"
464
+
465
+ # stop looping if we are out of sequence
466
+ if end_pos > len(self.sequence):
467
+ break
468
+
469
+ output += "\n"
470
+ cur_seq_pos += 60
471
+ return output
472
+
473
+ def _wgs_line(self):
474
+ output = ""
475
+ if self.wgs:
476
+ output += Record.BASE_FORMAT % "WGS"
477
+ output += self.wgs
478
+ return output
479
+
480
+ def _wgs_scafld_line(self):
481
+ output = ""
482
+ if self.wgs_scafld:
483
+ output += Record.BASE_FORMAT % "WGS_SCAFLD"
484
+ output += self.wgs_scafld
485
+ return output
486
+
487
+ def _contig_line(self):
488
+ """Output for CONTIG location information from RefSeq (PRIVATE)."""
489
+ output = ""
490
+ if self.contig:
491
+ output += Record.BASE_FORMAT % "CONTIG"
492
+ output += _wrapped_genbank(
493
+ self.contig, Record.GB_BASE_INDENT, split_char=","
494
+ )
495
+ return output
496
+
497
+
498
+ class Reference:
499
+ """Hold information from a GenBank reference.
500
+
501
+ Attributes:
502
+ - number - The number of the reference in the listing of references.
503
+ - bases - The bases in the sequence the reference refers to.
504
+ - authors - String with all of the authors.
505
+ - consrtm - Consortium the authors belong to.
506
+ - title - The title of the reference.
507
+ - journal - Information about the journal where the reference appeared.
508
+ - medline_id - The medline id for the reference.
509
+ - pubmed_id - The pubmed_id for the reference.
510
+ - remark - Free-form remarks about the reference.
511
+
512
+ """
513
+
514
+ def __init__(self):
515
+ """Initialize the class."""
516
+ self.number = ""
517
+ self.bases = ""
518
+ self.authors = ""
519
+ self.consrtm = ""
520
+ self.title = ""
521
+ self.journal = ""
522
+ self.medline_id = ""
523
+ self.pubmed_id = ""
524
+ self.remark = ""
525
+
526
+ def __str__(self):
527
+ """Convert the reference to a GenBank format string."""
528
+ output = self._reference_line()
529
+ output += self._authors_line()
530
+ output += self._consrtm_line()
531
+ output += self._title_line()
532
+ output += self._journal_line()
533
+ output += self._medline_line()
534
+ output += self._pubmed_line()
535
+ output += self._remark_line()
536
+
537
+ return output
538
+
539
+ def _reference_line(self):
540
+ """Output for REFERENCE lines (PRIVATE)."""
541
+ output = Record.BASE_FORMAT % "REFERENCE"
542
+ if self.number:
543
+ if self.bases:
544
+ output += "%-3s" % self.number
545
+ output += f"{self.bases}"
546
+ else:
547
+ output += f"{self.number}"
548
+
549
+ output += "\n"
550
+ return output
551
+
552
+ def _authors_line(self):
553
+ """Output for AUTHORS information (PRIVATE)."""
554
+ output = ""
555
+ if self.authors:
556
+ output += Record.INTERNAL_FORMAT % "AUTHORS"
557
+ output += _wrapped_genbank(self.authors, Record.GB_BASE_INDENT)
558
+ return output
559
+
560
+ def _consrtm_line(self):
561
+ """Output for CONSRTM information (PRIVATE)."""
562
+ output = ""
563
+ if self.consrtm:
564
+ output += Record.INTERNAL_FORMAT % "CONSRTM"
565
+ output += _wrapped_genbank(self.consrtm, Record.GB_BASE_INDENT)
566
+ return output
567
+
568
+ def _title_line(self):
569
+ """Output for TITLE information (PRIVATE)."""
570
+ output = ""
571
+ if self.title:
572
+ output += Record.INTERNAL_FORMAT % "TITLE"
573
+ output += _wrapped_genbank(self.title, Record.GB_BASE_INDENT)
574
+ return output
575
+
576
+ def _journal_line(self):
577
+ """Output for JOURNAL information (PRIVATE)."""
578
+ output = ""
579
+ if self.journal:
580
+ output += Record.INTERNAL_FORMAT % "JOURNAL"
581
+ output += _wrapped_genbank(self.journal, Record.GB_BASE_INDENT)
582
+ return output
583
+
584
+ def _medline_line(self):
585
+ """Output for MEDLINE information (PRIVATE)."""
586
+ output = ""
587
+ if self.medline_id:
588
+ output += Record.INTERNAL_FORMAT % "MEDLINE"
589
+ output += self.medline_id + "\n"
590
+ return output
591
+
592
+ def _pubmed_line(self):
593
+ """Output for PUBMED information (PRIVATE)."""
594
+ output = ""
595
+ if self.pubmed_id:
596
+ output += Record.OTHER_INTERNAL_FORMAT % "PUBMED"
597
+ output += self.pubmed_id + "\n"
598
+ return output
599
+
600
+ def _remark_line(self):
601
+ """Output for REMARK information (PRIVATE)."""
602
+ output = ""
603
+ if self.remark:
604
+ output += Record.INTERNAL_FORMAT % "REMARK"
605
+ output += _wrapped_genbank(self.remark, Record.GB_BASE_INDENT)
606
+ return output
607
+
608
+
609
+ class Feature:
610
+ """Hold information about a Feature in the Feature Table of GenBank record.
611
+
612
+ Attributes:
613
+ - key - The key name of the feature (ie. source)
614
+ - location - The string specifying the location of the feature.
615
+ - qualifiers - A list of Qualifier objects in the feature.
616
+
617
+ """
618
+
619
+ def __init__(self, key="", location=""):
620
+ """Initialize the class."""
621
+ self.key = key
622
+ self.location = location
623
+ self.qualifiers = []
624
+
625
+ def __repr__(self):
626
+ """Representation of the object for debugging or logging."""
627
+ return f"Feature(key={self.key!r}, location={self.location!r})"
628
+
629
+ def __str__(self):
630
+ """Return feature as a GenBank format string."""
631
+ output = Record.INTERNAL_FEATURE_FORMAT % self.key
632
+ output += _wrapped_genbank(
633
+ self.location, Record.GB_FEATURE_INDENT, split_char=","
634
+ )
635
+ for qualifier in self.qualifiers:
636
+ output += str(qualifier)
637
+ return output
638
+
639
+
640
+ class Qualifier:
641
+ """Hold information about a qualifier in a GenBank feature.
642
+
643
+ Attributes:
644
+ - key - The key name of the qualifier (ie. /organism=)
645
+ - value - The value of the qualifier ("Dictyostelium discoideum").
646
+
647
+ """
648
+
649
+ def __init__(self, key="", value=""):
650
+ """Initialize the class."""
651
+ self.key = key
652
+ self.value = value
653
+
654
+ def __repr__(self):
655
+ """Representation of the object for debugging or logging."""
656
+ return f"Qualifier(key={self.key!r}, value={self.value!r})"
657
+
658
+ def __str__(self):
659
+ """Return feature qualifier as a GenBank format string."""
660
+ output = " " * Record.GB_FEATURE_INDENT
661
+ # determine whether we can wrap on spaces
662
+ space_wrap = 1
663
+ for no_space_key in Bio.GenBank._BaseGenBankConsumer.remove_space_keys:
664
+ if no_space_key in self.key:
665
+ space_wrap = 0
666
+ # return double quotes as-is, leave it to the user to escape them
667
+ return output + _wrapped_genbank(
668
+ self.key + self.value, Record.GB_FEATURE_INDENT, space_wrap
669
+ )
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/Scanner.py ADDED
@@ -0,0 +1,1929 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2007-2017 by Peter Cock. All rights reserved.
2
+ # Revisions copyright 2010 by Uri Laserson. All rights reserved.
3
+ # This code is part of the Biopython distribution and governed by its
4
+ # license. Please see the LICENSE file that should have been included
5
+ # as part of this package.
6
+ """Internal code for parsing GenBank and EMBL files (PRIVATE).
7
+
8
+ This code is NOT intended for direct use. It provides a basic scanner
9
+ (for use with a event consumer such as Bio.GenBank._FeatureConsumer)
10
+ to parse a GenBank or EMBL file (with their shared INSDC feature table).
11
+
12
+ It is used by Bio.GenBank to parse GenBank files
13
+ It is also used by Bio.SeqIO to parse GenBank and EMBL files
14
+
15
+ Feature Table Documentation:
16
+
17
+ - http://www.insdc.org/files/feature_table.html
18
+ - http://www.ncbi.nlm.nih.gov/projects/collab/FT/index.html
19
+ - ftp://ftp.ncbi.nih.gov/genbank/docs/
20
+ """
21
+ # 17-MAR-2009: added wgs, wgs_scafld for GenBank whole genome shotgun master records.
22
+ # These are GenBank files that summarize the content of a project, and provide lists of
23
+ # scaffold and contig files in the project. These will be in annotations['wgs'] and
24
+ # annotations['wgs_scafld']. These GenBank files do not have sequences. See
25
+ # http://groups.google.com/group/bionet.molbio.genbank/browse_thread/thread/51fb88bf39e7dc36
26
+ # http://is.gd/nNgk
27
+ # for more details of this format, and an example.
28
+ # Added by Ying Huang & Iddo Friedberg
29
+
30
+ import re
31
+ import sys
32
+ import warnings
33
+ from collections import defaultdict
34
+
35
+ from Bio import BiopythonParserWarning
36
+ from Bio.File import as_handle
37
+ from Bio.Seq import Seq
38
+ from Bio.SeqRecord import SeqRecord
39
+
40
+
41
+ class InsdcScanner:
42
+ """Basic functions for breaking up a GenBank/EMBL file into sub sections.
43
+
44
+ The International Nucleotide Sequence Database Collaboration (INSDC)
45
+ between the DDBJ, EMBL, and GenBank. These organisations all use the
46
+ same "Feature Table" layout in their plain text flat file formats.
47
+
48
+ However, the header and sequence sections of an EMBL file are very
49
+ different in layout to those produced by GenBank/DDBJ.
50
+ """
51
+
52
+ # These constants get redefined with sensible values in the sub classes:
53
+ RECORD_START = "XXX" # "LOCUS " or "ID "
54
+ HEADER_WIDTH = 3 # 12 or 5
55
+ FEATURE_START_MARKERS = ["XXX***FEATURES***XXX"]
56
+ FEATURE_END_MARKERS = ["XXX***END FEATURES***XXX"]
57
+ FEATURE_QUALIFIER_INDENT = 0
58
+ FEATURE_QUALIFIER_SPACER = ""
59
+ SEQUENCE_HEADERS = ["XXX"] # with right hand side spaces removed
60
+
61
+ def __init__(self, debug=0):
62
+ """Initialize the class."""
63
+ assert len(self.RECORD_START) == self.HEADER_WIDTH
64
+ for marker in self.SEQUENCE_HEADERS:
65
+ assert marker == marker.rstrip()
66
+ assert len(self.FEATURE_QUALIFIER_SPACER) == self.FEATURE_QUALIFIER_INDENT
67
+ self.debug = debug
68
+ self.handle = None
69
+ self.line = None
70
+
71
+ def set_handle(self, handle):
72
+ """Set the handle attribute."""
73
+ self.handle = handle
74
+ self.line = ""
75
+
76
+ def find_start(self):
77
+ """Read in lines until find the ID/LOCUS line, which is returned.
78
+
79
+ Any preamble (such as the header used by the NCBI on ``*.seq.gz`` archives)
80
+ will we ignored.
81
+ """
82
+ while True:
83
+ if self.line:
84
+ line = self.line
85
+ self.line = ""
86
+ else:
87
+ line = self.handle.readline()
88
+ if not line:
89
+ if self.debug:
90
+ print("End of file")
91
+ return None
92
+ if isinstance(line[0], int):
93
+ # Same exception as for FASTQ files
94
+ raise ValueError("Is this handle in binary mode not text mode?")
95
+ if line[: self.HEADER_WIDTH] == self.RECORD_START:
96
+ if self.debug > 1:
97
+ print("Found the start of a record:\n" + line)
98
+ break
99
+ line = line.rstrip()
100
+ if line == "//":
101
+ if self.debug > 1:
102
+ print("Skipping // marking end of last record")
103
+ elif line == "":
104
+ if self.debug > 1:
105
+ print("Skipping blank line before record")
106
+ else:
107
+ # Ignore any header before the first ID/LOCUS line.
108
+ if self.debug > 1:
109
+ print("Skipping header line before record:\n" + line)
110
+ self.line = line
111
+ return line
112
+
113
+ def parse_header(self):
114
+ """Return list of strings making up the header.
115
+
116
+ New line characters are removed.
117
+
118
+ Assumes you have just read in the ID/LOCUS line.
119
+ """
120
+ if self.line[: self.HEADER_WIDTH] != self.RECORD_START:
121
+ raise ValueError("Not at start of record")
122
+
123
+ header_lines = []
124
+ while True:
125
+ line = self.handle.readline()
126
+ if not line:
127
+ raise ValueError("Premature end of line during sequence data")
128
+ line = line.rstrip()
129
+ if line in self.FEATURE_START_MARKERS:
130
+ if self.debug:
131
+ print("Found feature table")
132
+ break
133
+ # if line[:self.HEADER_WIDTH]==self.FEATURE_START_MARKER[:self.HEADER_WIDTH]:
134
+ # if self.debug : print("Found header table (?)")
135
+ # break
136
+ if line[: self.HEADER_WIDTH].rstrip() in self.SEQUENCE_HEADERS:
137
+ if self.debug:
138
+ print("Found start of sequence")
139
+ break
140
+ if line == "//":
141
+ raise ValueError("Premature end of sequence data marker '//' found")
142
+ header_lines.append(line)
143
+ self.line = line
144
+ return header_lines
145
+
146
+ def parse_features(self, skip=False):
147
+ """Return list of tuples for the features (if present).
148
+
149
+ Each feature is returned as a tuple (key, location, qualifiers)
150
+ where key and location are strings (e.g. "CDS" and
151
+ "complement(join(490883..490885,1..879))") while qualifiers
152
+ is a list of two string tuples (feature qualifier keys and values).
153
+
154
+ Assumes you have already read to the start of the features table.
155
+ """
156
+ if self.line.rstrip() not in self.FEATURE_START_MARKERS:
157
+ if self.debug:
158
+ print("Didn't find any feature table")
159
+ return []
160
+
161
+ while self.line.rstrip() in self.FEATURE_START_MARKERS:
162
+ self.line = self.handle.readline()
163
+
164
+ features = []
165
+ line = self.line
166
+ while True:
167
+ if not line:
168
+ raise ValueError("Premature end of line during features table")
169
+ if line[: self.HEADER_WIDTH].rstrip() in self.SEQUENCE_HEADERS:
170
+ if self.debug:
171
+ print("Found start of sequence")
172
+ break
173
+ line = line.rstrip()
174
+ if line == "//":
175
+ raise ValueError("Premature end of features table, marker '//' found")
176
+ if line in self.FEATURE_END_MARKERS:
177
+ if self.debug:
178
+ print("Found end of features")
179
+ line = self.handle.readline()
180
+ break
181
+ if line[2 : self.FEATURE_QUALIFIER_INDENT].strip() == "":
182
+ # This is an empty feature line between qualifiers. Empty
183
+ # feature lines within qualifiers are handled below (ignored).
184
+ line = self.handle.readline()
185
+ continue
186
+ if len(line) < self.FEATURE_QUALIFIER_INDENT:
187
+ warnings.warn(
188
+ f"line too short to contain a feature: {line!r}",
189
+ BiopythonParserWarning,
190
+ )
191
+ line = self.handle.readline()
192
+ continue
193
+
194
+ if skip:
195
+ line = self.handle.readline()
196
+ while (
197
+ line[: self.FEATURE_QUALIFIER_INDENT]
198
+ == self.FEATURE_QUALIFIER_SPACER
199
+ ):
200
+ line = self.handle.readline()
201
+ else:
202
+ # Build up a list of the lines making up this feature:
203
+ if (
204
+ line[self.FEATURE_QUALIFIER_INDENT] != " "
205
+ and " " in line[self.FEATURE_QUALIFIER_INDENT :]
206
+ ):
207
+ # The feature table design enforces a length limit on the feature keys.
208
+ # Some third party files (e.g. IGMT's EMBL like files) solve this by
209
+ # over indenting the location and qualifiers.
210
+ feature_key, line = line[2:].strip().split(None, 1)
211
+ feature_lines = [line]
212
+ warnings.warn(
213
+ f"Over indented {feature_key} feature?",
214
+ BiopythonParserWarning,
215
+ )
216
+ else:
217
+ feature_key = line[2 : self.FEATURE_QUALIFIER_INDENT].strip()
218
+ feature_lines = [line[self.FEATURE_QUALIFIER_INDENT :]]
219
+ line = self.handle.readline()
220
+ while line[
221
+ : self.FEATURE_QUALIFIER_INDENT
222
+ ] == self.FEATURE_QUALIFIER_SPACER or (
223
+ line != "" and line.rstrip() == ""
224
+ ): # cope with blank lines in the midst of a feature
225
+ # Use strip to remove any harmless trailing white space AND and leading
226
+ # white space (e.g. out of spec files with too much indentation)
227
+ feature_lines.append(line[self.FEATURE_QUALIFIER_INDENT :].strip())
228
+ line = self.handle.readline()
229
+ features.append(self.parse_feature(feature_key, feature_lines))
230
+ self.line = line
231
+ return features
232
+
233
+ def parse_feature(self, feature_key, lines):
234
+ r"""Parse a feature given as a list of strings into a tuple.
235
+
236
+ Expects a feature as a list of strings, returns a tuple (key, location,
237
+ qualifiers)
238
+
239
+ For example given this GenBank feature::
240
+
241
+ CDS complement(join(490883..490885,1..879))
242
+ /locus_tag="NEQ001"
243
+ /note="conserved hypothetical [Methanococcus jannaschii];
244
+ COG1583:Uncharacterized ACR; IPR001472:Bipartite nuclear
245
+ localization signal; IPR002743: Protein of unknown
246
+ function DUF57"
247
+ /codon_start=1
248
+ /transl_table=11
249
+ /product="hypothetical protein"
250
+ /protein_id="NP_963295.1"
251
+ /db_xref="GI:41614797"
252
+ /db_xref="GeneID:2732620"
253
+ /translation="MRLLLELKALNSIDKKQLSNYLIQGFIYNILKNTEYSWLHNWKK
254
+ EKYFNFTLIPKKDIIENKRYYLIISSPDKRFIEVLHNKIKDLDIITIGLAQFQLRKTK
255
+ KFDPKLRFPWVTITPIVLREGKIVILKGDKYYKVFVKRLEELKKYNLIKKKEPILEEP
256
+ IEISLNQIKDGWKIIDVKDRYYDFRNKSFSAFSNWLRDLKEQSLRKYNNFCGKNFYFE
257
+ EAIFEGFTFYKTVSIRIRINRGEAVYIGTLWKELNVYRKLDKEEREFYKFLYDCGLGS
258
+ LNSMGFGFVNTKKNSAR"
259
+
260
+ Then should give input key="CDS" and the rest of the data as a list of strings
261
+ lines=["complement(join(490883..490885,1..879))", ..., "LNSMGFGFVNTKKNSAR"]
262
+ where the leading spaces and trailing newlines have been removed.
263
+
264
+ Returns tuple containing: (key as string, location string, qualifiers as list)
265
+ as follows for this example:
266
+
267
+ key = "CDS", string
268
+ location = "complement(join(490883..490885,1..879))", string
269
+ qualifiers = list of string tuples:
270
+
271
+ [('locus_tag', '"NEQ001"'),
272
+ ('note', '"conserved hypothetical [Methanococcus jannaschii];\nCOG1583:..."'),
273
+ ('codon_start', '1'),
274
+ ('transl_table', '11'),
275
+ ('product', '"hypothetical protein"'),
276
+ ('protein_id', '"NP_963295.1"'),
277
+ ('db_xref', '"GI:41614797"'),
278
+ ('db_xref', '"GeneID:2732620"'),
279
+ ('translation', '"MRLLLELKALNSIDKKQLSNYLIQGFIYNILKNTEYSWLHNWKK\nEKYFNFT..."')]
280
+
281
+ In the above example, the "note" and "translation" were edited for compactness,
282
+ and they would contain multiple new line characters (displayed above as \n)
283
+
284
+ If a qualifier is quoted (in this case, everything except codon_start and
285
+ transl_table) then the quotes are NOT removed.
286
+
287
+ Note that no whitespace is removed.
288
+ """
289
+ # Skip any blank lines
290
+ iterator = (x for x in lines if x)
291
+ try:
292
+ line = next(iterator)
293
+
294
+ feature_location = line.strip()
295
+ while feature_location[-1:] == ",":
296
+ # Multiline location, still more to come!
297
+ line = next(iterator)
298
+ feature_location += line.strip()
299
+ if feature_location.count("(") > feature_location.count(")"):
300
+ # Including the prev line in warning would be more explicit,
301
+ # but this way get one-and-only-one warning shown by default:
302
+ warnings.warn(
303
+ "Non-standard feature line wrapping (didn't break on comma)?",
304
+ BiopythonParserWarning,
305
+ )
306
+ while feature_location[-1:] == "," or feature_location.count(
307
+ "("
308
+ ) > feature_location.count(")"):
309
+ line = next(iterator)
310
+ feature_location += line.strip()
311
+
312
+ qualifiers = []
313
+
314
+ for line_number, line in enumerate(iterator):
315
+ # check for extra wrapping of the location closing parentheses
316
+ if line_number == 0 and line.startswith(")"):
317
+ feature_location += line.strip()
318
+ elif line[0] == "/":
319
+ # New qualifier
320
+ i = line.find("=")
321
+ key = line[1:i] # does not work if i==-1
322
+ value = line[i + 1 :] # we ignore 'value' if i==-1
323
+ if i and value.startswith(" ") and value.lstrip().startswith('"'):
324
+ warnings.warn(
325
+ "White space after equals in qualifier",
326
+ BiopythonParserWarning,
327
+ )
328
+ value = value.lstrip()
329
+ if i == -1:
330
+ # Qualifier with no key, e.g. /pseudo
331
+ key = line[1:]
332
+ qualifiers.append((key, None))
333
+ elif not value:
334
+ # ApE can output /note=
335
+ qualifiers.append((key, ""))
336
+ elif value == '"':
337
+ # One single quote
338
+ if self.debug:
339
+ print(f"Single quote {key}:{value}")
340
+ # DO NOT remove the quote...
341
+ qualifiers.append((key, value))
342
+ elif value[0] == '"':
343
+ # Quoted...
344
+ value_list = [value]
345
+ while value_list[-1][-1] != '"':
346
+ value_list.append(next(iterator))
347
+ value = "\n".join(value_list)
348
+ # DO NOT remove the quotes...
349
+ qualifiers.append((key, value))
350
+ else:
351
+ # Unquoted
352
+ # if debug : print("Unquoted line %s:%s" % (key,value))
353
+ qualifiers.append((key, value))
354
+ else:
355
+ # Unquoted continuation
356
+ assert len(qualifiers) > 0
357
+ assert key == qualifiers[-1][0]
358
+ # if debug : print("Unquoted Cont %s:%s" % (key, line))
359
+ if qualifiers[-1][1] is None:
360
+ raise StopIteration
361
+ qualifiers[-1] = (key, qualifiers[-1][1] + "\n" + line)
362
+ return feature_key, feature_location, qualifiers
363
+ except StopIteration:
364
+ # Bummer
365
+ raise ValueError(
366
+ "Problem with '%s' feature:\n%s" % (feature_key, "\n".join(lines))
367
+ ) from None
368
+
369
+ def parse_footer(self):
370
+ """Return a tuple containing a list of any misc strings, and the sequence."""
371
+ # This is a basic bit of code to scan and discard the sequence,
372
+ # which was useful when developing the sub classes.
373
+ if self.line in self.FEATURE_END_MARKERS:
374
+ while self.line[: self.HEADER_WIDTH].rstrip() not in self.SEQUENCE_HEADERS:
375
+ self.line = self.handle.readline()
376
+ if not self.line:
377
+ raise ValueError("Premature end of file")
378
+ self.line = self.line.rstrip()
379
+
380
+ if self.line[: self.HEADER_WIDTH].rstrip() not in self.SEQUENCE_HEADERS:
381
+ raise ValueError("Not at start of sequence")
382
+ while True:
383
+ line = self.handle.readline()
384
+ if not line:
385
+ raise ValueError("Premature end of line during sequence data")
386
+ line = line.rstrip()
387
+ if line == "//":
388
+ break
389
+ self.line = line
390
+ return [], "" # Dummy values!
391
+
392
+ def _feed_first_line(self, consumer, line):
393
+ """Handle the LOCUS/ID line, passing data to the consumer (PRIVATE).
394
+
395
+ This should be implemented by the EMBL / GenBank specific subclass
396
+
397
+ Used by the parse_records() and parse() methods.
398
+ """
399
+
400
+ def _feed_header_lines(self, consumer, lines):
401
+ """Handle the header lines (list of strings), passing data to the consumer (PRIVATE).
402
+
403
+ This should be implemented by the EMBL / GenBank specific subclass
404
+
405
+ Used by the parse_records() and parse() methods.
406
+ """
407
+
408
+ @staticmethod
409
+ def _feed_feature_table(consumer, feature_tuples):
410
+ """Handle the feature table (list of tuples), passing data to the consumer (PRIVATE).
411
+
412
+ Used by the parse_records() and parse() methods.
413
+ """
414
+ consumer.start_feature_table()
415
+ for feature_key, location_string, qualifiers in feature_tuples:
416
+ consumer.feature_key(feature_key)
417
+ consumer.location(location_string)
418
+ for q_key, q_value in qualifiers:
419
+ if q_value is None:
420
+ consumer.feature_qualifier(q_key, q_value)
421
+ else:
422
+ consumer.feature_qualifier(q_key, q_value.replace("\n", " "))
423
+
424
+ def _feed_misc_lines(self, consumer, lines):
425
+ """Handle any lines between features and sequence (list of strings), passing data to the consumer (PRIVATE).
426
+
427
+ This should be implemented by the EMBL / GenBank specific subclass
428
+
429
+ Used by the parse_records() and parse() methods.
430
+ """
431
+
432
+ def feed(self, handle, consumer, do_features=True):
433
+ """Feed a set of data into the consumer.
434
+
435
+ This method is intended for use with the "old" code in Bio.GenBank
436
+
437
+ Arguments:
438
+ - handle - A handle with the information to parse.
439
+ - consumer - The consumer that should be informed of events.
440
+ - do_features - Boolean, should the features be parsed?
441
+ Skipping the features can be much faster.
442
+
443
+ Return values:
444
+ - true - Passed a record
445
+ - false - Did not find a record
446
+
447
+ """
448
+ # Should work with both EMBL and GenBank files provided the
449
+ # equivalent Bio.GenBank._FeatureConsumer methods are called...
450
+ self.set_handle(handle)
451
+ if not self.find_start():
452
+ # Could not find (another) record
453
+ consumer.data = None
454
+ return False
455
+
456
+ # We use the above class methods to parse the file into a simplified format.
457
+ # The first line, header lines and any misc lines after the features will be
458
+ # dealt with by GenBank / EMBL specific derived classes.
459
+
460
+ # First line and header:
461
+ self._feed_first_line(consumer, self.line)
462
+ self._feed_header_lines(consumer, self.parse_header())
463
+
464
+ # Features (common to both EMBL and GenBank):
465
+ if do_features:
466
+ self._feed_feature_table(consumer, self.parse_features(skip=False))
467
+ else:
468
+ self.parse_features(skip=True) # ignore the data
469
+
470
+ # Footer and sequence
471
+ misc_lines, sequence_string = self.parse_footer()
472
+ self._feed_misc_lines(consumer, misc_lines)
473
+
474
+ consumer.sequence(sequence_string)
475
+ # Calls to consumer.base_number() do nothing anyway
476
+ consumer.record_end("//")
477
+
478
+ assert self.line == "//"
479
+
480
+ # And we are done
481
+ return True
482
+
483
+ def parse(self, handle, do_features=True):
484
+ """Return a SeqRecord (with SeqFeatures if do_features=True).
485
+
486
+ See also the method parse_records() for use on multi-record files.
487
+ """
488
+ from Bio.GenBank import _FeatureConsumer
489
+ from Bio.GenBank.utils import FeatureValueCleaner
490
+
491
+ consumer = _FeatureConsumer(
492
+ use_fuzziness=1, feature_cleaner=FeatureValueCleaner()
493
+ )
494
+
495
+ if self.feed(handle, consumer, do_features):
496
+ return consumer.data
497
+ else:
498
+ return None
499
+
500
+ def parse_records(self, handle, do_features=True):
501
+ """Parse records, return a SeqRecord object iterator.
502
+
503
+ Each record (from the ID/LOCUS line to the // line) becomes a SeqRecord
504
+
505
+ The SeqRecord objects include SeqFeatures if do_features=True
506
+
507
+ This method is intended for use in Bio.SeqIO
508
+ """
509
+ # This is a generator function
510
+ with as_handle(handle) as handle:
511
+ while True:
512
+ record = self.parse(handle, do_features)
513
+ if record is None:
514
+ break
515
+ if record.id is None:
516
+ raise ValueError(
517
+ "Failed to parse the record's ID. Invalid ID line?"
518
+ )
519
+ if record.name == "<unknown name>":
520
+ raise ValueError(
521
+ "Failed to parse the record's name. Invalid ID line?"
522
+ )
523
+ if record.description == "<unknown description>":
524
+ raise ValueError("Failed to parse the record's description")
525
+ yield record
526
+
527
+ def parse_cds_features(
528
+ self, handle, alphabet=None, tags2id=("protein_id", "locus_tag", "product")
529
+ ):
530
+ """Parse CDS features, return SeqRecord object iterator.
531
+
532
+ Each CDS feature becomes a SeqRecord.
533
+
534
+ Arguments:
535
+ - alphabet - Obsolete, should be left as None.
536
+ - tags2id - Tuple of three strings, the feature keys to use
537
+ for the record id, name and description,
538
+
539
+ This method is intended for use in Bio.SeqIO
540
+
541
+ """
542
+ if alphabet is not None:
543
+ raise ValueError("The alphabet argument is no longer supported")
544
+ with as_handle(handle) as handle:
545
+ self.set_handle(handle)
546
+ while self.find_start():
547
+ # Got an EMBL or GenBank record...
548
+ self.parse_header() # ignore header lines!
549
+ feature_tuples = self.parse_features()
550
+ # self.parse_footer() # ignore footer lines!
551
+ while True:
552
+ line = self.handle.readline()
553
+ if not line:
554
+ break
555
+ if line[:2] == "//":
556
+ break
557
+ self.line = line.rstrip()
558
+
559
+ # Now go though those features...
560
+ for key, location_string, qualifiers in feature_tuples:
561
+ if key == "CDS":
562
+ # Create SeqRecord
563
+ # ================
564
+ # SeqRecord objects cannot be created with annotations, they
565
+ # must be added afterwards. So create an empty record and
566
+ # then populate it:
567
+ record = SeqRecord(seq=None)
568
+ annotations = record.annotations
569
+ annotations["molecule_type"] = "protein"
570
+ # Should we add a location object to the annotations?
571
+ # I *think* that only makes sense for SeqFeatures with their
572
+ # sub features...
573
+ annotations["raw_location"] = location_string.replace(" ", "")
574
+
575
+ for qualifier_name, qualifier_data in qualifiers:
576
+ if (
577
+ qualifier_data is not None
578
+ and qualifier_data[0] == '"'
579
+ and qualifier_data[-1] == '"'
580
+ ):
581
+ # Remove quotes
582
+ qualifier_data = qualifier_data[1:-1]
583
+ # Append the data to the annotation qualifier...
584
+ if qualifier_name == "translation":
585
+ assert record.seq is None, "Multiple translations!"
586
+ record.seq = Seq(qualifier_data.replace("\n", ""))
587
+ elif qualifier_name == "db_xref":
588
+ # its a list, possibly empty. Its safe to extend
589
+ record.dbxrefs.append(qualifier_data)
590
+ else:
591
+ if qualifier_data is not None:
592
+ qualifier_data = qualifier_data.replace(
593
+ "\n", " "
594
+ ).replace(" ", " ")
595
+ try:
596
+ annotations[qualifier_name] += " " + qualifier_data
597
+ except KeyError:
598
+ # Not an addition to existing data, its the first bit
599
+ annotations[qualifier_name] = qualifier_data
600
+
601
+ # Fill in the ID, Name, Description
602
+ # =================================
603
+ try:
604
+ record.id = annotations[tags2id[0]]
605
+ except KeyError:
606
+ pass
607
+ try:
608
+ record.name = annotations[tags2id[1]]
609
+ except KeyError:
610
+ pass
611
+ try:
612
+ record.description = annotations[tags2id[2]]
613
+ except KeyError:
614
+ pass
615
+
616
+ yield record
617
+
618
+
619
+ class EmblScanner(InsdcScanner):
620
+ """For extracting chunks of information in EMBL files."""
621
+
622
+ RECORD_START = "ID "
623
+ HEADER_WIDTH = 5
624
+ FEATURE_START_MARKERS = ["FH Key Location/Qualifiers", "FH"]
625
+ FEATURE_END_MARKERS = ["XX"] # XX can also mark the end of many things!
626
+ FEATURE_QUALIFIER_INDENT = 21
627
+ FEATURE_QUALIFIER_SPACER = "FT" + " " * (FEATURE_QUALIFIER_INDENT - 2)
628
+ SEQUENCE_HEADERS = ["SQ", "CO"] # Remove trailing spaces
629
+
630
+ EMBL_INDENT = HEADER_WIDTH
631
+ EMBL_SPACER = " " * EMBL_INDENT
632
+
633
+ def parse_footer(self):
634
+ """Return a tuple containing a list of any misc strings, and the sequence."""
635
+ if self.line[: self.HEADER_WIDTH].rstrip() not in self.SEQUENCE_HEADERS:
636
+ raise ValueError(f"Footer format unexpected: '{self.line}'")
637
+
638
+ # Note that the SQ line can be split into several lines...
639
+ misc_lines = []
640
+ while self.line[: self.HEADER_WIDTH].rstrip() in self.SEQUENCE_HEADERS:
641
+ misc_lines.append(self.line)
642
+ self.line = self.handle.readline()
643
+ if not self.line:
644
+ raise ValueError("Premature end of file")
645
+ self.line = self.line.rstrip()
646
+
647
+ if not (
648
+ self.line[: self.HEADER_WIDTH] == " " * self.HEADER_WIDTH
649
+ or self.line.strip() == "//"
650
+ ):
651
+ raise ValueError(f"Unexpected content after SQ or CO line: {self.line!r}")
652
+
653
+ seq_lines = []
654
+ line = self.line
655
+ while True:
656
+ if not line:
657
+ raise ValueError("Premature end of file in sequence data")
658
+ line = line.strip()
659
+ if not line:
660
+ raise ValueError("Blank line in sequence data")
661
+ if line == "//":
662
+ break
663
+ if self.line[: self.HEADER_WIDTH] != (" " * self.HEADER_WIDTH):
664
+ raise ValueError(
665
+ "Problem with characters in header line, "
666
+ " or incorrect header width: " + self.line
667
+ )
668
+ # Remove tailing number now, remove spaces later
669
+ linersplit = line.rsplit(None, 1)
670
+ if len(linersplit) == 2 and linersplit[1].isdigit():
671
+ seq_lines.append(linersplit[0])
672
+ elif line.isdigit():
673
+ # Special case of final blank line with no bases
674
+ # just the sequence coordinate
675
+ pass
676
+ else:
677
+ warnings.warn(
678
+ "EMBL sequence line missing coordinates", BiopythonParserWarning
679
+ )
680
+ seq_lines.append(line)
681
+ line = self.handle.readline()
682
+ self.line = line
683
+ return misc_lines, "".join(seq_lines).replace(" ", "")
684
+
685
+ def _feed_first_line(self, consumer, line):
686
+ assert line[: self.HEADER_WIDTH].rstrip() == "ID"
687
+ if line[self.HEADER_WIDTH :].count(";") == 6:
688
+ # Looks like the semi colon separated style introduced in 2006
689
+ self._feed_first_line_new(consumer, line)
690
+ elif line[self.HEADER_WIDTH :].count(";") == 3:
691
+ if line.rstrip().endswith(" SQ"):
692
+ # EMBL-bank patent data
693
+ self._feed_first_line_patents(consumer, line)
694
+ else:
695
+ # Looks like the pre 2006 style
696
+ self._feed_first_line_old(consumer, line)
697
+ elif line[self.HEADER_WIDTH :].count(";") == 2:
698
+ # Looks like KIKO patent data
699
+ self._feed_first_line_patents_kipo(consumer, line)
700
+ else:
701
+ raise ValueError("Did not recognise the ID line layout:\n" + line)
702
+
703
+ def _feed_first_line_patents(self, consumer, line):
704
+ # Old style EMBL patent records where ID line ended SQ
705
+ # Not 100% sure that PRT here is really molecule type and
706
+ # not the data file division...
707
+ #
708
+ # Either Non-Redundant Level 1 database records,
709
+ # ID <accession>; <molecule type>; <non-redundant level 1>; <cluster size L1>
710
+ # e.g. ID NRP_AX000635; PRT; NR1; 15 SQ
711
+ #
712
+ # Or, Non-Redundant Level 2 database records:
713
+ # ID <L2-accession>; <molecule type>; <non-redundant level 2>; <cluster size L2>
714
+ # e.g. ID NRP0000016E; PRT; NR2; 5 SQ
715
+ # e.g. ID NRP_AX000635; PRT; NR1; 15 SQ
716
+ fields = [
717
+ data.strip() for data in line[self.HEADER_WIDTH :].strip()[:-3].split(";")
718
+ ]
719
+ assert len(fields) == 4
720
+ consumer.locus(fields[0])
721
+ consumer.residue_type(fields[1]) # semi-redundant
722
+ consumer.data_file_division(fields[2])
723
+ # TODO - Record cluster size?
724
+
725
+ def _feed_first_line_patents_kipo(self, consumer, line):
726
+ # EMBL format patent sequence from KIPO, e.g.
727
+ # ftp://ftp.ebi.ac.uk/pub/databases/patentdata/kipo_prt.dat.gz
728
+ #
729
+ # e.g. ID DI500001 STANDARD; PRT; 111 AA.
730
+ #
731
+ # This follows the style of _feed_first_line_old
732
+ assert line[: self.HEADER_WIDTH].rstrip() == "ID"
733
+ fields = [line[self.HEADER_WIDTH :].split(None, 1)[0]]
734
+ fields.extend(line[self.HEADER_WIDTH :].split(None, 1)[1].split(";"))
735
+ fields = [entry.strip() for entry in fields]
736
+ """
737
+ The tokens represent:
738
+
739
+ 0. Primary accession number
740
+ (space sep)
741
+ 1. ??? (e.g. standard)
742
+ (semi-colon)
743
+ 2. Molecule type (protein)? Division? Always 'PRT'
744
+ 3. Sequence length (e.g. '111 AA.')
745
+ """
746
+ consumer.locus(fields[0]) # Should we also call the accession consumer?
747
+ # consumer.molecule_type(fields[2])
748
+ self._feed_seq_length(consumer, fields[3])
749
+
750
+ def _feed_first_line_old(self, consumer, line):
751
+ # Expects an ID line in the style before 2006, e.g.
752
+ # ID SC10H5 standard; DNA; PRO; 4870 BP.
753
+ # ID BSUB9999 standard; circular DNA; PRO; 4214630 BP.
754
+ assert line[: self.HEADER_WIDTH].rstrip() == "ID"
755
+ fields = [line[self.HEADER_WIDTH :].split(None, 1)[0]]
756
+ fields.extend(line[self.HEADER_WIDTH :].split(None, 1)[1].split(";"))
757
+ fields = [entry.strip() for entry in fields]
758
+ """
759
+ The tokens represent:
760
+
761
+ 0. Primary accession number
762
+ (space sep)
763
+ 1. ??? (e.g. standard)
764
+ (semi-colon)
765
+ 2. Topology and/or Molecule type (e.g. 'circular DNA' or 'DNA')
766
+ 3. Taxonomic division (e.g. 'PRO')
767
+ 4. Sequence length (e.g. '4639675 BP.')
768
+
769
+ """
770
+ consumer.locus(fields[0]) # Should we also call the accession consumer?
771
+ consumer.residue_type(fields[2])
772
+ if "circular" in fields[2]:
773
+ consumer.topology("circular")
774
+ consumer.molecule_type(fields[2].replace("circular", "").strip())
775
+ elif "linear" in fields[2]:
776
+ consumer.topology("linear")
777
+ consumer.molecule_type(fields[2].replace("linear", "").strip())
778
+ else:
779
+ consumer.molecule_type(fields[2].strip())
780
+ consumer.data_file_division(fields[3])
781
+ self._feed_seq_length(consumer, fields[4])
782
+
783
+ def _feed_first_line_new(self, consumer, line):
784
+ # Expects an ID line in the style introduced in 2006, e.g.
785
+ # ID X56734; SV 1; linear; mRNA; STD; PLN; 1859 BP.
786
+ # ID CD789012; SV 4; linear; genomic DNA; HTG; MAM; 500 BP.
787
+ assert line[: self.HEADER_WIDTH].rstrip() == "ID"
788
+ fields = [data.strip() for data in line[self.HEADER_WIDTH :].strip().split(";")]
789
+ assert len(fields) == 7
790
+ """
791
+ The tokens represent:
792
+
793
+ 0. Primary accession number
794
+ 1. Sequence version number
795
+ 2. Topology: 'circular' or 'linear'
796
+ 3. Molecule type (e.g. 'genomic DNA')
797
+ 4. Data class (e.g. 'STD')
798
+ 5. Taxonomic division (e.g. 'PRO')
799
+ 6. Sequence length (e.g. '4639675 BP.')
800
+
801
+ """
802
+
803
+ consumer.locus(fields[0])
804
+
805
+ # Call the accession consumer now, to make sure we record
806
+ # something as the record.id, in case there is no AC line
807
+ consumer.accession(fields[0])
808
+
809
+ # TODO - How to deal with the version field? At the moment the consumer
810
+ # will try and use this for the ID which isn't ideal for EMBL files.
811
+ version_parts = fields[1].split()
812
+ if (
813
+ len(version_parts) == 2
814
+ and version_parts[0] == "SV"
815
+ and version_parts[1].isdigit()
816
+ ):
817
+ consumer.version_suffix(version_parts[1])
818
+
819
+ # Based on how the old GenBank parser worked, merge these two:
820
+ consumer.residue_type(" ".join(fields[2:4])) # Semi-obsolete
821
+
822
+ consumer.topology(fields[2])
823
+ consumer.molecule_type(fields[3])
824
+
825
+ # consumer.xxx(fields[4]) # TODO - What should we do with the data class?
826
+
827
+ consumer.data_file_division(fields[5])
828
+
829
+ self._feed_seq_length(consumer, fields[6])
830
+
831
+ @staticmethod
832
+ def _feed_seq_length(consumer, text):
833
+ length_parts = text.split()
834
+ assert len(length_parts) == 2, f"Invalid sequence length string {text!r}"
835
+ assert length_parts[1].upper() in ["BP", "BP.", "AA", "AA."]
836
+ consumer.size(length_parts[0])
837
+
838
+ def _feed_header_lines(self, consumer, lines):
839
+ consumer_dict = {
840
+ "AC": "accession",
841
+ "SV": "version", # SV line removed in June 2006, now part of ID line
842
+ "DE": "definition",
843
+ # 'RN' : 'reference_num',
844
+ # 'RC' : reference comment... TODO
845
+ # 'RP' : 'reference_bases',
846
+ # 'RX' : reference cross reference... DOI or Pubmed
847
+ "RG": "consrtm", # optional consortium
848
+ # 'RA' : 'authors',
849
+ # 'RT' : 'title',
850
+ "RL": "journal",
851
+ "OS": "organism",
852
+ "OC": "taxonomy",
853
+ # 'DR' : data reference
854
+ "CC": "comment",
855
+ # 'XX' : splitter
856
+ }
857
+ # We have to handle the following specially:
858
+ # RX (depending on reference type...)
859
+ for line in lines:
860
+ line_type = line[: self.EMBL_INDENT].strip()
861
+ data = line[self.EMBL_INDENT :].strip()
862
+ if line_type == "XX":
863
+ pass
864
+ elif line_type == "RN":
865
+ # Reformat reference numbers for the GenBank based consumer
866
+ # e.g. '[1]' becomes '1'
867
+ if data[0] == "[" and data[-1] == "]":
868
+ data = data[1:-1]
869
+ consumer.reference_num(data)
870
+ elif line_type == "RP":
871
+ if data.strip() == "[-]":
872
+ # Patent EMBL files from KIPO just use: RN [-]
873
+ pass
874
+ else:
875
+ # Reformat reference numbers for the GenBank based consumer
876
+ # e.g. '1-4639675' becomes '(bases 1 to 4639675)'
877
+ # and '160-550, 904-1055' becomes '(bases 160 to 550; 904 to 1055)'
878
+ # Note could be multi-line, and end with a comma
879
+ parts = [
880
+ bases.replace("-", " to ").strip()
881
+ for bases in data.split(",")
882
+ if bases.strip()
883
+ ]
884
+ consumer.reference_bases(f"(bases {'; '.join(parts)})")
885
+ elif line_type == "RT":
886
+ # Remove the enclosing quotes and trailing semi colon.
887
+ # Note the title can be split over multiple lines.
888
+ if data.startswith('"'):
889
+ data = data[1:]
890
+ if data.endswith('";'):
891
+ data = data[:-2]
892
+ consumer.title(data)
893
+ elif line_type == "RX":
894
+ # EMBL support three reference types at the moment:
895
+ # - PUBMED PUBMED bibliographic database (NLM)
896
+ # - DOI Digital Object Identifier (International DOI Foundation)
897
+ # - AGRICOLA US National Agriculture Library (NAL) of the US Department
898
+ # of Agriculture (USDA)
899
+ #
900
+ # Format:
901
+ # RX resource_identifier; identifier.
902
+ #
903
+ # e.g.
904
+ # RX DOI; 10.1016/0024-3205(83)90010-3.
905
+ # RX PUBMED; 264242.
906
+ #
907
+ # Currently our reference object only supports PUBMED and MEDLINE
908
+ # (as these were in GenBank files?).
909
+ key, value = data.split(";", 1)
910
+ if value.endswith("."):
911
+ value = value[:-1]
912
+ value = value.strip()
913
+ if key == "PUBMED":
914
+ consumer.pubmed_id(value)
915
+ # TODO - Handle other reference types (here and in BioSQL bindings)
916
+ elif line_type == "CC":
917
+ # Have to pass a list of strings for this one (not just a string)
918
+ consumer.comment([data])
919
+ elif line_type == "DR":
920
+ # Database Cross-reference, format:
921
+ # DR database_identifier; primary_identifier; secondary_identifier.
922
+ #
923
+ # e.g.
924
+ # DR MGI; 98599; Tcrb-V4.
925
+ #
926
+ # TODO - How should we store any secondary identifier?
927
+ parts = data.rstrip(".").split(";")
928
+ # Turn it into "database_identifier:primary_identifier" to
929
+ # mimic the GenBank parser. e.g. "MGI:98599"
930
+ if len(parts) == 1:
931
+ warnings.warn(
932
+ "Malformed DR line in EMBL file.", BiopythonParserWarning
933
+ )
934
+ else:
935
+ consumer.dblink(f"{parts[0].strip()}:{parts[1].strip()}")
936
+ elif line_type == "RA":
937
+ # Remove trailing ; at end of authors list
938
+ consumer.authors(data.rstrip(";"))
939
+ elif line_type == "PR":
940
+ # In the EMBL patent files, this is a PR (PRiority) line which
941
+ # provides the earliest active priority within the family.
942
+ # The priority number comes first, followed by the priority date.
943
+ #
944
+ # e.g.
945
+ # PR JP19990377484 16-DEC-1999
946
+ #
947
+ # However, in most EMBL files this is a PR (PRoject) line which
948
+ # gives the BioProject reference number.
949
+ #
950
+ # e.g.
951
+ # PR Project:PRJNA60715;
952
+ #
953
+ # In GenBank files this corresponds to the old PROJECT line
954
+ # which was later replaced with the DBLINK line.
955
+ if data.startswith("Project:"):
956
+ # Remove trailing ; at end of the project reference
957
+ consumer.project(data.rstrip(";"))
958
+ elif line_type == "KW":
959
+ consumer.keywords(data.rstrip(";"))
960
+ elif line_type in consumer_dict:
961
+ # Its a semi-automatic entry!
962
+ getattr(consumer, consumer_dict[line_type])(data)
963
+ else:
964
+ if self.debug:
965
+ print(f"Ignoring EMBL header line:\n{line}")
966
+
967
+ def _feed_misc_lines(self, consumer, lines):
968
+ # TODO - Should we do something with the information on the SQ line(s)?
969
+ lines.append("")
970
+ line_iter = iter(lines)
971
+ try:
972
+ for line in line_iter:
973
+ if line.startswith("CO "):
974
+ line = line[5:].strip()
975
+ contig_location = line
976
+ while True:
977
+ line = next(line_iter)
978
+ if not line:
979
+ break
980
+ elif line.startswith("CO "):
981
+ # Don't need to preserve the whitespace here.
982
+ contig_location += line[5:].strip()
983
+ else:
984
+ raise ValueError(
985
+ "Expected CO (contig) continuation line, got:\n" + line
986
+ )
987
+ consumer.contig_location(contig_location)
988
+ if line.startswith("SQ Sequence "):
989
+ # e.g.
990
+ # SQ Sequence 219 BP; 82 A; 48 C; 33 G; 45 T; 11 other;
991
+ #
992
+ # Or, EMBL-bank patent, e.g.
993
+ # SQ Sequence 465 AA; 3963407aa91d3a0d622fec679a4524e0; MD5;
994
+ self._feed_seq_length(
995
+ consumer, line[14:].rstrip().rstrip(";").split(";", 1)[0]
996
+ )
997
+ # TODO - Record the checksum etc?
998
+ return
999
+ except StopIteration:
1000
+ raise ValueError("Problem in misc lines before sequence") from None
1001
+
1002
+
1003
+ class _ImgtScanner(EmblScanner):
1004
+ """For extracting chunks of information in IMGT (EMBL like) files (PRIVATE).
1005
+
1006
+ IMGT files are like EMBL files but in order to allow longer feature types
1007
+ the features should be indented by 25 characters not 21 characters. In
1008
+ practice the IMGT flat files tend to use either 21 or 25 characters, so we
1009
+ must cope with both.
1010
+
1011
+ This is private to encourage use of Bio.SeqIO rather than Bio.GenBank.
1012
+ """
1013
+
1014
+ FEATURE_START_MARKERS = [
1015
+ "FH Key Location/Qualifiers",
1016
+ "FH Key Location/Qualifiers (from EMBL)",
1017
+ "FH Key Location/Qualifiers",
1018
+ "FH",
1019
+ ]
1020
+
1021
+ def _feed_first_line(self, consumer, line):
1022
+ assert line[: self.HEADER_WIDTH].rstrip() == "ID"
1023
+ if line[self.HEADER_WIDTH :].count(";") != 5:
1024
+ # Assume its an older EMBL-like line,
1025
+ return EmblScanner._feed_first_line(self, consumer, line)
1026
+ # Otherwise assume its the new (circa 2016) IMGT style
1027
+ # as used in the IPD-IMGT/HLA Database
1028
+ #
1029
+ # https://github.com/ANHIG/IMGTHLA/
1030
+ #
1031
+ # The key changes post 3.16 are the addition of an SV value
1032
+ # to the ID line, these additions should make the format more
1033
+ # similar to the ENA style.
1034
+ #
1035
+ # ID HLA00001 standard; DNA; HUM; 3503 BP.
1036
+ #
1037
+ # becomes
1038
+ #
1039
+ # ID HLA00001; SV 1; standard; DNA; HUM; 3503 BP.
1040
+ fields = [data.strip() for data in line[self.HEADER_WIDTH :].strip().split(";")]
1041
+ assert len(fields) == 6
1042
+ """
1043
+ The tokens represent:
1044
+
1045
+ 0. Primary accession number (eg 'HLA00001')
1046
+ 1. Sequence version number (eg 'SV 1')
1047
+ 2. ??? eg 'standard'
1048
+ 3. Molecule type (e.g. 'DNA')
1049
+ 4. Taxonomic division (e.g. 'HUM')
1050
+ 5. Sequence length (e.g. '3503 BP.')
1051
+ """
1052
+ consumer.locus(fields[0])
1053
+
1054
+ # See TODO on the EMBL _feed_first_line_new about version field
1055
+ version_parts = fields[1].split()
1056
+ if (
1057
+ len(version_parts) == 2
1058
+ and version_parts[0] == "SV"
1059
+ and version_parts[1].isdigit()
1060
+ ):
1061
+ consumer.version_suffix(version_parts[1])
1062
+
1063
+ consumer.residue_type(fields[3])
1064
+ if "circular" in fields[3]:
1065
+ consumer.topology("circular")
1066
+ consumer.molecule_type(fields[3].replace("circular", "").strip())
1067
+ elif "linear" in fields[3]:
1068
+ consumer.topology("linear")
1069
+ consumer.molecule_type(fields[3].replace("linear", "").strip())
1070
+ else:
1071
+ consumer.molecule_type(fields[3].strip())
1072
+ consumer.data_file_division(fields[4])
1073
+ self._feed_seq_length(consumer, fields[5])
1074
+
1075
+ def parse_features(self, skip=False):
1076
+ """Return list of tuples for the features (if present).
1077
+
1078
+ Each feature is returned as a tuple (key, location, qualifiers)
1079
+ where key and location are strings (e.g. "CDS" and
1080
+ "complement(join(490883..490885,1..879))") while qualifiers
1081
+ is a list of two string tuples (feature qualifier keys and values).
1082
+
1083
+ Assumes you have already read to the start of the features table.
1084
+ """
1085
+ if self.line.rstrip() not in self.FEATURE_START_MARKERS:
1086
+ if self.debug:
1087
+ print("Didn't find any feature table")
1088
+ return []
1089
+
1090
+ while self.line.rstrip() in self.FEATURE_START_MARKERS:
1091
+ self.line = self.handle.readline()
1092
+
1093
+ bad_position_re = re.compile(r"([0-9]+)>")
1094
+
1095
+ features = []
1096
+ line = self.line
1097
+ while True:
1098
+ if not line:
1099
+ raise ValueError("Premature end of line during features table")
1100
+ if line[: self.HEADER_WIDTH].rstrip() in self.SEQUENCE_HEADERS:
1101
+ if self.debug:
1102
+ print("Found start of sequence")
1103
+ break
1104
+ line = line.rstrip()
1105
+ if line == "//":
1106
+ raise ValueError("Premature end of features table, marker '//' found")
1107
+ if line in self.FEATURE_END_MARKERS:
1108
+ if self.debug:
1109
+ print("Found end of features")
1110
+ line = self.handle.readline()
1111
+ break
1112
+ if line[2 : self.FEATURE_QUALIFIER_INDENT].strip() == "":
1113
+ # This is an empty feature line between qualifiers. Empty
1114
+ # feature lines within qualifiers are handled below (ignored).
1115
+ line = self.handle.readline()
1116
+ continue
1117
+
1118
+ if skip:
1119
+ line = self.handle.readline()
1120
+ while (
1121
+ line[: self.FEATURE_QUALIFIER_INDENT]
1122
+ == self.FEATURE_QUALIFIER_SPACER
1123
+ ):
1124
+ line = self.handle.readline()
1125
+ else:
1126
+ assert line[:2] == "FT"
1127
+ try:
1128
+ feature_key, location_start = line[2:].strip().split()
1129
+ except ValueError:
1130
+ # e.g. "FT TRANSMEMBRANE-REGION2163..2240\n"
1131
+ # Assume indent of 25 as per IMGT spec, with the location
1132
+ # start in column 26 (one-based).
1133
+ feature_key = line[2:25].strip()
1134
+ location_start = line[25:].strip()
1135
+ feature_lines = [location_start]
1136
+ line = self.handle.readline()
1137
+ while (
1138
+ line[: self.FEATURE_QUALIFIER_INDENT]
1139
+ == self.FEATURE_QUALIFIER_SPACER
1140
+ or line.rstrip() == ""
1141
+ ): # cope with blank lines in the midst of a feature
1142
+ # Use strip to remove any harmless trailing white space AND and leading
1143
+ # white space (copes with 21 or 26 indents and orther variants)
1144
+ assert line[:2] == "FT"
1145
+ feature_lines.append(line[self.FEATURE_QUALIFIER_INDENT :].strip())
1146
+ line = self.handle.readline()
1147
+ feature_key, location, qualifiers = self.parse_feature(
1148
+ feature_key, feature_lines
1149
+ )
1150
+ # Try to handle known problems with IMGT locations here:
1151
+ if ">" in location:
1152
+ # Nasty hack for common IMGT bug, should be >123 not 123>
1153
+ # in a location string. At least here the meaning is clear,
1154
+ # and since it is so common I don't want to issue a warning
1155
+ # warnings.warn("Feature location %s is invalid, "
1156
+ # "moving greater than sign before position"
1157
+ # % location, BiopythonParserWarning)
1158
+ location = bad_position_re.sub(r">\1", location)
1159
+ features.append((feature_key, location, qualifiers))
1160
+ self.line = line
1161
+ return features
1162
+
1163
+
1164
+ class GenBankScanner(InsdcScanner):
1165
+ """For extracting chunks of information in GenBank files."""
1166
+
1167
+ RECORD_START = "LOCUS "
1168
+ HEADER_WIDTH = 12
1169
+ FEATURE_START_MARKERS = ["FEATURES Location/Qualifiers", "FEATURES"]
1170
+ FEATURE_END_MARKERS: list[str] = []
1171
+ FEATURE_QUALIFIER_INDENT = 21
1172
+ FEATURE_QUALIFIER_SPACER = " " * FEATURE_QUALIFIER_INDENT
1173
+ SEQUENCE_HEADERS = [
1174
+ "CONTIG",
1175
+ "ORIGIN",
1176
+ "BASE COUNT",
1177
+ "WGS",
1178
+ "TSA",
1179
+ "TLS",
1180
+ ] # trailing spaces removed
1181
+
1182
+ GENBANK_INDENT = HEADER_WIDTH
1183
+ GENBANK_SPACER = " " * GENBANK_INDENT
1184
+
1185
+ STRUCTURED_COMMENT_START = "-START##"
1186
+ STRUCTURED_COMMENT_END = "-END##"
1187
+ STRUCTURED_COMMENT_DELIM = " :: "
1188
+
1189
+ def parse_footer(self):
1190
+ """Return a tuple containing a list of any misc strings, and the sequence."""
1191
+ if self.line[: self.HEADER_WIDTH].rstrip() not in self.SEQUENCE_HEADERS:
1192
+ raise ValueError(f"Footer format unexpected: '{self.line}'")
1193
+
1194
+ misc_lines = []
1195
+ while (
1196
+ self.line[: self.HEADER_WIDTH].rstrip() in self.SEQUENCE_HEADERS
1197
+ or self.line[: self.HEADER_WIDTH] == " " * self.HEADER_WIDTH
1198
+ or "WGS" == self.line[:3]
1199
+ ):
1200
+ misc_lines.append(self.line.rstrip())
1201
+ self.line = self.handle.readline()
1202
+ if not self.line:
1203
+ raise ValueError("Premature end of file")
1204
+
1205
+ if self.line[: self.HEADER_WIDTH].rstrip() in self.SEQUENCE_HEADERS:
1206
+ raise ValueError(f"Eh? '{self.line}'")
1207
+
1208
+ # Now just consume the sequence lines until reach the // marker
1209
+ # or a CONTIG line
1210
+ seq_lines = []
1211
+ line = self.line
1212
+ while True:
1213
+ if not line:
1214
+ warnings.warn(
1215
+ "Premature end of file in sequence data", BiopythonParserWarning
1216
+ )
1217
+ line = "//"
1218
+ break
1219
+ line = line.rstrip()
1220
+ if not line:
1221
+ warnings.warn("Blank line in sequence data", BiopythonParserWarning)
1222
+ line = self.handle.readline()
1223
+ continue
1224
+ if line == "//":
1225
+ break
1226
+ if line.startswith("CONTIG"):
1227
+ break
1228
+ if len(line) > 9 and line[9:10] != " ":
1229
+ # Some broken programs indent the sequence by one space too many
1230
+ # so try to get rid of that and test again.
1231
+ warnings.warn(
1232
+ "Invalid indentation for sequence line", BiopythonParserWarning
1233
+ )
1234
+ line = line[1:]
1235
+ if len(line) > 9 and line[9:10] != " ":
1236
+ raise ValueError(f"Sequence line mal-formed, '{line}'")
1237
+ seq_lines.append(line[10:]) # remove spaces later
1238
+ line = self.handle.readline()
1239
+
1240
+ self.line = line
1241
+ return misc_lines, "".join(seq_lines).replace(" ", "")
1242
+
1243
+ def _feed_first_line(self, consumer, line):
1244
+ """Scan over and parse GenBank LOCUS line (PRIVATE).
1245
+
1246
+ This must cope with several variants, primarily the old and new column
1247
+ based standards from GenBank. Additionally EnsEMBL produces GenBank
1248
+ files where the LOCUS line is space separated rather that following
1249
+ the column based layout.
1250
+
1251
+ We also try to cope with GenBank like files with partial LOCUS lines.
1252
+
1253
+ As of release 229.0, the columns are no longer strictly in a given
1254
+ position. See GenBank format release notes:
1255
+
1256
+ "Historically, the LOCUS line has had a fixed length and its
1257
+ elements have been presented at specific column positions...
1258
+ But with the anticipated increases in the lengths of accession
1259
+ numbers, and the advent of sequences that are gigabases long,
1260
+ maintaining the column positions will not always be possible and
1261
+ the overall length of the LOCUS line could exceed 79 characters."
1262
+
1263
+ """
1264
+ #####################################
1265
+ # LOCUS line #
1266
+ #####################################
1267
+ if line[0 : self.GENBANK_INDENT] != "LOCUS ":
1268
+ raise ValueError("LOCUS line does not start correctly:\n" + line)
1269
+
1270
+ # Have to break up the locus line, and handle the different bits of it.
1271
+ # There are at least two different versions of the locus line...
1272
+ if line[29:33] in [" bp ", " aa ", " rc "] and line[55:62] == " ":
1273
+ # Old... note we insist on the 55:62 being empty to avoid trying
1274
+ # to parse space separated LOCUS lines from Ensembl etc, see below.
1275
+ #
1276
+ # Positions Contents
1277
+ # --------- --------
1278
+ # 00:06 LOCUS
1279
+ # 06:12 spaces
1280
+ # 12:?? Locus name
1281
+ # ??:?? space
1282
+ # ??:29 Length of sequence, right-justified
1283
+ # 29:33 space, bp, space
1284
+ # 33:41 strand type / molecule type, e.g. DNA
1285
+ # 41:42 space
1286
+ # 42:51 Blank (implies linear), linear or circular
1287
+ # 51:52 space
1288
+ # 52:55 The division code (e.g. BCT, VRL, INV)
1289
+ # 55:62 space
1290
+ # 62:73 Date, in the form dd-MMM-yyyy (e.g., 15-MAR-1991)
1291
+ #
1292
+ # assert line[29:33] in [' bp ', ' aa ',' rc '] , \
1293
+ # 'LOCUS line does not contain size units at expected position:\n' + line
1294
+ if line[41:42] != " ":
1295
+ raise ValueError(
1296
+ "LOCUS line does not contain space at position 42:\n" + line
1297
+ )
1298
+ if line[42:51].strip() not in ["", "linear", "circular"]:
1299
+ raise ValueError(
1300
+ "LOCUS line does not contain valid entry "
1301
+ "(linear, circular, ...):\n" + line
1302
+ )
1303
+ if line[51:52] != " ":
1304
+ raise ValueError(
1305
+ "LOCUS line does not contain space at position 52:\n" + line
1306
+ )
1307
+ # if line[55:62] != ' ':
1308
+ # raise ValueError('LOCUS line does not contain spaces from position 56 to 62:\n' + line)
1309
+ parse_date = False
1310
+ if line[62:73].strip():
1311
+ parse_date = True
1312
+ if line[64:65] != "-":
1313
+ parse_date = False
1314
+ warnings.warn(
1315
+ "LOCUS line does not contain - "
1316
+ "at position 65 in date:\n" + line,
1317
+ BiopythonParserWarning,
1318
+ )
1319
+ if line[68:69] != "-":
1320
+ parse_date = False
1321
+ warnings.warn(
1322
+ "LOCUS line does not contain - "
1323
+ "at position 69 in date:\n" + line,
1324
+ BiopythonParserWarning,
1325
+ )
1326
+
1327
+ name_and_length_str = line[self.GENBANK_INDENT : 29]
1328
+ while " " in name_and_length_str:
1329
+ name_and_length_str = name_and_length_str.replace(" ", " ")
1330
+ name_and_length = name_and_length_str.split(" ")
1331
+ if len(name_and_length) > 2:
1332
+ raise ValueError(
1333
+ "Cannot parse the name and length in the LOCUS line:\n" + line
1334
+ )
1335
+ if len(name_and_length) == 1:
1336
+ raise ValueError("Name and length collide in the LOCUS line:\n" + line)
1337
+ # Should be possible to split them based on position, if
1338
+ # a clear definition of the standard exists THAT AGREES with
1339
+ # existing files.
1340
+ name, length = name_and_length
1341
+ if len(name) > 16:
1342
+ # As long as the sequence is short, can steal its leading spaces
1343
+ # to extend the name over the current 16 character limit.
1344
+ # However, that deserves a warning as it is out of spec.
1345
+ warnings.warn(
1346
+ "GenBank LOCUS line identifier over 16 characters",
1347
+ BiopythonParserWarning,
1348
+ )
1349
+ consumer.locus(name)
1350
+ consumer.size(length)
1351
+ # consumer.residue_type(line[33:41].strip())
1352
+
1353
+ if line[33:51].strip() == "" and line[29:33] == " aa ":
1354
+ # Amino acids -> protein (even if there is no residue type given)
1355
+ consumer.residue_type("PROTEIN")
1356
+ else:
1357
+ consumer.residue_type(line[33:51].strip())
1358
+
1359
+ consumer.molecule_type(line[33:41].strip())
1360
+ consumer.topology(line[42:51].strip())
1361
+ consumer.data_file_division(line[52:55])
1362
+ if parse_date:
1363
+ consumer.date(line[62:73])
1364
+ elif line[40:44] in [" bp ", " aa ", " rc "] and line[54:64].strip() in [
1365
+ "",
1366
+ "linear",
1367
+ "circular",
1368
+ ]:
1369
+ # New... linear/circular/big blank test should avoid EnsEMBL style
1370
+ # LOCUS line being treated like a proper column based LOCUS line.
1371
+ #
1372
+ # Positions Contents
1373
+ # --------- --------
1374
+ # 00:06 LOCUS
1375
+ # 06:12 spaces
1376
+ # 12:?? Locus name
1377
+ # ??:?? space
1378
+ # ??:40 Length of sequence, right-justified
1379
+ # 40:44 space, bp, space
1380
+ # 44:47 Blank, ss-, ds-, ms-
1381
+ # 47:54 Blank, DNA, RNA, tRNA, mRNA, uRNA, snRNA, cDNA
1382
+ # 54:55 space
1383
+ # 55:63 Blank (implies linear), linear or circular
1384
+ # 63:64 space
1385
+ # 64:67 The division code (e.g. BCT, VRL, INV)
1386
+ # 67:68 space
1387
+ # 68:79 Date, in the form dd-MMM-yyyy (e.g., 15-MAR-1991)
1388
+ #
1389
+ if len(line) < 79:
1390
+ # JBEI genbank files seem to miss a division code and date
1391
+ # See issue #1656 e.g.
1392
+ # LOCUS pEH010 5743 bp DNA circular
1393
+ warnings.warn(
1394
+ f"Truncated LOCUS line found - is this correct?\n:{line!r}",
1395
+ BiopythonParserWarning,
1396
+ )
1397
+ padding_len = 79 - len(line)
1398
+ padding = " " * padding_len
1399
+ line += padding
1400
+
1401
+ if line[40:44] not in [" bp ", " aa ", " rc "]:
1402
+ raise ValueError(
1403
+ "LOCUS line does not contain size units at "
1404
+ "expected position:\n" + line
1405
+ )
1406
+ if line[44:47] not in [" ", "ss-", "ds-", "ms-"]:
1407
+ raise ValueError(
1408
+ "LOCUS line does not have valid strand "
1409
+ "type (Single stranded, ...):\n" + line
1410
+ )
1411
+
1412
+ if not (
1413
+ line[47:54].strip() == ""
1414
+ or "DNA" in line[47:54].strip().upper()
1415
+ or "RNA" in line[47:54].strip().upper()
1416
+ ):
1417
+ raise ValueError(
1418
+ "LOCUS line does not contain valid "
1419
+ "sequence type (DNA, RNA, ...):\n" + line
1420
+ )
1421
+ if line[54:55] != " ":
1422
+ raise ValueError(
1423
+ "LOCUS line does not contain space at position 55:\n" + line
1424
+ )
1425
+ if line[55:63].strip() not in ["", "linear", "circular"]:
1426
+ raise ValueError(
1427
+ "LOCUS line does not contain valid "
1428
+ "entry (linear, circular, ...):\n" + line
1429
+ )
1430
+ if line[63:64] != " ":
1431
+ raise ValueError(
1432
+ "LOCUS line does not contain space at position 64:\n" + line
1433
+ )
1434
+ if line[67:68] != " ":
1435
+ raise ValueError(
1436
+ "LOCUS line does not contain space at position 68:\n" + line
1437
+ )
1438
+ parse_date = False
1439
+ if line[68:79].strip():
1440
+ parse_date = True
1441
+ if line[70:71] != "-":
1442
+ parse_date = False
1443
+ warnings.warn(
1444
+ "LOCUS line does not contain - "
1445
+ "at position 71 in date:\n" + line,
1446
+ BiopythonParserWarning,
1447
+ )
1448
+ if line[74:75] != "-":
1449
+ parse_date = False
1450
+ warnings.warn(
1451
+ "LOCUS line does not contain - "
1452
+ "at position 75 in date:\n" + line,
1453
+ BiopythonParserWarning,
1454
+ )
1455
+
1456
+ name_and_length_str = line[self.GENBANK_INDENT : 40]
1457
+ while " " in name_and_length_str:
1458
+ name_and_length_str = name_and_length_str.replace(" ", " ")
1459
+ name_and_length = name_and_length_str.split(" ")
1460
+ if len(name_and_length) > 2:
1461
+ raise ValueError(
1462
+ "Cannot parse the name and length in the LOCUS line:\n" + line
1463
+ )
1464
+ if len(name_and_length) == 1:
1465
+ raise ValueError("Name and length collide in the LOCUS line:\n" + line)
1466
+ # Should be possible to split them based on position, if
1467
+ # a clear definition of the stand exists THAT AGREES with
1468
+ # existing files.
1469
+ consumer.locus(name_and_length[0])
1470
+ consumer.size(name_and_length[1])
1471
+
1472
+ if line[44:54].strip() == "" and line[40:44] == " aa ":
1473
+ # Amino acids -> protein (even if there is no residue type given)
1474
+ consumer.residue_type(("PROTEIN " + line[54:63]).strip())
1475
+ else:
1476
+ consumer.residue_type(line[44:63].strip())
1477
+
1478
+ consumer.molecule_type(line[44:54].strip())
1479
+ consumer.topology(line[55:63].strip())
1480
+ if line[64:76].strip():
1481
+ consumer.data_file_division(line[64:67])
1482
+ if parse_date:
1483
+ consumer.date(line[68:79])
1484
+ elif line[self.GENBANK_INDENT :].strip().count(" ") == 0:
1485
+ # Truncated LOCUS line, as produced by some EMBOSS tools - see bug 1762
1486
+ #
1487
+ # e.g.
1488
+ #
1489
+ # "LOCUS U00096"
1490
+ #
1491
+ # rather than:
1492
+ #
1493
+ # "LOCUS U00096 4639675 bp DNA circular BCT"
1494
+ #
1495
+ # Positions Contents
1496
+ # --------- --------
1497
+ # 00:06 LOCUS
1498
+ # 06:12 spaces
1499
+ # 12:?? Locus name
1500
+ if line[self.GENBANK_INDENT :].strip() != "":
1501
+ consumer.locus(line[self.GENBANK_INDENT :].strip())
1502
+ else:
1503
+ # Must just have just "LOCUS ", is this even legitimate?
1504
+ # We should be able to continue parsing... we need real world testcases!
1505
+ warnings.warn(
1506
+ f"Minimal LOCUS line found - is this correct?\n:{line!r}",
1507
+ BiopythonParserWarning,
1508
+ )
1509
+ elif (
1510
+ len(line.split()) == 8
1511
+ and line.split()[3] in ("aa", "bp")
1512
+ and line.split()[5] in ("linear", "circular")
1513
+ ):
1514
+ # Cope with invalidly spaced GenBank LOCUS lines like
1515
+ # LOCUS AB070938 6497 bp DNA linear BCT 11-OCT-2001
1516
+ # This will also cope with extra long accession numbers and
1517
+ # sequence lengths
1518
+ splitline = line.split()
1519
+ consumer.locus(splitline[1])
1520
+ # Provide descriptive error message if the sequence is too long
1521
+ # for python to handle
1522
+
1523
+ if int(splitline[2]) > sys.maxsize:
1524
+ raise ValueError(
1525
+ "Tried to load a sequence with a length %s, "
1526
+ "your installation of python can only load "
1527
+ "sesquences of length %s" % (splitline[2], sys.maxsize)
1528
+ )
1529
+ else:
1530
+ consumer.size(splitline[2])
1531
+
1532
+ consumer.residue_type(splitline[4])
1533
+ consumer.topology(splitline[5])
1534
+ consumer.data_file_division(splitline[6])
1535
+ consumer.date(splitline[7])
1536
+ if len(line) < 80:
1537
+ warnings.warn(
1538
+ "Attempting to parse malformed locus line:\n%r\n"
1539
+ "Found locus %r size %r residue_type %r\n"
1540
+ "Some fields may be wrong."
1541
+ % (line, splitline[1], splitline[2], splitline[4]),
1542
+ BiopythonParserWarning,
1543
+ )
1544
+ elif len(line.split()) == 7 and line.split()[3] in ["aa", "bp"]:
1545
+ # Cope with EnsEMBL genbank files which use space separation rather
1546
+ # than the expected column based layout. e.g.
1547
+ # LOCUS HG531_PATCH 1000000 bp DNA HTG 18-JUN-2011
1548
+ # LOCUS HG531_PATCH 759984 bp DNA HTG 18-JUN-2011
1549
+ # LOCUS HG506_HG1000_1_PATCH 814959 bp DNA HTG 18-JUN-2011
1550
+ # LOCUS HG506_HG1000_1_PATCH 1219964 bp DNA HTG 18-JUN-2011
1551
+ # Notice that the 'bp' can occur in the position expected by either
1552
+ # the old or the new fixed column standards (parsed above).
1553
+ splitline = line.split()
1554
+ consumer.locus(splitline[1])
1555
+ consumer.size(splitline[2])
1556
+ consumer.residue_type(splitline[4])
1557
+ consumer.data_file_division(splitline[5])
1558
+ consumer.date(splitline[6])
1559
+ elif len(line.split()) >= 4 and line.split()[3] in ["aa", "bp"]:
1560
+ # Cope with EMBOSS seqret output where it seems the locus id can cause
1561
+ # the other fields to overflow. We just IGNORE the other fields!
1562
+ warnings.warn(
1563
+ f"Malformed LOCUS line found - is this correct?\n:{line!r}",
1564
+ BiopythonParserWarning,
1565
+ )
1566
+ consumer.locus(line.split()[1])
1567
+ consumer.size(line.split()[2])
1568
+ elif len(line.split()) >= 4 and line.split()[-1] in ["aa", "bp"]:
1569
+ # Cope with pseudo-GenBank files like this:
1570
+ # "LOCUS RNA5 complete 1718 bp"
1571
+ # Treat everything between LOCUS and the size as the identifier.
1572
+ warnings.warn(
1573
+ f"Malformed LOCUS line found - is this correct?\n:{line!r}",
1574
+ BiopythonParserWarning,
1575
+ )
1576
+ consumer.locus(line[5:].rsplit(None, 2)[0].strip())
1577
+ consumer.size(line.split()[-2])
1578
+ else:
1579
+ raise ValueError("Did not recognise the LOCUS line layout:\n" + line)
1580
+
1581
+ def _feed_header_lines(self, consumer, lines):
1582
+ # Following dictionary maps GenBank lines to the associated
1583
+ # consumer methods - the special cases like LOCUS where one
1584
+ # genbank line triggers several consumer calls have to be
1585
+ # handled individually.
1586
+ consumer_dict = {
1587
+ "DEFINITION": "definition",
1588
+ "ACCESSION": "accession",
1589
+ "NID": "nid",
1590
+ "PID": "pid",
1591
+ "DBSOURCE": "db_source",
1592
+ "KEYWORDS": "keywords",
1593
+ "SEGMENT": "segment",
1594
+ "SOURCE": "source",
1595
+ "AUTHORS": "authors",
1596
+ "CONSRTM": "consrtm",
1597
+ "PROJECT": "project",
1598
+ "TITLE": "title",
1599
+ "JOURNAL": "journal",
1600
+ "MEDLINE": "medline_id",
1601
+ "PUBMED": "pubmed_id",
1602
+ "REMARK": "remark",
1603
+ }
1604
+ # We have to handle the following specially:
1605
+ # ORIGIN (locus, size, residue_type, data_file_division and date)
1606
+ # COMMENT (comment)
1607
+ # VERSION (version and gi)
1608
+ # DBLINK (database links like projects, newlines important)
1609
+ # REFERENCE (eference_num and reference_bases)
1610
+ # ORGANISM (organism and taxonomy)
1611
+ lines = [_f for _f in lines if _f]
1612
+ lines.append("") # helps avoid getting StopIteration all the time
1613
+ line_iter = iter(lines)
1614
+ try:
1615
+ line = next(line_iter)
1616
+ while True:
1617
+ if not line:
1618
+ break
1619
+ line_type = line[: self.GENBANK_INDENT].strip()
1620
+ data = line[self.GENBANK_INDENT :].strip()
1621
+
1622
+ if line_type == "VERSION":
1623
+ # Need to call consumer.version(), and maybe also consumer.gi() as well.
1624
+ # e.g.
1625
+ # VERSION AC007323.5 GI:6587720
1626
+ while " " in data:
1627
+ data = data.replace(" ", " ")
1628
+ if " GI:" not in data:
1629
+ consumer.version(data)
1630
+ else:
1631
+ if self.debug:
1632
+ print(
1633
+ "Version ["
1634
+ + data.split(" GI:")[0]
1635
+ + "], gi ["
1636
+ + data.split(" GI:")[1]
1637
+ + "]"
1638
+ )
1639
+ consumer.version(data.split(" GI:")[0])
1640
+ consumer.gi(data.split(" GI:")[1])
1641
+ # Read in the next line!
1642
+ line = next(line_iter)
1643
+ elif line_type == "DBLINK":
1644
+ # Need to call consumer.dblink() for each line, e.g.
1645
+ # DBLINK Project: 57779
1646
+ # BioProject: PRJNA57779
1647
+ line = data.strip()
1648
+ # Read in the next line, and see if its more of the DBLINK section:
1649
+ while True:
1650
+ next_line = next(line_iter)
1651
+ if next_line[: self.GENBANK_INDENT] == self.GENBANK_SPACER:
1652
+ # No new tag on next line, continue to add dbrefs
1653
+ if next_line.count(":") == 0:
1654
+ # This is a continuation of previous dbref
1655
+ line += " " + next_line.strip()
1656
+ else:
1657
+ # Add this continuation to the data string
1658
+ consumer.dblink(line.strip())
1659
+ line = next_line
1660
+ continue
1661
+ else:
1662
+ # Add this continuation to the data string
1663
+ consumer.dblink(line.strip())
1664
+ # End of the DBLINK, leave this text in the variable "line"
1665
+ line = next_line
1666
+ break
1667
+ line = next(line_iter)
1668
+ elif line_type == "REFERENCE":
1669
+ if self.debug > 1:
1670
+ print("Found reference [" + data + "]")
1671
+ # Need to call consumer.reference_num() and consumer.reference_bases()
1672
+ # e.g.
1673
+ # REFERENCE 1 (bases 1 to 86436)
1674
+ #
1675
+ # Note that this can be multiline, see Bug 1968, e.g.
1676
+ #
1677
+ # REFERENCE 42 (bases 1517 to 1696; 3932 to 4112; 17880 to 17975; 21142 to
1678
+ # 28259)
1679
+ #
1680
+ # For such cases we will call the consumer once only.
1681
+ data = data.strip()
1682
+
1683
+ # Read in the next line, and see if its more of the reference:
1684
+ while True:
1685
+ line = next(line_iter)
1686
+ if line[: self.GENBANK_INDENT] == self.GENBANK_SPACER:
1687
+ # Add this continuation to the data string
1688
+ data += " " + line[self.GENBANK_INDENT :]
1689
+ if self.debug > 1:
1690
+ print("Extended reference text [" + data + "]")
1691
+ else:
1692
+ # End of the reference, leave this text in the variable "line"
1693
+ break
1694
+
1695
+ # We now have all the reference line(s) stored in a string, data,
1696
+ # which we pass to the consumer
1697
+ while " " in data:
1698
+ data = data.replace(" ", " ")
1699
+ if " " not in data:
1700
+ if self.debug > 2:
1701
+ print('Reference number "' + data + '"')
1702
+ consumer.reference_num(data)
1703
+ else:
1704
+ if self.debug > 2:
1705
+ print(
1706
+ 'Reference number "'
1707
+ + data[: data.find(" ")]
1708
+ + '", "'
1709
+ + data[data.find(" ") + 1 :]
1710
+ + '"'
1711
+ )
1712
+ consumer.reference_num(data[: data.find(" ")])
1713
+ consumer.reference_bases(data[data.find(" ") + 1 :])
1714
+ elif line_type == "ORGANISM":
1715
+ # Typically the first line is the organism, and subsequent lines
1716
+ # are the taxonomy lineage. However, given longer and longer
1717
+ # species names (as more and more strains and sub strains get
1718
+ # sequenced) the oragnism name can now get wrapped onto multiple
1719
+ # lines. The NCBI say we have to recognise the lineage line by
1720
+ # the presence of semi-colon delimited entries. In the long term,
1721
+ # they are considering adding a new keyword (e.g. LINEAGE).
1722
+ # See Bug 2591 for details.
1723
+ organism_data = data
1724
+ lineage_data = ""
1725
+ while True:
1726
+ line = next(line_iter)
1727
+ if line[0 : self.GENBANK_INDENT] == self.GENBANK_SPACER:
1728
+ if (
1729
+ lineage_data
1730
+ or ";" in line
1731
+ or line[self.GENBANK_INDENT :].strip()
1732
+ in (
1733
+ "Bacteria.",
1734
+ "Archaea.",
1735
+ "Eukaryota.",
1736
+ "Unclassified.",
1737
+ "Viruses.",
1738
+ "cellular organisms.",
1739
+ "other sequences.",
1740
+ "unclassified sequences.",
1741
+ )
1742
+ ):
1743
+ lineage_data += " " + line[self.GENBANK_INDENT :]
1744
+ elif line[self.GENBANK_INDENT :].strip() == ".":
1745
+ # No lineage data, just . place holder
1746
+ pass
1747
+ else:
1748
+ organism_data += (
1749
+ " " + line[self.GENBANK_INDENT :].strip()
1750
+ )
1751
+ else:
1752
+ # End of organism and taxonomy
1753
+ break
1754
+ consumer.organism(organism_data)
1755
+ if lineage_data.strip() == "" and self.debug > 1:
1756
+ print("Taxonomy line(s) missing or blank")
1757
+ consumer.taxonomy(lineage_data.strip())
1758
+ del organism_data, lineage_data
1759
+ elif line_type == "COMMENT":
1760
+ # A COMMENT can either be plain text or tabular (Structured Comment),
1761
+ # or contain both. Multi-line comments are common. The code calls
1762
+ # consumer.comment() once with a list where each entry
1763
+ # is a line. If there's a structured comment consumer.structured_comment()
1764
+ # is called with a dict of dicts where the secondary key/value pairs are
1765
+ # the same as those in the structured comment table. The primary key is
1766
+ # the title or header of the table (e.g. Assembly-Data, FluData). See
1767
+ # http://www.ncbi.nlm.nih.gov/genbank/structuredcomment
1768
+ # for more information on Structured Comments.
1769
+ data = line[self.GENBANK_INDENT :]
1770
+ if self.debug > 1:
1771
+ print("Found comment")
1772
+ comment_list = []
1773
+ structured_comment_dict = defaultdict(dict)
1774
+ regex = rf"([^#]+){self.STRUCTURED_COMMENT_START}$"
1775
+ structured_comment_key = re.search(regex, data)
1776
+ if structured_comment_key is not None:
1777
+ structured_comment_key = structured_comment_key.group(1)
1778
+ if self.debug > 1:
1779
+ print("Found Structured Comment")
1780
+ else:
1781
+ comment_list.append(data)
1782
+
1783
+ while True:
1784
+ line = next(line_iter)
1785
+ data = line[self.GENBANK_INDENT :]
1786
+ if line[0 : self.GENBANK_INDENT] == self.GENBANK_SPACER:
1787
+ if self.STRUCTURED_COMMENT_START in data:
1788
+ regex = rf"([^#]+){self.STRUCTURED_COMMENT_START}$"
1789
+ structured_comment_key = re.search(regex, data)
1790
+ if structured_comment_key is not None:
1791
+ structured_comment_key = (
1792
+ structured_comment_key.group(1)
1793
+ )
1794
+ else:
1795
+ comment_list.append(data)
1796
+ elif (
1797
+ structured_comment_key is not None
1798
+ and self.STRUCTURED_COMMENT_DELIM.strip() in data
1799
+ ):
1800
+ match = re.search(
1801
+ rf"(.+?)\s*{self.STRUCTURED_COMMENT_DELIM.strip()}\s*(.*)",
1802
+ data,
1803
+ )
1804
+ structured_comment_dict[structured_comment_key][
1805
+ match.group(1)
1806
+ ] = match.group(2)
1807
+ if self.debug > 2:
1808
+ print(
1809
+ "Structured Comment continuation [" + data + "]"
1810
+ )
1811
+ elif (
1812
+ structured_comment_key is not None
1813
+ and self.STRUCTURED_COMMENT_END not in data
1814
+ ):
1815
+ # Don't die on a malformed comment, just warn and carry on
1816
+ if (
1817
+ structured_comment_key
1818
+ not in structured_comment_dict
1819
+ ):
1820
+ warnings.warn(
1821
+ f"Structured comment not parsed on malformed header line: {line}",
1822
+ BiopythonParserWarning,
1823
+ )
1824
+ continue
1825
+
1826
+ # The current structured comment has a multiline value
1827
+ previous_value_line = structured_comment_dict[
1828
+ structured_comment_key
1829
+ ][match.group(1)]
1830
+ structured_comment_dict[structured_comment_key][
1831
+ match.group(1)
1832
+ ] = (previous_value_line + " " + line.strip())
1833
+ elif self.STRUCTURED_COMMENT_END in data:
1834
+ # End of structured comment
1835
+ structured_comment_key = None
1836
+ else:
1837
+ comment_list.append(data)
1838
+ if self.debug > 2:
1839
+ print("Comment continuation [" + data + "]")
1840
+ else:
1841
+ # End of the comment
1842
+ break
1843
+ if comment_list:
1844
+ consumer.comment(comment_list)
1845
+ if structured_comment_dict:
1846
+ consumer.structured_comment(structured_comment_dict)
1847
+ del comment_list, structured_comment_key, structured_comment_dict
1848
+ elif line_type in consumer_dict:
1849
+ # It's a semi-automatic entry!
1850
+ # Now, this may be a multi line entry...
1851
+ while True:
1852
+ line = next(line_iter)
1853
+ if line[0 : self.GENBANK_INDENT] == self.GENBANK_SPACER:
1854
+ data += " " + line[self.GENBANK_INDENT :]
1855
+ else:
1856
+ # We now have all the data for this entry:
1857
+
1858
+ # The DEFINITION field must ends with a period
1859
+ # # see ftp://ftp.ncbi.nih.gov/genbank/gbrel.txt [3.4.5]
1860
+ # and discussion https://github.com/biopython/biopython/pull/616
1861
+ # We consider this period belong to the syntax, not to the data
1862
+ # So remove it if it exist
1863
+ if line_type == "DEFINITION" and data.endswith("."):
1864
+ data = data[:-1]
1865
+ getattr(consumer, consumer_dict[line_type])(data)
1866
+ # End of continuation - return to top of loop!
1867
+ break
1868
+ else:
1869
+ if self.debug:
1870
+ print("Ignoring GenBank header line:\n" % line)
1871
+ # Read in next line
1872
+ line = next(line_iter)
1873
+ except StopIteration:
1874
+ raise ValueError("Problem in header") from None
1875
+
1876
+ def _feed_misc_lines(self, consumer, lines):
1877
+ # Deals with a few misc lines between the features and the sequence
1878
+ lines.append("")
1879
+ line_iter = iter(lines)
1880
+ try:
1881
+ for line in line_iter:
1882
+ if line.startswith("BASE COUNT"):
1883
+ line = line[10:].strip()
1884
+ if line:
1885
+ if self.debug:
1886
+ print("base_count = " + line)
1887
+ consumer.base_count(line)
1888
+ if line.startswith("ORIGIN"):
1889
+ line = line[6:].strip()
1890
+ if line:
1891
+ if self.debug:
1892
+ print("origin_name = " + line)
1893
+ consumer.origin_name(line)
1894
+ if line.startswith("TLS "):
1895
+ line = line[3:].strip()
1896
+ consumer.tls(line)
1897
+ if line.startswith("TSA "):
1898
+ line = line[3:].strip()
1899
+ consumer.tsa(line)
1900
+ if line.startswith("WGS "):
1901
+ line = line[3:].strip()
1902
+ consumer.wgs(line)
1903
+ if line.startswith("WGS_SCAFLD"):
1904
+ line = line[10:].strip()
1905
+ consumer.add_wgs_scafld(line)
1906
+ if line.startswith("CONTIG"):
1907
+ line = line[6:].strip()
1908
+ contig_location = line
1909
+ while True:
1910
+ line = next(line_iter)
1911
+ if not line:
1912
+ break
1913
+ elif line[: self.GENBANK_INDENT] == self.GENBANK_SPACER:
1914
+ # Don't need to preserve the whitespace here.
1915
+ contig_location += line[self.GENBANK_INDENT :].rstrip()
1916
+ elif line.startswith("ORIGIN"):
1917
+ # Strange, seen this in GenPept files via Entrez gbwithparts
1918
+ line = line[6:].strip()
1919
+ if line:
1920
+ consumer.origin_name(line)
1921
+ break
1922
+ else:
1923
+ raise ValueError(
1924
+ "Expected CONTIG continuation line, got:\n" + line
1925
+ )
1926
+ consumer.contig_location(contig_location)
1927
+ return
1928
+ except StopIteration:
1929
+ raise ValueError("Problem in misc lines before sequence") from None
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/__init__.py ADDED
@@ -0,0 +1,1206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2000 by Jeffrey Chang, Brad Chapman. All rights reserved.
2
+ # Copyright 2006-2017 by Peter Cock. All rights reserved.
3
+ #
4
+ # This code is part of the Biopython distribution and governed by its
5
+ # license. Please see the LICENSE file that should have been included
6
+ # as part of this package.
7
+
8
+ """Code to work with GenBank formatted files.
9
+
10
+ Rather than using Bio.GenBank, you are now encouraged to use Bio.SeqIO with
11
+ the "genbank" or "embl" format names to parse GenBank or EMBL files into
12
+ SeqRecord and SeqFeature objects (see the Biopython tutorial for details).
13
+
14
+ Using Bio.GenBank directly to parse GenBank files is only useful if you want
15
+ to obtain GenBank-specific Record objects, which is a much closer
16
+ representation to the raw file contents than the SeqRecord alternative from
17
+ the FeatureParser (used in Bio.SeqIO).
18
+
19
+ To use the Bio.GenBank parser, there are two helper functions:
20
+
21
+ - read Parse a handle containing a single GenBank record
22
+ as Bio.GenBank specific Record objects.
23
+ - parse Iterate over a handle containing multiple GenBank
24
+ records as Bio.GenBank specific Record objects.
25
+
26
+ The following internal classes are not intended for direct use and may
27
+ be deprecated in a future release.
28
+
29
+ Classes:
30
+ - Iterator Iterate through a file of GenBank entries
31
+ - FeatureParser Parse GenBank data in SeqRecord and SeqFeature objects.
32
+ - RecordParser Parse GenBank data into a Record object.
33
+
34
+ Exceptions:
35
+ - ParserFailureError Exception indicating a failure in the parser (ie.
36
+ scanner or consumer)
37
+
38
+ """
39
+
40
+ import re
41
+ import warnings
42
+
43
+ from Bio import BiopythonParserWarning
44
+ from Bio.Seq import Seq
45
+ from Bio.SeqFeature import Location
46
+ from Bio.SeqFeature import LocationParserError
47
+ from Bio.SeqFeature import Reference
48
+ from Bio.SeqFeature import SeqFeature
49
+ from Bio.SeqFeature import SimpleLocation
50
+
51
+ from .Scanner import GenBankScanner
52
+ from .utils import FeatureValueCleaner
53
+
54
+ # Constants used to parse GenBank header lines
55
+ GENBANK_INDENT = 12
56
+ GENBANK_SPACER = " " * GENBANK_INDENT
57
+
58
+ # Constants for parsing GenBank feature lines
59
+ FEATURE_KEY_INDENT = 5
60
+ FEATURE_QUALIFIER_INDENT = 21
61
+ FEATURE_KEY_SPACER = " " * FEATURE_KEY_INDENT
62
+ FEATURE_QUALIFIER_SPACER = " " * FEATURE_QUALIFIER_INDENT
63
+
64
+
65
+ class Iterator:
66
+ """Iterator interface to move over a file of GenBank entries one at a time (OBSOLETE).
67
+
68
+ This class is likely to be deprecated in a future release of Biopython.
69
+ Please use Bio.SeqIO.parse(..., format="gb") or Bio.GenBank.parse(...)
70
+ for SeqRecord and GenBank specific Record objects respectively instead.
71
+ """
72
+
73
+ def __init__(self, handle, parser=None):
74
+ """Initialize the iterator.
75
+
76
+ Arguments:
77
+ - handle - A handle with GenBank entries to iterate through.
78
+ - parser - An optional parser to pass the entries through before
79
+ returning them. If None, then the raw entry will be returned.
80
+
81
+ """
82
+ self.handle = handle
83
+ self._parser = parser
84
+
85
+ def __next__(self):
86
+ """Return the next GenBank record from the handle.
87
+
88
+ Will return None if we ran out of records.
89
+ """
90
+ if self._parser is None:
91
+ lines = []
92
+ while True:
93
+ line = self.handle.readline()
94
+ if not line:
95
+ return None # Premature end of file?
96
+ lines.append(line)
97
+ if line.rstrip() == "//":
98
+ break
99
+ return "".join(lines)
100
+ try:
101
+ return self._parser.parse(self.handle)
102
+ except StopIteration:
103
+ return None
104
+
105
+ def __iter__(self):
106
+ """Iterate over the records."""
107
+ return iter(self.__next__, None)
108
+
109
+
110
+ class ParserFailureError(ValueError):
111
+ """Failure caused by some kind of problem in the parser."""
112
+
113
+
114
+ _cleaner = FeatureValueCleaner()
115
+
116
+
117
+ class FeatureParser:
118
+ """Parse GenBank files into Seq + Feature objects (OBSOLETE).
119
+
120
+ Direct use of this class is discouraged, and may be deprecated in
121
+ a future release of Biopython.
122
+
123
+ Please use Bio.SeqIO.parse(...) or Bio.SeqIO.read(...) instead.
124
+ """
125
+
126
+ def __init__(self, debug_level=0, use_fuzziness=1, feature_cleaner=None):
127
+ """Initialize a GenBank parser and Feature consumer.
128
+
129
+ Arguments:
130
+ - debug_level - An optional argument that species the amount of
131
+ debugging information the parser should spit out. By default we have
132
+ no debugging info (the fastest way to do things), but if you want
133
+ you can set this as high as two and see exactly where a parse fails.
134
+ - use_fuzziness - Specify whether or not to use fuzzy representations.
135
+ The default is 1 (use fuzziness).
136
+ - feature_cleaner - A class which will be used to clean out the
137
+ values of features. This class must implement the function
138
+ clean_value. GenBank.utils has a "standard" cleaner class, which
139
+ is used by default.
140
+
141
+ """
142
+ self._scanner = GenBankScanner(debug_level)
143
+ self.use_fuzziness = use_fuzziness
144
+ if feature_cleaner:
145
+ self._cleaner = feature_cleaner
146
+ else:
147
+ self._cleaner = _cleaner # default
148
+
149
+ def parse(self, handle):
150
+ """Parse the specified handle."""
151
+ _consumer = _FeatureConsumer(self.use_fuzziness, self._cleaner)
152
+ self._scanner.feed(handle, _consumer)
153
+ return _consumer.data
154
+
155
+
156
+ class RecordParser:
157
+ """Parse GenBank files into Record objects (OBSOLETE).
158
+
159
+ Direct use of this class is discouraged, and may be deprecated in
160
+ a future release of Biopython.
161
+
162
+ Please use the Bio.GenBank.parse(...) or Bio.GenBank.read(...) functions
163
+ instead.
164
+ """
165
+
166
+ def __init__(self, debug_level=0):
167
+ """Initialize the parser.
168
+
169
+ Arguments:
170
+ - debug_level - An optional argument that species the amount of
171
+ debugging information the parser should spit out. By default we have
172
+ no debugging info (the fastest way to do things), but if you want
173
+ you can set this as high as two and see exactly where a parse fails.
174
+
175
+ """
176
+ self._scanner = GenBankScanner(debug_level)
177
+
178
+ def parse(self, handle):
179
+ """Parse the specified handle into a GenBank record."""
180
+ _consumer = _RecordConsumer()
181
+
182
+ self._scanner.feed(handle, _consumer)
183
+ return _consumer.data
184
+
185
+
186
+ class _BaseGenBankConsumer:
187
+ """Abstract GenBank consumer providing useful general functions (PRIVATE).
188
+
189
+ This just helps to eliminate some duplication in things that most
190
+ GenBank consumers want to do.
191
+ """
192
+
193
+ # Special keys in GenBank records that we should remove spaces from
194
+ # For instance, \translation keys have values which are proteins and
195
+ # should have spaces and newlines removed from them. This class
196
+ # attribute gives us more control over specific formatting problems.
197
+ remove_space_keys = ["translation"]
198
+
199
+ def __init__(self):
200
+ pass
201
+
202
+ @staticmethod
203
+ def _split_keywords(keyword_string):
204
+ """Split a string of keywords into a nice clean list (PRIVATE)."""
205
+ # process the keywords into a python list
206
+ if keyword_string == "" or keyword_string == ".":
207
+ keywords = ""
208
+ elif keyword_string[-1] == ".":
209
+ keywords = keyword_string[:-1]
210
+ else:
211
+ keywords = keyword_string
212
+ keyword_list = keywords.split(";")
213
+ return [x.strip() for x in keyword_list]
214
+
215
+ @staticmethod
216
+ def _split_accessions(accession_string):
217
+ """Split a string of accession numbers into a list (PRIVATE)."""
218
+ # first replace all line feeds with spaces
219
+ # Also, EMBL style accessions are split with ';'
220
+ accession = accession_string.replace("\n", " ").replace(";", " ")
221
+
222
+ return [x.strip() for x in accession.split() if x.strip()]
223
+
224
+ @staticmethod
225
+ def _split_taxonomy(taxonomy_string):
226
+ """Split a string with taxonomy info into a list (PRIVATE)."""
227
+ if not taxonomy_string or taxonomy_string == ".":
228
+ # Missing data, no taxonomy
229
+ return []
230
+
231
+ if taxonomy_string[-1] == ".":
232
+ tax_info = taxonomy_string[:-1]
233
+ else:
234
+ tax_info = taxonomy_string
235
+ tax_list = tax_info.split(";")
236
+ return [
237
+ item.strip()
238
+ for tax_item in tax_list
239
+ for item in tax_item.split("\n")
240
+ if item
241
+ ]
242
+
243
+ @staticmethod
244
+ def _clean_location(location_string):
245
+ """Clean whitespace out of a location string (PRIVATE).
246
+
247
+ The location parser isn't a fan of whitespace, so we clean it out
248
+ before feeding it into the parser.
249
+ """
250
+ # Originally this imported string.whitespace and did a replace
251
+ # via a loop. It's simpler to just split on whitespace and rejoin
252
+ # the string - and this avoids importing string too. See Bug 2684.
253
+ return "".join(location_string.split())
254
+
255
+ @staticmethod
256
+ def _remove_newlines(text):
257
+ """Remove any newlines in the passed text, returning the new string (PRIVATE)."""
258
+ # get rid of newlines in the qualifier value
259
+ newlines = ["\n", "\r"]
260
+ for ws in newlines:
261
+ text = text.replace(ws, "")
262
+
263
+ return text
264
+
265
+ @staticmethod
266
+ def _normalize_spaces(text):
267
+ """Replace multiple spaces in the passed text with single spaces (PRIVATE)."""
268
+ # get rid of excessive spaces
269
+ return " ".join(x for x in text.split(" ") if x)
270
+
271
+ @staticmethod
272
+ def _remove_spaces(text):
273
+ """Remove all spaces from the passed text (PRIVATE)."""
274
+ return text.replace(" ", "")
275
+
276
+ @staticmethod
277
+ def _convert_to_python_numbers(start, end):
278
+ """Convert a start and end range to python notation (PRIVATE).
279
+
280
+ In GenBank, starts and ends are defined in "biological" coordinates,
281
+ where 1 is the first base and [i, j] means to include both i and j.
282
+
283
+ In python, 0 is the first base and [i, j] means to include i, but
284
+ not j.
285
+
286
+ So, to convert "biological" to python coordinates, we need to
287
+ subtract 1 from the start, and leave the end and things should
288
+ be converted happily.
289
+ """
290
+ new_start = start - 1
291
+ new_end = end
292
+
293
+ return new_start, new_end
294
+
295
+
296
+ class _FeatureConsumer(_BaseGenBankConsumer):
297
+ """Create a SeqRecord object with Features to return (PRIVATE).
298
+
299
+ Attributes:
300
+ - use_fuzziness - specify whether or not to parse with fuzziness in
301
+ feature locations.
302
+ - feature_cleaner - a class that will be used to provide specialized
303
+ cleaning-up of feature values.
304
+
305
+ """
306
+
307
+ def __init__(self, use_fuzziness, feature_cleaner=None):
308
+ from Bio.SeqRecord import SeqRecord
309
+
310
+ _BaseGenBankConsumer.__init__(self)
311
+ self.data = SeqRecord(None, id=None)
312
+ self.data.id = None
313
+ self.data.description = ""
314
+
315
+ self._use_fuzziness = use_fuzziness
316
+ self._feature_cleaner = feature_cleaner
317
+
318
+ self._seq_type = ""
319
+ self._seq_data = []
320
+ self._cur_reference = None
321
+ self._cur_feature = None
322
+ self._expected_size = None
323
+
324
+ def locus(self, locus_name):
325
+ """Set the locus name is set as the name of the Sequence."""
326
+ self.data.name = locus_name
327
+
328
+ def size(self, content):
329
+ """Record the sequence length."""
330
+ self._expected_size = int(content)
331
+
332
+ def residue_type(self, type):
333
+ """Record the sequence type (SEMI-OBSOLETE).
334
+
335
+ This reflects the fact that the topology (linear/circular) and
336
+ molecule type (e.g. DNA vs RNA) were a single field in early
337
+ files. Current GenBank/EMBL files have two fields.
338
+ """
339
+ self._seq_type = type.strip()
340
+
341
+ def topology(self, topology):
342
+ """Validate and record sequence topology.
343
+
344
+ The topology argument should be "linear" or "circular" (string).
345
+ """
346
+ if topology:
347
+ if topology not in ["linear", "circular"]:
348
+ raise ParserFailureError(
349
+ f"Unexpected topology {topology!r} should be linear or circular"
350
+ )
351
+ self.data.annotations["topology"] = topology
352
+
353
+ def molecule_type(self, mol_type):
354
+ """Validate and record the molecule type (for round-trip etc)."""
355
+ if mol_type:
356
+ if "circular" in mol_type or "linear" in mol_type:
357
+ raise ParserFailureError(
358
+ f"Molecule type {mol_type!r} should not include topology"
359
+ )
360
+
361
+ # Writing out records will fail if we have a lower case DNA
362
+ # or RNA string in here, so upper case it.
363
+ # This is a bit ugly, but we don't want to upper case e.g.
364
+ # the m in mRNA, but thanks to the strip we lost the spaces
365
+ # so we need to index from the back
366
+ if mol_type[-3:].upper() in ("DNA", "RNA") and not mol_type[-3:].isupper():
367
+ warnings.warn(
368
+ f"Non-upper case molecule type in LOCUS line: {mol_type}",
369
+ BiopythonParserWarning,
370
+ )
371
+
372
+ self.data.annotations["molecule_type"] = mol_type
373
+
374
+ def data_file_division(self, division):
375
+ self.data.annotations["data_file_division"] = division
376
+
377
+ def date(self, submit_date):
378
+ self.data.annotations["date"] = submit_date
379
+
380
+ def definition(self, definition):
381
+ """Set the definition as the description of the sequence."""
382
+ if self.data.description:
383
+ # Append to any existing description
384
+ # e.g. EMBL files with two DE lines.
385
+ self.data.description += " " + definition
386
+ else:
387
+ self.data.description = definition
388
+
389
+ def accession(self, acc_num):
390
+ """Set the accession number as the id of the sequence.
391
+
392
+ If we have multiple accession numbers, the first one passed is
393
+ used.
394
+ """
395
+ new_acc_nums = self._split_accessions(acc_num)
396
+
397
+ # Also record them ALL in the annotations
398
+ try:
399
+ # On the off chance there was more than one accession line:
400
+ for acc in new_acc_nums:
401
+ # Prevent repeat entries
402
+ if acc not in self.data.annotations["accessions"]:
403
+ self.data.annotations["accessions"].append(acc)
404
+ except KeyError:
405
+ self.data.annotations["accessions"] = new_acc_nums
406
+
407
+ # if we haven't set the id information yet, add the first acc num
408
+ if not self.data.id:
409
+ if len(new_acc_nums) > 0:
410
+ # self.data.id = new_acc_nums[0]
411
+ # Use the FIRST accession as the ID, not the first on this line!
412
+ self.data.id = self.data.annotations["accessions"][0]
413
+
414
+ def tls(self, content):
415
+ self.data.annotations["tls"] = content.split("-")
416
+
417
+ def tsa(self, content):
418
+ self.data.annotations["tsa"] = content.split("-")
419
+
420
+ def wgs(self, content):
421
+ self.data.annotations["wgs"] = content.split("-")
422
+
423
+ def add_wgs_scafld(self, content):
424
+ self.data.annotations.setdefault("wgs_scafld", []).append(content.split("-"))
425
+
426
+ def nid(self, content):
427
+ self.data.annotations["nid"] = content
428
+
429
+ def pid(self, content):
430
+ self.data.annotations["pid"] = content
431
+
432
+ def version(self, version_id):
433
+ # Want to use the versioned accession as the record.id
434
+ # This comes from the VERSION line in GenBank files, or the
435
+ # obsolete SV line in EMBL. For the new EMBL files we need
436
+ # both the version suffix from the ID line and the accession
437
+ # from the AC line.
438
+ if version_id.count(".") == 1 and version_id.split(".")[1].isdigit():
439
+ self.accession(version_id.split(".")[0])
440
+ self.version_suffix(version_id.split(".")[1])
441
+ elif version_id:
442
+ # For backwards compatibility...
443
+ self.data.id = version_id
444
+
445
+ def project(self, content):
446
+ """Handle the information from the PROJECT line as a list of projects.
447
+
448
+ e.g.::
449
+
450
+ PROJECT GenomeProject:28471
451
+
452
+ or::
453
+
454
+ PROJECT GenomeProject:13543 GenomeProject:99999
455
+
456
+ This is stored as dbxrefs in the SeqRecord to be consistent with the
457
+ projected switch of this line to DBLINK in future GenBank versions.
458
+ Note the NCBI plan to replace "GenomeProject:28471" with the shorter
459
+ "Project:28471" as part of this transition.
460
+ """
461
+ content = content.replace("GenomeProject:", "Project:")
462
+ self.data.dbxrefs.extend(p for p in content.split() if p)
463
+
464
+ def dblink(self, content):
465
+ """Store DBLINK cross references as dbxrefs in our record object.
466
+
467
+ This line type is expected to replace the PROJECT line in 2009. e.g.
468
+
469
+ During transition::
470
+
471
+ PROJECT GenomeProject:28471
472
+ DBLINK Project:28471
473
+ Trace Assembly Archive:123456
474
+
475
+ Once the project line is dropped::
476
+
477
+ DBLINK Project:28471
478
+ Trace Assembly Archive:123456
479
+
480
+ Note GenomeProject -> Project.
481
+
482
+ We'll have to see some real examples to be sure, but based on the
483
+ above example we can expect one reference per line.
484
+
485
+ Note that at some point the NCBI have included an extra space, e.g.::
486
+
487
+ DBLINK Project: 28471
488
+
489
+ """
490
+ # During the transition period with both PROJECT and DBLINK lines,
491
+ # we don't want to add the same cross reference twice.
492
+ while ": " in content:
493
+ content = content.replace(": ", ":")
494
+ if content.strip() not in self.data.dbxrefs:
495
+ self.data.dbxrefs.append(content.strip())
496
+
497
+ def version_suffix(self, version):
498
+ """Set the version to overwrite the id.
499
+
500
+ Since the version provides the same information as the accession
501
+ number, plus some extra info, we set this as the id if we have
502
+ a version.
503
+ """
504
+ # e.g. GenBank line:
505
+ # VERSION U49845.1 GI:1293613
506
+ # or the obsolete EMBL line:
507
+ # SV U49845.1
508
+ # Scanner calls consumer.version("U49845.1")
509
+ # which then calls consumer.version_suffix(1)
510
+ #
511
+ # e.g. EMBL new line:
512
+ # ID X56734; SV 1; linear; mRNA; STD; PLN; 1859 BP.
513
+ # Scanner calls consumer.version_suffix(1)
514
+ assert version.isdigit()
515
+ self.data.annotations["sequence_version"] = int(version)
516
+
517
+ def db_source(self, content):
518
+ self.data.annotations["db_source"] = content.rstrip()
519
+
520
+ def gi(self, content):
521
+ self.data.annotations["gi"] = content
522
+
523
+ def keywords(self, content):
524
+ if "keywords" in self.data.annotations:
525
+ # Multi-line keywords, append to list
526
+ # Note EMBL states "A keyword is never split between lines."
527
+ self.data.annotations["keywords"].extend(self._split_keywords(content))
528
+ else:
529
+ self.data.annotations["keywords"] = self._split_keywords(content)
530
+
531
+ def segment(self, content):
532
+ self.data.annotations["segment"] = content
533
+
534
+ def source(self, content):
535
+ # Note that some software (e.g. VectorNTI) may produce an empty
536
+ # source (rather than using a dot/period as might be expected).
537
+ if content == "":
538
+ source_info = ""
539
+ elif content[-1] == ".":
540
+ source_info = content[:-1]
541
+ else:
542
+ source_info = content
543
+ self.data.annotations["source"] = source_info
544
+
545
+ def organism(self, content):
546
+ self.data.annotations["organism"] = content
547
+
548
+ def taxonomy(self, content):
549
+ """Record (another line of) the taxonomy lineage."""
550
+ lineage = self._split_taxonomy(content)
551
+ try:
552
+ self.data.annotations["taxonomy"].extend(lineage)
553
+ except KeyError:
554
+ self.data.annotations["taxonomy"] = lineage
555
+
556
+ def reference_num(self, content):
557
+ """Signal the beginning of a new reference object."""
558
+ # if we have a current reference that hasn't been added to
559
+ # the list of references, add it.
560
+ if self._cur_reference is not None:
561
+ self.data.annotations["references"].append(self._cur_reference)
562
+ else:
563
+ self.data.annotations["references"] = []
564
+
565
+ self._cur_reference = Reference()
566
+
567
+ def reference_bases(self, content):
568
+ """Attempt to determine the sequence region the reference entails.
569
+
570
+ Possible types of information we may have to deal with:
571
+
572
+ (bases 1 to 86436)
573
+ (sites)
574
+ (bases 1 to 105654; 110423 to 111122)
575
+ 1 (residues 1 to 182)
576
+ """
577
+ # first remove the parentheses
578
+ assert content.endswith(")"), content
579
+ ref_base_info = content[1:-1]
580
+
581
+ all_locations = []
582
+ # parse if we've got 'bases' and 'to'
583
+ if "bases" in ref_base_info and "to" in ref_base_info:
584
+ # get rid of the beginning 'bases'
585
+ ref_base_info = ref_base_info[5:]
586
+ locations = self._split_reference_locations(ref_base_info)
587
+ all_locations.extend(locations)
588
+ elif "residues" in ref_base_info and "to" in ref_base_info:
589
+ residues_start = ref_base_info.find("residues")
590
+ # get only the information after "residues"
591
+ ref_base_info = ref_base_info[(residues_start + len("residues ")) :]
592
+ locations = self._split_reference_locations(ref_base_info)
593
+ all_locations.extend(locations)
594
+
595
+ # make sure if we are not finding information then we have
596
+ # the string 'sites' or the string 'bases'
597
+ elif ref_base_info == "sites" or ref_base_info.strip() == "bases":
598
+ pass
599
+ # otherwise raise an error
600
+ else:
601
+ raise ValueError(
602
+ f"Could not parse base info {ref_base_info} in record {self.data.id}"
603
+ )
604
+
605
+ self._cur_reference.location = all_locations
606
+
607
+ def _split_reference_locations(self, location_string):
608
+ """Get reference locations out of a string of reference information (PRIVATE).
609
+
610
+ The passed string should be of the form::
611
+
612
+ 1 to 20; 20 to 100
613
+
614
+ This splits the information out and returns a list of location objects
615
+ based on the reference locations.
616
+ """
617
+ # split possibly multiple locations using the ';'
618
+ all_base_info = location_string.split(";")
619
+
620
+ new_locations = []
621
+ for base_info in all_base_info:
622
+ start, end = base_info.split("to")
623
+ new_start, new_end = self._convert_to_python_numbers(
624
+ int(start.strip()), int(end.strip())
625
+ )
626
+ this_location = SimpleLocation(new_start, new_end)
627
+ new_locations.append(this_location)
628
+ return new_locations
629
+
630
+ def authors(self, content):
631
+ if self._cur_reference.authors:
632
+ self._cur_reference.authors += " " + content
633
+ else:
634
+ self._cur_reference.authors = content
635
+
636
+ def consrtm(self, content):
637
+ if self._cur_reference.consrtm:
638
+ self._cur_reference.consrtm += " " + content
639
+ else:
640
+ self._cur_reference.consrtm = content
641
+
642
+ def title(self, content):
643
+ if self._cur_reference is None:
644
+ warnings.warn(
645
+ "GenBank TITLE line without REFERENCE line.", BiopythonParserWarning
646
+ )
647
+ elif self._cur_reference.title:
648
+ self._cur_reference.title += " " + content
649
+ else:
650
+ self._cur_reference.title = content
651
+
652
+ def journal(self, content):
653
+ if self._cur_reference.journal:
654
+ self._cur_reference.journal += " " + content
655
+ else:
656
+ self._cur_reference.journal = content
657
+
658
+ def medline_id(self, content):
659
+ self._cur_reference.medline_id = content
660
+
661
+ def pubmed_id(self, content):
662
+ self._cur_reference.pubmed_id = content
663
+
664
+ def remark(self, content):
665
+ """Deal with a reference comment."""
666
+ if self._cur_reference.comment:
667
+ self._cur_reference.comment += " " + content
668
+ else:
669
+ self._cur_reference.comment = content
670
+
671
+ def comment(self, content):
672
+ try:
673
+ self.data.annotations["comment"] += "\n" + "\n".join(content)
674
+ except KeyError:
675
+ self.data.annotations["comment"] = "\n".join(content)
676
+
677
+ def structured_comment(self, content):
678
+ self.data.annotations["structured_comment"] = content
679
+
680
+ def features_line(self, content):
681
+ """Get ready for the feature table when we reach the FEATURE line."""
682
+ self.start_feature_table()
683
+
684
+ def start_feature_table(self):
685
+ """Indicate we've got to the start of the feature table."""
686
+ # make sure we've added on our last reference object
687
+ if self._cur_reference is not None:
688
+ self.data.annotations["references"].append(self._cur_reference)
689
+ self._cur_reference = None
690
+
691
+ def feature_key(self, content):
692
+ # start a new feature
693
+ self._cur_feature = SeqFeature()
694
+ self._cur_feature.type = content
695
+ self.data.features.append(self._cur_feature)
696
+
697
+ def location(self, content):
698
+ """Parse out location information from the location string.
699
+
700
+ This uses simple Python code with some regular expressions to do the
701
+ parsing, and then translates the results into appropriate objects.
702
+ """
703
+ # clean up newlines and other whitespace inside the location before
704
+ # parsing - locations should have no whitespace whatsoever
705
+ location_line = self._clean_location(content)
706
+
707
+ # Older records have junk like replace(266,"c") in the
708
+ # location line. Newer records just replace this with
709
+ # the number 266 and have the information in a more reasonable
710
+ # place. So we'll just grab out the number and feed this to the
711
+ # parser. We shouldn't really be losing any info this way.
712
+ if "replace" in location_line:
713
+ comma_pos = location_line.find(",")
714
+ location_line = location_line[8:comma_pos]
715
+
716
+ length = self._expected_size
717
+ # Check if the sequence is circular for features that span the origin
718
+ is_circular = "circular" in self.data.annotations.get("topology", "").lower()
719
+ stranded = "PROTEIN" not in self._seq_type.upper()
720
+
721
+ try:
722
+ location = Location.fromstring(location_line, length, is_circular, stranded)
723
+ except LocationParserError as e:
724
+ warnings.warn(
725
+ f"{e}; setting feature location to None.", BiopythonParserWarning
726
+ )
727
+ location = None
728
+ self._cur_feature.location = location
729
+
730
+ def feature_qualifier(self, key, value):
731
+ """When we get a qualifier key and its value.
732
+
733
+ Can receive None, since you can have valueless keys such as /pseudo
734
+ """
735
+ # Hack to try to preserve historical behaviour of /pseudo etc
736
+ if value is None:
737
+ # if the key doesn't exist yet, add an empty string
738
+ if key not in self._cur_feature.qualifiers:
739
+ self._cur_feature.qualifiers[key] = [""]
740
+ return
741
+ # otherwise just skip this key
742
+ return
743
+
744
+ # Remove enclosing quotation marks
745
+ if len(value) > 1 and value[0] == '"' and value[-1] == '"':
746
+ value = value[1:-1]
747
+
748
+ # Handle NCBI escaping
749
+ # Warn if escaping is not according to standard
750
+ if re.search(r'[^"]"[^"]|^"[^"]|[^"]"$', value):
751
+ warnings.warn(
752
+ 'The NCBI states double-quote characters like " should be escaped as "" '
753
+ "(two double - quotes), but here it was not: %r" % value,
754
+ BiopythonParserWarning,
755
+ )
756
+ # Undo escaping, repeated double quotes -> one double quote
757
+ value = value.replace('""', '"')
758
+
759
+ if self._feature_cleaner is not None:
760
+ value = self._feature_cleaner.clean_value(key, value)
761
+
762
+ # if the qualifier name exists, append the value
763
+ if key in self._cur_feature.qualifiers:
764
+ self._cur_feature.qualifiers[key].append(value)
765
+ # otherwise start a new list of the key with its values
766
+ else:
767
+ self._cur_feature.qualifiers[key] = [value]
768
+
769
+ def feature_qualifier_name(self, content_list):
770
+ """Use feature_qualifier instead (OBSOLETE)."""
771
+ raise NotImplementedError("Use the feature_qualifier method instead.")
772
+
773
+ def feature_qualifier_description(self, content):
774
+ """Use feature_qualifier instead (OBSOLETE)."""
775
+ raise NotImplementedError("Use the feature_qualifier method instead.")
776
+
777
+ def contig_location(self, content):
778
+ """Deal with CONTIG information."""
779
+ # Historically this was stored as a SeqFeature object, but it was
780
+ # stored under record.annotations["contig"] and not under
781
+ # record.features with the other SeqFeature objects.
782
+ #
783
+ # The CONTIG location line can include additional tokens like
784
+ # Gap(), Gap(100) or Gap(unk100) which are not used in the feature
785
+ # location lines, so storing it using SeqFeature based location
786
+ # objects is difficult.
787
+ #
788
+ # We now store this a string, which means for BioSQL we are now in
789
+ # much better agreement with how BioPerl records the CONTIG line
790
+ # in the database.
791
+ #
792
+ # NOTE - This code assumes the scanner will return all the CONTIG
793
+ # lines already combined into one long string!
794
+ self.data.annotations["contig"] = content
795
+
796
+ def origin_name(self, content):
797
+ pass
798
+
799
+ def base_count(self, content):
800
+ pass
801
+
802
+ def base_number(self, content):
803
+ pass
804
+
805
+ def sequence(self, content):
806
+ """Add up sequence information as we get it.
807
+
808
+ To try and make things speedier, this puts all of the strings
809
+ into a list of strings, and then uses string.join later to put
810
+ them together. Supposedly, this is a big time savings
811
+ """
812
+ assert " " not in content
813
+ self._seq_data.append(content.upper())
814
+
815
+ def record_end(self, content):
816
+ """Clean up when we've finished the record."""
817
+ # Try and append the version number to the accession for the full id
818
+ if not self.data.id:
819
+ if "accessions" in self.data.annotations:
820
+ raise ValueError(
821
+ "Problem adding version number to accession: "
822
+ + str(self.data.annotations["accessions"])
823
+ )
824
+ self.data.id = self.data.name # Good fall back?
825
+ elif self.data.id.count(".") == 0:
826
+ try:
827
+ self.data.id += ".%i" % self.data.annotations["sequence_version"]
828
+ except KeyError:
829
+ pass
830
+
831
+ # add the sequence information
832
+
833
+ sequence = "".join(self._seq_data)
834
+
835
+ if (
836
+ self._expected_size is not None
837
+ and len(sequence) != 0
838
+ and self._expected_size != len(sequence)
839
+ ):
840
+ warnings.warn(
841
+ "Expected sequence length %i, found %i (%s)."
842
+ % (self._expected_size, len(sequence), self.data.id),
843
+ BiopythonParserWarning,
844
+ )
845
+
846
+ molecule_type = None
847
+ if self._seq_type:
848
+ # mRNA is really also DNA, since it is actually cDNA
849
+ if "DNA" in self._seq_type.upper() or "MRNA" in self._seq_type.upper():
850
+ molecule_type = "DNA"
851
+ # are there ever really RNA sequences in GenBank?
852
+ elif "RNA" in self._seq_type.upper():
853
+ # Even for data which was from RNA, the sequence string
854
+ # is usually given as DNA (T not U). Bug 3010
855
+ molecule_type = "RNA"
856
+ elif (
857
+ "PROTEIN" in self._seq_type.upper() or self._seq_type == "PRT"
858
+ ): # PRT is used in EMBL-bank for patents
859
+ molecule_type = "protein"
860
+ # work around ugly GenBank records which have circular or
861
+ # linear but no indication of sequence type
862
+ elif self._seq_type in ["circular", "linear", "unspecified"]:
863
+ pass
864
+ # we have a bug if we get here
865
+ else:
866
+ raise ValueError(
867
+ f"Could not determine molecule_type for seq_type {self._seq_type}"
868
+ )
869
+ # Don't overwrite molecule_type
870
+ if molecule_type is not None:
871
+ self.data.annotations["molecule_type"] = self.data.annotations.get(
872
+ "molecule_type", molecule_type
873
+ )
874
+ if not sequence and self._expected_size:
875
+ self.data.seq = Seq(None, length=self._expected_size)
876
+ else:
877
+ self.data.seq = Seq(sequence)
878
+
879
+
880
+ class _RecordConsumer(_BaseGenBankConsumer):
881
+ """Create a GenBank Record object from scanner generated information (PRIVATE)."""
882
+
883
+ def __init__(self):
884
+ _BaseGenBankConsumer.__init__(self)
885
+ from . import Record
886
+
887
+ self.data = Record.Record()
888
+
889
+ self._seq_data = []
890
+ self._cur_reference = None
891
+ self._cur_feature = None
892
+ self._cur_qualifier = None
893
+
894
+ def tls(self, content):
895
+ self.data.tls = content.split("-")
896
+
897
+ def tsa(self, content):
898
+ self.data.tsa = content.split("-")
899
+
900
+ def wgs(self, content):
901
+ self.data.wgs = content.split("-")
902
+
903
+ def add_wgs_scafld(self, content):
904
+ self.data.wgs_scafld.append(content.split("-"))
905
+
906
+ def locus(self, content):
907
+ self.data.locus = content
908
+
909
+ def size(self, content):
910
+ self.data.size = content
911
+
912
+ def residue_type(self, content):
913
+ # Be lenient about parsing, but technically lowercase residue types are malformed.
914
+ if "dna" in content or "rna" in content:
915
+ warnings.warn(
916
+ f"Invalid seq_type ({content}): DNA/RNA should be uppercase.",
917
+ BiopythonParserWarning,
918
+ )
919
+ self.data.residue_type = content
920
+
921
+ def data_file_division(self, content):
922
+ self.data.data_file_division = content
923
+
924
+ def date(self, content):
925
+ self.data.date = content
926
+
927
+ def definition(self, content):
928
+ self.data.definition = content
929
+
930
+ def accession(self, content):
931
+ for acc in self._split_accessions(content):
932
+ if acc not in self.data.accession:
933
+ self.data.accession.append(acc)
934
+
935
+ def molecule_type(self, mol_type):
936
+ """Validate and record the molecule type (for round-trip etc)."""
937
+ if mol_type:
938
+ if "circular" in mol_type or "linear" in mol_type:
939
+ raise ParserFailureError(
940
+ f"Molecule type {mol_type!r} should not include topology"
941
+ )
942
+
943
+ # Writing out records will fail if we have a lower case DNA
944
+ # or RNA string in here, so upper case it.
945
+ # This is a bit ugly, but we don't want to upper case e.g.
946
+ # the m in mRNA, but thanks to the strip we lost the spaces
947
+ # so we need to index from the back
948
+ if mol_type[-3:].upper() in ("DNA", "RNA") and not mol_type[-3:].isupper():
949
+ warnings.warn(
950
+ f"Non-upper case molecule type in LOCUS line: {mol_type}",
951
+ BiopythonParserWarning,
952
+ )
953
+
954
+ self.data.molecule_type = mol_type
955
+
956
+ def topology(self, topology):
957
+ """Validate and record sequence topology.
958
+
959
+ The topology argument should be "linear" or "circular" (string).
960
+ """
961
+ if topology:
962
+ if topology not in ["linear", "circular"]:
963
+ raise ParserFailureError(
964
+ f"Unexpected topology {topology!r} should be linear or circular"
965
+ )
966
+ self.data.topology = topology
967
+
968
+ def nid(self, content):
969
+ self.data.nid = content
970
+
971
+ def pid(self, content):
972
+ self.data.pid = content
973
+
974
+ def version(self, content):
975
+ self.data.version = content
976
+
977
+ def db_source(self, content):
978
+ self.data.db_source = content.rstrip()
979
+
980
+ def gi(self, content):
981
+ self.data.gi = content
982
+
983
+ def keywords(self, content):
984
+ self.data.keywords = self._split_keywords(content)
985
+
986
+ def project(self, content):
987
+ self.data.projects.extend(p for p in content.split() if p)
988
+
989
+ def dblink(self, content):
990
+ self.data.dblinks.append(content)
991
+
992
+ def segment(self, content):
993
+ self.data.segment = content
994
+
995
+ def source(self, content):
996
+ self.data.source = content
997
+
998
+ def organism(self, content):
999
+ self.data.organism = content
1000
+
1001
+ def taxonomy(self, content):
1002
+ self.data.taxonomy = self._split_taxonomy(content)
1003
+
1004
+ def reference_num(self, content):
1005
+ """Grab the reference number and signal the start of a new reference."""
1006
+ # check if we have a reference to add
1007
+ if self._cur_reference is not None:
1008
+ self.data.references.append(self._cur_reference)
1009
+
1010
+ from . import Record
1011
+
1012
+ self._cur_reference = Record.Reference()
1013
+ self._cur_reference.number = content
1014
+
1015
+ def reference_bases(self, content):
1016
+ self._cur_reference.bases = content
1017
+
1018
+ def authors(self, content):
1019
+ self._cur_reference.authors = content
1020
+
1021
+ def consrtm(self, content):
1022
+ self._cur_reference.consrtm = content
1023
+
1024
+ def title(self, content):
1025
+ if self._cur_reference is None:
1026
+ warnings.warn(
1027
+ "GenBank TITLE line without REFERENCE line.", BiopythonParserWarning
1028
+ )
1029
+ return
1030
+ self._cur_reference.title = content
1031
+
1032
+ def journal(self, content):
1033
+ self._cur_reference.journal = content
1034
+
1035
+ def medline_id(self, content):
1036
+ self._cur_reference.medline_id = content
1037
+
1038
+ def pubmed_id(self, content):
1039
+ self._cur_reference.pubmed_id = content
1040
+
1041
+ def remark(self, content):
1042
+ self._cur_reference.remark = content
1043
+
1044
+ def comment(self, content):
1045
+ self.data.comment += "\n".join(content)
1046
+
1047
+ def structured_comment(self, content):
1048
+ self.data.structured_comment = content
1049
+
1050
+ def primary_ref_line(self, content):
1051
+ """Save reference data for the PRIMARY line."""
1052
+ self.data.primary.append(content)
1053
+
1054
+ def primary(self, content):
1055
+ pass
1056
+
1057
+ def features_line(self, content):
1058
+ """Get ready for the feature table when we reach the FEATURE line."""
1059
+ self.start_feature_table()
1060
+
1061
+ def start_feature_table(self):
1062
+ """Signal the start of the feature table."""
1063
+ # we need to add on the last reference
1064
+ if self._cur_reference is not None:
1065
+ self.data.references.append(self._cur_reference)
1066
+
1067
+ def feature_key(self, content):
1068
+ """Grab the key of the feature and signal the start of a new feature."""
1069
+ # first add on feature information if we've got any
1070
+ self._add_feature()
1071
+
1072
+ from . import Record
1073
+
1074
+ self._cur_feature = Record.Feature()
1075
+ self._cur_feature.key = content
1076
+
1077
+ def _add_feature(self):
1078
+ """Add a feature to the record, with relevant checks (PRIVATE).
1079
+
1080
+ This does all of the appropriate checking to make sure we haven't
1081
+ left any info behind, and that we are only adding info if it
1082
+ exists.
1083
+ """
1084
+ if self._cur_feature is not None:
1085
+ # if we have a left over qualifier, add it to the qualifiers
1086
+ # on the current feature
1087
+ if self._cur_qualifier is not None:
1088
+ self._cur_feature.qualifiers.append(self._cur_qualifier)
1089
+
1090
+ self._cur_qualifier = None
1091
+ self.data.features.append(self._cur_feature)
1092
+
1093
+ def location(self, content):
1094
+ self._cur_feature.location = self._clean_location(content)
1095
+
1096
+ def feature_qualifier(self, key, value):
1097
+ self.feature_qualifier_name([key])
1098
+ if value is not None:
1099
+ self.feature_qualifier_description(value)
1100
+
1101
+ def feature_qualifier_name(self, content_list):
1102
+ """Deal with qualifier names.
1103
+
1104
+ We receive a list of keys, since you can have valueless keys such as
1105
+ /pseudo which would be passed in with the next key (since no other
1106
+ tags separate them in the file)
1107
+ """
1108
+ from . import Record
1109
+
1110
+ for content in content_list:
1111
+ # the record parser keeps the /s -- add them if we don't have 'em
1112
+ if not content.startswith("/"):
1113
+ content = f"/{content}"
1114
+ # add on a qualifier if we've got one
1115
+ if self._cur_qualifier is not None:
1116
+ self._cur_feature.qualifiers.append(self._cur_qualifier)
1117
+
1118
+ self._cur_qualifier = Record.Qualifier()
1119
+ self._cur_qualifier.key = content
1120
+
1121
+ def feature_qualifier_description(self, content):
1122
+ # if we have info then the qualifier key should have a ='s
1123
+ if "=" not in self._cur_qualifier.key:
1124
+ self._cur_qualifier.key = f"{self._cur_qualifier.key}="
1125
+ cur_content = self._remove_newlines(content)
1126
+ # remove all spaces from the value if it is a type where spaces
1127
+ # are not important
1128
+ for remove_space_key in self.__class__.remove_space_keys:
1129
+ if remove_space_key in self._cur_qualifier.key:
1130
+ cur_content = self._remove_spaces(cur_content)
1131
+ self._cur_qualifier.value = self._normalize_spaces(cur_content)
1132
+
1133
+ def base_count(self, content):
1134
+ self.data.base_counts = content
1135
+
1136
+ def origin_name(self, content):
1137
+ self.data.origin = content
1138
+
1139
+ def contig_location(self, content):
1140
+ """Signal that we have contig information to add to the record."""
1141
+ self.data.contig = self._clean_location(content)
1142
+
1143
+ def sequence(self, content):
1144
+ """Add sequence information to a list of sequence strings.
1145
+
1146
+ This removes spaces in the data and uppercases the sequence, and
1147
+ then adds it to a list of sequences. Later on we'll join this
1148
+ list together to make the final sequence. This is faster than
1149
+ adding on the new string every time.
1150
+ """
1151
+ assert " " not in content
1152
+ self._seq_data.append(content.upper())
1153
+
1154
+ def record_end(self, content):
1155
+ """Signal the end of the record and do any necessary clean-up."""
1156
+ # add together all of the sequence parts to create the
1157
+ # final sequence string
1158
+ self.data.sequence = "".join(self._seq_data)
1159
+ # add on the last feature
1160
+ self._add_feature()
1161
+
1162
+
1163
+ def parse(handle):
1164
+ """Iterate over GenBank formatted entries as Record objects.
1165
+
1166
+ >>> from Bio import GenBank
1167
+ >>> with open("GenBank/NC_000932.gb") as handle:
1168
+ ... for record in GenBank.parse(handle):
1169
+ ... print(record.accession)
1170
+ ['NC_000932']
1171
+
1172
+ To get SeqRecord objects use Bio.SeqIO.parse(..., format="gb")
1173
+ instead.
1174
+ """
1175
+ return iter(Iterator(handle, RecordParser()))
1176
+
1177
+
1178
+ def read(handle):
1179
+ """Read a handle containing a single GenBank entry as a Record object.
1180
+
1181
+ >>> from Bio import GenBank
1182
+ >>> with open("GenBank/NC_000932.gb") as handle:
1183
+ ... record = GenBank.read(handle)
1184
+ ... print(record.accession)
1185
+ ['NC_000932']
1186
+
1187
+ To get a SeqRecord object use Bio.SeqIO.read(..., format="gb")
1188
+ instead.
1189
+ """
1190
+ iterator = parse(handle)
1191
+ try:
1192
+ record = next(iterator)
1193
+ except StopIteration:
1194
+ raise ValueError("No records found in handle") from None
1195
+ try:
1196
+ next(iterator)
1197
+ raise ValueError("More than one record found in handle")
1198
+ except StopIteration:
1199
+ pass
1200
+ return record
1201
+
1202
+
1203
+ if __name__ == "__main__":
1204
+ from Bio._utils import run_doctest
1205
+
1206
+ run_doctest()
.venv_haddock/lib/python3.12/site-packages/Bio/GenBank/utils.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This code is part of the Biopython distribution and governed by its
2
+ # license. Please see the LICENSE file that should have been included
3
+ # as part of this package.
4
+ #
5
+
6
+ """Useful utilities for helping in parsing GenBank files."""
7
+
8
+
9
+ class FeatureValueCleaner:
10
+ r"""Provide specialized capabilities for cleaning up values in features.
11
+
12
+ This class is designed to provide a mechanism to clean up and process
13
+ values in the key/value pairs of GenBank features. This is useful
14
+ because in cases like::
15
+
16
+ /translation="MED
17
+ YDPWNLRFQSKYKSRDA"
18
+
19
+ you'll otherwise end up with white space in it.
20
+
21
+ This cleaning needs to be done on a case by case basis since it is
22
+ impossible to interpret whether you should be concatenating everything
23
+ (as in translations), or combining things with spaces (as might be
24
+ the case with /notes).
25
+
26
+ >>> cleaner = FeatureValueCleaner(["translation"])
27
+ >>> cleaner
28
+ FeatureValueCleaner(['translation'])
29
+ >>> cleaner.clean_value("translation", "MED\nYDPWNLRFQSKYKSRDA")
30
+ 'MEDYDPWNLRFQSKYKSRDA'
31
+ """
32
+
33
+ keys_to_process = ["translation"]
34
+
35
+ def __init__(self, to_process=keys_to_process):
36
+ """Initialize with the keys we should deal with."""
37
+ self._to_process = to_process
38
+
39
+ def __repr__(self):
40
+ """Return a string representation of the class."""
41
+ return f"{self.__class__.__name__}({self._to_process!r})"
42
+
43
+ def clean_value(self, key_name, value):
44
+ """Clean the specified value and return it.
45
+
46
+ If the value is not specified to be dealt with, the original value
47
+ will be returned.
48
+ """
49
+ if key_name in self._to_process:
50
+ try:
51
+ cleaner = getattr(self, f"_clean_{key_name}")
52
+ except AttributeError:
53
+ raise AssertionError(f"No function to clean key: {key_name}") from None
54
+ value = cleaner(value)
55
+ return value
56
+
57
+ def _clean_translation(self, value):
58
+ """Concatenate a translation value to one long protein string (PRIVATE)."""
59
+ translation_parts = value.split()
60
+ return "".join(translation_parts)
61
+
62
+
63
+ if __name__ == "__main__":
64
+ from Bio._utils import run_doctest
65
+
66
+ run_doctest()
.venv_haddock/lib/python3.12/site-packages/Bio/Geo/._Record.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Geo/.___init__.py ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Geo/.___pycache__ ADDED
Binary file (4.1 kB). View file
 
.venv_haddock/lib/python3.12/site-packages/Bio/Geo/Record.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2001 by Katharine Lindner. All rights reserved.
2
+ # Copyright 2006 by PeterC. All rights reserved.
3
+ # This code is part of the Biopython distribution and governed by its
4
+ # license. Please see the LICENSE file that should have been included
5
+ # as part of this package.
6
+
7
+ """Hold GEO data in a straightforward format.
8
+
9
+ classes:
10
+ o Record - All of the information in an GEO record.
11
+
12
+ See http://www.ncbi.nlm.nih.gov/geo/
13
+ """
14
+
15
+
16
+ class Record:
17
+ """Hold GEO information in a format similar to the original record.
18
+
19
+ The Record class is meant to make data easy to get to when you are
20
+ just interested in looking at GEO data.
21
+
22
+ Attributes:
23
+ entity_type
24
+ entity_id
25
+ entity_attributes
26
+ col_defs
27
+ table_rows
28
+
29
+ """
30
+
31
+ def __init__(self):
32
+ """Initialize the class."""
33
+ self.entity_type = ""
34
+ self.entity_id = ""
35
+ self.entity_attributes = {}
36
+ self.col_defs = {}
37
+ self.table_rows = []
38
+
39
+ def __str__(self):
40
+ """Return the GEO record as a string."""
41
+ output = ""
42
+ output += f"GEO Type: {self.entity_type}\n"
43
+ output += f"GEO Id: {self.entity_id}\n"
44
+ att_keys = sorted(self.entity_attributes)
45
+ for key in att_keys:
46
+ contents = self.entity_attributes[key]
47
+ if isinstance(contents, list):
48
+ for item in contents:
49
+ try:
50
+ output += f"{key}: {item[:40]}\n"
51
+ output += out_block(item[40:])
52
+ except Exception: # TODO: IndexError?
53
+ pass
54
+ elif isinstance(contents, str):
55
+ output += f"{key}: {contents[:40]}\n"
56
+ output += out_block(contents[40:])
57
+ else:
58
+ raise RuntimeError(f"unexpected contents of type {type(contents)}")
59
+ col_keys = sorted(self.col_defs)
60
+ output += "Column Header Definitions\n"
61
+ for key in col_keys:
62
+ val = self.col_defs[key]
63
+ output += f" {key}: {val[:40]}\n"
64
+ output += out_block(val[40:], " ")
65
+ # May have to display VERY large tables,
66
+ # so only show the first 20 lines of data
67
+ MAX_ROWS = 20 + 1 # include header in count
68
+ for row in self.table_rows[0:MAX_ROWS]:
69
+ output += f"{self.table_rows.index(row)}: "
70
+ for col in row:
71
+ output += f"{col}\t"
72
+ output += "\n"
73
+ if len(self.table_rows) > MAX_ROWS:
74
+ output += "...\n"
75
+ row = self.table_rows[-1]
76
+ output += f"{self.table_rows.index(row)}: "
77
+ for col in row:
78
+ output += f"{col}\t"
79
+ output += "\n"
80
+
81
+ return output
82
+
83
+
84
+ def out_block(text, prefix=""):
85
+ """Format text in blocks of 80 chars with an additional optional prefix."""
86
+ output = ""
87
+ for j in range(0, len(text), 80):
88
+ output += f"{prefix}{text[j : j + 80]}\n"
89
+ output += "\n"
90
+ return output