我正在尝试访问所有<光谱> XML文件中“ms level”值等于1的标记。然后,生成一个.txt文件,其中包含标记内的数据字符串,包括位,无论数据是否被压缩,以及原始二进制字符串。然后应该进一步对文件中的任何其他标记执行相同操作。这是一个我不允许使用解析库的项目。
我不确定如何在不使用外部库的情况下访问XML文件中的标记,然后在标记内提取数据。我理解如何完成任务的高级计划,但不知道我应该使用什么工具。
编辑:我想到的是,在第一个<之前,文件中有更多文件。光谱>标签出现。在创建第一个mzmlFileBuffer时,它只获取整个文件的第一行“<?xml version =”1.0“encoding =”ISO-8859-1“?>”而且我不确定为什么。它不会访问整个文件中带有标签的任何内容,这也是我想知道该怎么做的。
这是文件的一个示例:
<spectrum index="0" id="controllerType=0 controllerNumber=1 scan=1" defaultArrayLength="1625">
<cvParam cvRef="MS" accession="MS:1000511" name="ms level" value="1"/>
<cvParam cvRef="MS" accession="MS:1000130" name="positive scan" value=""/>
<cvParam cvRef="MS" accession="MS:1000580" name="MSn spectrum" value=""/>
<cvParam cvRef="MS" accession="MS:1000127" name="centroid spectrum" value=""/>
<cvParam cvRef="MS" accession="MS:1000528" name="lowest observed m/z" value="451.17056274414062"/>
<cvParam cvRef="MS" accession="MS:1000527" name="highest observed m/z" value="1199.9544677734375"/>
<cvParam cvRef="MS" accession="MS:1000504" name="base peak m/z" value="786.59503173828125"/>
<cvParam cvRef="MS" accession="MS:1000505" name="base peak intensity" value="6488257.5"/>
<cvParam cvRef="MS" accession="MS:1000285" name="total ion current" value="114753896"/>
<scanList count="1">
<cvParam cvRef="MS" accession="MS:1000795" name="no combination" value=""/>
<scan instrumentConfigurationRef="IC1">
<cvParam cvRef="MS" accession="MS:1000616" name="preset scan configuration" value="1"/>
<cvParam cvRef="MS" accession="MS:1000498" name="full scan" value=""/>
<cvParam cvRef="MS" accession="MS:1000016" name="scan start time" value="0.259" unitCvRef="UO" unitAccession="UO:0000010" unitName="second"/>
</scan>
</scanList>
<binaryDataArrayList count="2">
<binaryDataArray encodedLength="6748">
<cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/>
<cvParam cvRef="MS" accession="MS:1000574" name="zlib compression" value=""/>
<cvParam cvRef="MS" accession="MS:1000514" name="m/z array" value="" unitCvRef="MS" unitAccession="MS:1000040" unitName="m/z"/>
<binary>eJwt13tcj3f/wPFrq3A73UM5RhfCpuR2nCm6qBzLMWyEax1sQxFiI1yIm+SYYrfSpYNjuFNtRulyyLA0Jm4bcW3KmMOM8rMpfnt8Xp+/no/3+fP9Vg8PiqKYx3vGaoqiqOnjhMZL6ZjxQm3dBKF9JJS+umFC8/EnQv0/8+gvQvuvRbh/JfUPVwuVumux9TahNScD47Lom5fH3s359P33DGYWs7/4GvURvzB3/BnvuVSF5Y5LuY/Wp/WEamIP4lE9qXsMEyrx44j7TiD2/pA4IEJodNtGHJMk1Adkss9nD/taVWJoFfV3q4VagcMy5usJtc7OQr27u9D8sYvQinyX+soJ1DdFEBfF0Od7TKhOPSm0vV4IlXCn5aKvRT2hcRCt482EynwX8idaCvUnEULTYQZzIz8R2o/QyooRqrVo713E/JRN+GA7fX3zmfc4hsop8n7F3Dl8nvuFN/DRffzrJfU4R0O8o6oZ1mspVJzbC/XmHYXqedTquQttF7TiPai7edKf0JP5h72oJ3xAPWew0Fjrx3x9f+JjI6g3DaT/zDjiK6jsG08+Jpj+/h9SnzGZfNEU9sWGyHeiEhVK/ikaI8IxGc1hMzFU+gKVUfP4nDPn0x8Wg4sW46SV1F/Es39wAnM1W+XnTiR/fTt7L6fxrgaZ5Jtk8z31QSPkKPve5DLvkIet0OyK1gdoBMu4RwF7x0lHniLf7yx98agmoXXnO+5rJdRTUPe/Qt9a1NuX0Z+OWr608BbvafIbNnBYIfakNRBqJU2FimcztNHo6izUe7YRqhaaSR2IfTrS/5a70BqO9h0PHO1J3/1e2KE387NR+UrGb9C43J++N97ko33I1xvAO28Mpl7Hn3kNtWvSoYHcvYlGUDDvdwyn/x8LqAetYk/n9cTqNvoGJfE53FO4/2M6+WuZeDObPXoe+/ej9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P/uRf+m99nzUT/mdvrSFzqKvii0oqcQW1PpXzCd+c2LuZO8jL7P1+KreFyayNyq7cRxO4VqWCp7muaSd/gac46xL/E0fWUXyW/6jv7E73mfw1XuJ6NuXif/TDrwJvXBd/hczX4nf/85tvg/9j18zZ00hy3inRl1hcq+BkL7SGts6io0u7oR10pzumKKh1BN6kt8vj978ryZy/UltiZSD4kWWkXzqZ9axPy3S7bwc1spNI7HET9ZS9/prbzTfQfxeyns8zDJT91H/+WD5K8eYc+u0/TvLaV+9TL9f9m8y7xP39M2W0V8tZ1Qq3ITmi/7YeYQfDOC+qFAoeEwWqh2Hiu03xkv1F+j1XQSe9/+kLr3ZKwbQt59OpbPY2/jBOInG9nbfDP7/pnIvvg06l5ZvKfmAHPbDtLvcIR8o1zutEGj6dfMqyfIuxex98rf/j/gwvqS</binary>
</binaryDataArray>
<binaryDataArray encodedLength="7872">
<cvParam cvRef="MS" accession="MS:1000521" name="32-bit float" value=""/>
<cvParam cvRef="MS" accession="MS:1000574" name="zlib compression" value=""/>
<cvParam cvRef="MS" accession="MS:1000515" name="intensity array" value="" unitCvRef="MS" unitAccession="MS:1000131" unitName="number of counts"/>
<binary>eJwNlndAD/obhUsahJJRlMpIRrIJP9s5n++3a2VmRRlZuUgidEVXWbeiXZLSHpSSpvYgKtIwCpWKrIQI/fr7/fO85zmP/rN2OCRoSbdtVxDV6s9g0+0azi2SkWxp7cYWGy+hWvGaP/5W5sfsZsqEdSJyvidMwnLwP7Wn0Pr7DK9+mCyOrHKDxyYF3qt1x/Gb8fjeLxvKmQo8avkTbmnzJYrybvR3cIVxeyAs5D+g4oQdKgZqi/bYH1AM+Emb/is5LfcWEoxlGT3yX/io3MaW+S7oNtKPrz5uZcgjGUYtdcUWuevQ3PCJq1Ujcbo8FBu+ClFOM+FgMYP9vvghssIFq1/+i8aNNzAipb+YquCApy6TxR9LJ947MpFVH825MfKOkLt2EpLCeugV6LNi2Tloz9hJ3ahg7HxxDFV7XiDQeKMkY6SE+cGe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aqPEfKoBbbF51H9LR51hqP501WNk8yKsPVKIv6nUY60+344Z52DjMXJGOXViw+2WfIi+lBH5yuswz1QMykRmuOqoX7lDnbuyca9r6P4bpwf7rmvpu4qTzzpWYFXmx7AcXwWFk3X4KcgHb47IEPfU0d4vGcdduyuRP3i+5jf3YVTL2pzjrIMfy6Lxk+zRCw1CoO7jhkTFv3N+B43YfWxj8RdbwZP74mFpo1rVyWaMML5BvaNTMChDGcmueXglZUOQz+0o+xQHOVv3EfzDEUWBcxl1MFsYmA+nq8NxbtjPvy9+zomNhbBadM8DrOUp8ycGMgaj+GW1nDol9ShY99H/Mqax/NF5DNdRW61+4nDRbF4eyITsv1DsNUjEDXOVThV0Yhxy/LQ4hCBWNcbmL9Hhu82xWNyqAEHt6Z0bd8tDA9bxcMXtokRm5VE6X/vIROvxbirPpj9ZRPnbv2OcZZKfNici5ZvEaibcAoTunfimnIJVhu+xdyGDuycnIFwX3km/QpH8Kc17G25gheOL2ROaSEG30qA9UsZTtl6H6dW+KP3rDn8JSsrauob2D07AqVT5XmoyzWU0gKwObQr60INfkt+hC8Dm/Dd1w/p5jFIHbNLOMf2FtlF5vz8JQp5nbE4fFCXlkxAT+cM7HJ0Q47tHNY3ZKCvXwoytNYzOOg+rnbl5DpjiJj4r4wIDdtNtwkZCNlTgd3KcnRp6/I1k3TunV3JN8PGMqXrv1PugiahHxn4tz96hbui9loM7k5W4Ibc8/B0Osref6Vhj5w1JbPvIp592aOkHt3WJuLzzUSsbgtAg7GCuJZTxQTlgeL48+u0VwvEjDF9GVI8gdvqn6Djr1E8GPEHrR7x0P3kB23lS/jH3g3fpbUsGjKaO7NGUWXOD/hGvcTtvAjmVXpwFeZz/IB0/B/ml2Pk</binary>
</binaryDataArray>
</binaryDataArrayList>
</spectrum>
这就是我的代码,我的下一步是使用strstr来查看我想要提取的相应数据的spectrumString:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
char mzmlFileBuffer[23000];
char *spectrumPtr;
char *spectrumEndPtr;
int indexStart;
int indexEnd;
char spectrumString[18000];
FILE *fp;
fp = fopen("32_64_compressed.mzML", "r");
if (fp == NULL) {
printf("File failed to open...");
exit(EXIT_FAILURE);
}
while (fgets(mzmlFileBuffer, 23000, fp) != NULL) {
//FIND FIRST OCCURRENCE OF <SPECTRUM
spectrumPtr = strstr(mzmlFileBuffer, "<spectrum ");
indexStart = spectrumPtr - mzmlFileBuffer;
//FIND END OF SPRECTRUM
spectrumEndPtr = strstr(mzmlFileBuffer, "</spectrum>");
indexEnd = spectrumEndPtr - mzmlFileBuffer;
//CREATE NEW STRING BETWEEN INDICES
strncpy(spectrumString, spectrumPtr, indexEnd - indexStart);
//IF SPECTRUM IS MS LEVEL 1
//if (strstr(spectrumString, "name=\"ms level\" value=\"1\"") != NULL) {
//
//}
}
}
答案 0 :(得分:3)
编写一个完全一致的_
解析器是一个庞大而复杂的项目。如果用于文件的实际格式简单而有规律,那么您的方法将起作用,但演示文稿中的任何更改都将破坏您的简单解析器。
您应该在任何地方添加一致性检查,以检测此类偏离预期格式。
另请注意,_
不符合您的想法。你应该永远不要使用这个功能。它不适合这项工作。要从字符串中提取片段,请使用xs.foreach(println)
并手动添加最终xml
。顺便提一下,如果size参数小于源字符串的长度,strncpy
将不会为目标终止目的地。
根据memcpy
文件的大小,将整个文件读入缓冲区并从此缓冲区解析可能更简单。一次读取一行需要您实现某种形式的状态机来跟踪伪解析阶段。
您能否与我们分享阻止您使用xml解析库的原因?可能有一些方法可以在项目中包含解析代码,并保持在约束条件和包许可证的约束下。
编辑:由于您在基础C课程中并且不应该使用外部库,因此这项任务非常令人惊讶。他们可能期望你编写一个快速而肮脏的解决方案,搜索标记字符串和'\0'
字符串引号,提取片段,可能转换二进制编码,如base64。在一般情况下很难使这项工作,但对于特定的给定文件,您应该能够生成一个有效的解决方案。