cvmcore 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {cvmcore-0.2.0 → cvmcore-0.2.1}/PKG-INFO +2 -2
  2. cvmcore-0.2.1/cvmcore/__init__.py +10 -0
  3. cvmcore-0.2.1/cvmcore/cvmcore.py +143 -0
  4. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore.egg-info/PKG-INFO +2 -2
  5. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore.egg-info/requires.txt +0 -1
  6. {cvmcore-0.2.0 → cvmcore-0.2.1}/setup.py +7 -1
  7. cvmcore-0.2.0/cvmcore/__init__.py +0 -10
  8. cvmcore-0.2.0/cvmcore/cvmcore.py +0 -1455
  9. {cvmcore-0.2.0 → cvmcore-0.2.1}/README.md +0 -0
  10. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore/inputdir/CPF_RS14355.fasta +0 -0
  11. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore/inputdir/CPF_RS14360.fasta +0 -0
  12. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore/inputdir/CPF_RS14365.fasta +0 -0
  13. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore/test.py +0 -0
  14. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore.egg-info/SOURCES.txt +0 -0
  15. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore.egg-info/dependency_links.txt +0 -0
  16. {cvmcore-0.2.0 → cvmcore-0.2.1}/cvmcore.egg-info/top_level.txt +0 -0
  17. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/demo.ipynb +0 -0
  18. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/gene_feature.csv +0 -0
  19. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/circular_dendrogram.png +0 -0
  20. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/circular_dendrogram_color_label.png +0 -0
  21. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/circular_dendrogram_openangle.png +0 -0
  22. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/circular_dendrogram_startangle.png +0 -0
  23. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/circular_dendrogram_tippoints.png +0 -0
  24. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/dendrogram.png +0 -0
  25. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/dendrogram_heatmap_cmap.png +0 -0
  26. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/dendrogram_heatmap_minimumvalue.png +0 -0
  27. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/dendrogram_with_heatmap.png +0 -0
  28. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/gene_arrow_all.png +0 -0
  29. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/gene_arrow_bottom.png +0 -0
  30. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/gene_arrow_top.png +0 -0
  31. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/multiple_heatmap.png +0 -0
  32. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/phylogenetic_tree.png +0 -0
  33. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/phylotree_heatmap_withgenes.png +0 -0
  34. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/phylotree_multiple_heatmap.png +0 -0
  35. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/phylotree_with_heatmap-remove_tiplabel.png +0 -0
  36. {cvmcore-0.2.0 → cvmcore-0.2.1}/demodata/screenshots/phylotree_with_heatmap.png +0 -0
  37. {cvmcore-0.2.0 → cvmcore-0.2.1}/requirements.txt +0 -0
  38. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_11_1.png +0 -0
  39. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_13_1.png +0 -0
  40. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_15_1.png +0 -0
  41. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_20_0.png +0 -0
  42. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_23_0.png +0 -0
  43. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_25_0.png +0 -0
  44. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_27_0.png +0 -0
  45. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_29_0.png +0 -0
  46. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_35_0.png +0 -0
  47. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_39_1.png +0 -0
  48. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_41_1.png +0 -0
  49. {cvmcore-0.2.0 → cvmcore-0.2.1}/screenshots/output_7_0.png +0 -0
  50. {cvmcore-0.2.0 → cvmcore-0.2.1}/setup.cfg +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cvmcore
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: SZQ lab data analysis core function
5
- Home-page: https://github.com/hbucqp/cvmcore
5
+ Home-page: https://github.com/hbucqp/cvmplot
6
6
  Author: Qingpo Cui
7
7
  Author-email: cqp@cau.edu.cn
8
8
  License: MIT Licence
