mimosa-tool 1.0.0__cp314-cp314-win_amd64.whl
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.
- mimosa/__init__.py +46 -0
- mimosa/_core/__init__.py +17 -0
- mimosa/_core/_core.cp314-win_amd64.pyd +0 -0
- mimosa/_core/bindings.cpp +28 -0
- mimosa/_core/core_functions.h +29 -0
- mimosa/_core/fasta_to_plain.h +182 -0
- mimosa/_core/mco_prc.cpp +1476 -0
- mimosa/_core/pfm_to_pwm.h +130 -0
- mimosa/cli.py +619 -0
- mimosa/comparison.py +1066 -0
- mimosa/execute.py +97 -0
- mimosa/functions.py +787 -0
- mimosa/io.py +522 -0
- mimosa/models.py +1161 -0
- mimosa/pipeline.py +402 -0
- mimosa/ragged.py +126 -0
- mimosa_tool-1.0.0.dist-info/METADATA +432 -0
- mimosa_tool-1.0.0.dist-info/RECORD +21 -0
- mimosa_tool-1.0.0.dist-info/WHEEL +5 -0
- mimosa_tool-1.0.0.dist-info/entry_points.txt +3 -0
- mimosa_tool-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
double pfm[MATLEN][OLIGNUM];
|
|
2
|
+
|
|
3
|
+
int NthColumn(char *din, char *dout, int nstol)
|
|
4
|
+
{
|
|
5
|
+
int p1, p2;
|
|
6
|
+
if(nstol==0)p1=-1;
|
|
7
|
+
else
|
|
8
|
+
{
|
|
9
|
+
p1=StrNStr(din,'\t',nstol);
|
|
10
|
+
if(p1==-1)return -1;
|
|
11
|
+
}
|
|
12
|
+
p2=StrNStr(din,'\t',nstol+1);
|
|
13
|
+
if(p2==-1)p2=strlen(din);
|
|
14
|
+
int len=p2-p1-1;
|
|
15
|
+
strncpy(dout,&din[p1+1],len);
|
|
16
|
+
if(len==0)return -1;
|
|
17
|
+
dout[len]='\0';
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
int pfm_to_pwm(char *file_pfm, double **mat)
|
|
21
|
+
{
|
|
22
|
+
char d[500],head[500], s[500];
|
|
23
|
+
int i, j, len=0;
|
|
24
|
+
double nseq;//=atoi(argv[3]);
|
|
25
|
+
int shift_col;//=atoi(argv[4]);
|
|
26
|
+
|
|
27
|
+
FILE *in_pfm;
|
|
28
|
+
if((in_pfm=fopen(file_pfm,"rt"))==NULL)
|
|
29
|
+
{
|
|
30
|
+
printf("Input file %s can't be opened!\n",file_pfm);
|
|
31
|
+
return -1;
|
|
32
|
+
}
|
|
33
|
+
int alfabet=0;
|
|
34
|
+
fgets(head,sizeof(head),in_pfm);
|
|
35
|
+
fgets(head,sizeof(head),in_pfm);
|
|
36
|
+
//homer, cis-bp
|
|
37
|
+
nseq=1000000000;
|
|
38
|
+
//shift_col=0;
|
|
39
|
+
{
|
|
40
|
+
DelChar(head,'\n');
|
|
41
|
+
DelChar(head,'\r');
|
|
42
|
+
int headlen= strlen(head);
|
|
43
|
+
if(head[headlen-1]=='\t')
|
|
44
|
+
{
|
|
45
|
+
head[headlen-1]='\0';
|
|
46
|
+
headlen--;
|
|
47
|
+
}
|
|
48
|
+
int counttab=0;
|
|
49
|
+
for(i=0;i<headlen;i++)
|
|
50
|
+
{
|
|
51
|
+
if(head[i]=='\t')counttab++;
|
|
52
|
+
}
|
|
53
|
+
if(counttab==4 || counttab==16)
|
|
54
|
+
{
|
|
55
|
+
shift_col=1;
|
|
56
|
+
alfabet=counttab;
|
|
57
|
+
}
|
|
58
|
+
else
|
|
59
|
+
{
|
|
60
|
+
if(counttab==3 || counttab==15)
|
|
61
|
+
{
|
|
62
|
+
shift_col=0;
|
|
63
|
+
alfabet=counttab+1;
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
{
|
|
67
|
+
printf("Reading errorin Cisbp/Homer matrix file %s !\n",file_pfm);
|
|
68
|
+
return -1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
rewind(in_pfm);
|
|
73
|
+
|
|
74
|
+
int olen=0;
|
|
75
|
+
fgets(head,sizeof(head),in_pfm);
|
|
76
|
+
for(i=0;i<MATLEN;i++)
|
|
77
|
+
{
|
|
78
|
+
if(fgets(d,sizeof(d),in_pfm)!=NULL)
|
|
79
|
+
{
|
|
80
|
+
char c=d[0];
|
|
81
|
+
if(isdigit(c) || (strchr("-ATGC",c)!=0))olen++;
|
|
82
|
+
}
|
|
83
|
+
else break;
|
|
84
|
+
}
|
|
85
|
+
rewind(in_pfm);
|
|
86
|
+
fgets(head,sizeof(head),in_pfm);
|
|
87
|
+
for(i=0;i<MATLEN;i++)
|
|
88
|
+
{
|
|
89
|
+
if(fgets(d,sizeof(d),in_pfm)!=NULL)
|
|
90
|
+
{
|
|
91
|
+
// DelChar(d,'\n');
|
|
92
|
+
// DelChar(d,'\r');
|
|
93
|
+
char c=d[0];
|
|
94
|
+
if(isdigit(c) || (strchr("-ATGC",c)!=0))
|
|
95
|
+
{
|
|
96
|
+
// printf("%s",d[i]);
|
|
97
|
+
for(j=0;j<alfabet;j++)
|
|
98
|
+
{
|
|
99
|
+
if(NthColumn(d,s,j+shift_col)==-1)
|
|
100
|
+
{
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
//double score=atof(s);
|
|
104
|
+
//pfm[i][j]=nseq*score;
|
|
105
|
+
pfm[i][j]=atof(s);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else break;
|
|
109
|
+
}
|
|
110
|
+
else break;
|
|
111
|
+
}
|
|
112
|
+
//logodds score
|
|
113
|
+
double pse=0.25;
|
|
114
|
+
double pse4=1;
|
|
115
|
+
double vych=log10(pse);
|
|
116
|
+
int olen1=olen-1;
|
|
117
|
+
for(i=0;i<olen;i++)
|
|
118
|
+
{
|
|
119
|
+
double sum=0;
|
|
120
|
+
for(j=0;j<alfabet;j++)sum+=nseq*pfm[i][j];
|
|
121
|
+
int alfabet1=alfabet-1;
|
|
122
|
+
for(j=0;j<alfabet;j++)
|
|
123
|
+
{
|
|
124
|
+
double count=nseq*pfm[i][j];
|
|
125
|
+
double ves=(count+pse)/(sum+pse4);
|
|
126
|
+
mat[i][j]=log10(ves)-vych;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return olen;
|
|
130
|
+
}
|