@@ -0,0 +1,10 @@
1
+ # -*- coding:utf-8 -*-
2
+
3
+ __title__ = 'cvmplot'
4
+ __description__ = 'Major plot function used by SZQ lab from China Agricultural University'
5
+ __url__ = 'https://github.com/hbucqp/cvmplot'
6
+ __version__ = "0.2.1"
7
+ __author__ = 'Qingpo Cui'
8
+ __author_email__ = 'cqp@cau.edu.cn'
9
+ __license__ = 'MIT'
10
+ __copyright__ = 'Copyright 2023 Qingpo Cui'
@@ -0,0 +1,143 @@
1
+ import os
2
+ import sys
3
+ import time
4
+
5
+ # data process
6
+ import numpy as np
7
+ import pandas as pd
8
+ from scipy.cluster.hierarchy import linkage, dendrogram, complete, to_tree
9
+ from scipy.spatial.distance import squareform
10
+ from tabulate import tabulate
11
+ from io import StringIO
12
+ import warnings
13
+ # from Bio.Blast import NCBIWWW
14
+ with warnings.catch_warnings():
15
+ warnings.simplefilter('ignore', category=DeprecationWarning)
16
+ from Bio import SeqIO
17
+ from Bio import Phylo
18
+ from Bio.Seq import Seq
19
+ from Bio.SeqRecord import SeqRecord
20
+ from Bio.Blast import NCBIXML
21
+
22
+
23
+ # matplotlib
24
+ import matplotlib
25
+ import matplotlib as mpl
26
+ from matplotlib import pyplot as plt
27
+ from matplotlib.lines import Line2D
28
+ from matplotlib.patches import Patch, FancyArrow
29
+ from matplotlib.transforms import Affine2D
30
+ from matplotlib.colors import LinearSegmentedColormap
31
+ import matplotlib.collections as mpcollections
32
+ from mpl_toolkits.axes_grid1.inset_locator import inset_axes
33
+ from typing import Optional, List, Dict, Union, Tuple
34
+
35
+ plt.rcParams['font.family'] = 'sans-serif'
36
+ plt.rcParams['font.sans-serif'] = ['Arial']
37
+ plt.rcParams['svg.fonttype'] = 'none'
38
+
39
+
40
+ class cfunc():
41
+ pass
42
+
43
+ @staticmethod
44
+ def is_fasta(file):
45
+ """
46
+ chcek if the input file is fasta format
47
+ """
48
+ try:
49
+ with open(file, "r") as handle:
50
+ records = SeqIO.parse(handle, "fasta")
51
+ # False when `fasta` is empty, i.e. wasn't a FASTA file
52
+ for record in records:
53
+ pass
54
+ return true
55
+ except:
56
+ print(f'The input file {file} is not a valid fasta file.')
57
+ return False
58
+
59
+ def get_mod_time(file):
60
+ """
61
+ Return the last modified time of file as YYYY-MM-DD string format.
62
+ Parameters
63
+ ----------
64
+ file :
65
+ file path string
66
+ Returns
67
+ ----------
68
+ Raises
69
+ ----------
70
+ Notes
71
+ ----------
72
+ References
73
+ ----------
74
+ See Also
75
+ ----------
76
+ Examples
77
+ ----------
78
+ """
79
+ file = os.path.abspath(file)
80
+ md_time = os.stat(file).st_mtime
81
+ lst_mod_time = time.strftime("%Y-%m-%d", time.localtime(md_time))
82
+ return lst_mod_time
83
+
84
+ def check_sequence_type(file_path):
85
+ """
86
+ Check the input file type (DNA or Amino Acid)
87
+ """
88
+ try:
89
+ # Read the sequence from the file
90
+ records = list(SeqIO.parse(file_path, "fasta"))
91
+ if not records:
92
+ return "Unknown"
93
+
94
+ sequence = str(records[0].seq).upper()
95
+
96
+ # Define sets of characters for DNA and amino acids
97
+ dna_chars = set("ATCG")
98
+ amino_acid_chars = set("ACDEFGHIKLMNPQRSTVWY")
99
+
100
+ # Check if the sequence contains only DNA characters
101
+ if set(sequence).issubset(dna_chars):
102
+ return "DNA"
103
+ # Check if the sequence contains only amino acid characters
104
+ elif set(sequence).issubset(amino_acid_chars):
105
+ return "Amino Acid"
106
+ else:
107
+ return "Unknown"
108
+ except Exception as e:
109
+ return f"Error: {e}"
110
+
111
+ @staticmethod
112
+ def alleles2ref(files_dir: str, outpath: str, outname: str):
113
+ """
114
+ Create cgMLST reference sequences using fasta files downloaded from "https://www.cgmlst.org/"
115
+ """
116
+ files_dir = os.path.abspath(files_dir)
117
+ new_records = []
118
+ for file in os.listdir(files_dir):
119
+ # print(file)
120
+ if file.endswith('.fasta'):
121
+ file_base = file.split('.')[0]
122
+ # print(file_base)
123
+ file = os.path.join(files_dir, file)
124
+ records = SeqIO.parse(file, 'fasta')
125
+ for record in records:
126
+ record.id = file_base + "_" + record.id
127
+ record.name = file_base + "_" + record.name
128
+ record.description = ''
129
+ # print(record.id)
130
+ # print(record)
131
+ new_records.append(record)
132
+
133
+ # check if outpath exists
134
+ outdir = os.path.abspath(outpath)
135
+ if not os.path.exists(outdir):
136
+ os.makedirs(outdir, exist_ok=True)
137
+
138
+ # Specify the output file nameå
139
+ output_file = f'{outname}.fsa'
140
+ output_file = os.path.join(outdir, output_file)
141
+ # Write the modified sequences to the new fasta file
142
+ with open(output_file, "w") as output_handle:
143
+ SeqIO.write(new_records, output_handle, "fasta")
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cvmcore
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: SZQ lab data analysis core function
5
- Home-page: https://github.com/hbucqp/cvmcore
5
+ Home-page: https://github.com/hbucqp/cvmplot
6
6
  Author: Qingpo Cui
7
7
  Author-email: cqp@cau.edu.cn
8
8
  License: MIT Licence
@@ -5,4 +5,3 @@ matplotlib
5
5
  numpy
6
6
  scipy
7
7
  tabulate
8
- dask
@@ -18,7 +18,13 @@ except ImportError:
18
18
 
19
19
 
20
20
  requirements = [
21
- 'Bio', 'pandas', 'setuptools', 'matplotlib', 'numpy', 'scipy', 'tabulate', 'dask'
21
+ 'Bio',
22
+ 'pandas',
23
+ 'setuptools',
24
+ 'matplotlib',
25
+ 'numpy',
26
+ 'scipy',
27
+ 'tabulate'
22
28
  ]
23
29
 
24
30
  about = {}
@@ -1,10 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
-
3
- __title__ = 'cvmbcore'
4
- __description__ = 'core function of data analysis used by SZQ lab from China Agricultural University'
5
- __url__ = 'https://github.com/hbucqp/cvmcore'
6
- __version__ = "0.2.0"
7
- __author__ = 'Qingpo Cui'
8
- __author_email__ = 'cqp@cau.edu.cn'
9
- __license__ = 'MIT'
10
- __copyright__ = 'Copyright 2023 Qingpo Cui'