1 首先对生物序列进行blast比对:得出网格图分析的点和边两部分。
第一:首先用blast用序列对fasta数据建库,建库中会产生,phr结尾的数据库文件
D:\blast1\bin>formatdb -i D:\blast1\fasta\T3SE_All_check.fasta -o T -p T
第二:用blastall命令对程序进行比对,保留生成的比对结果,把结果保留到文件中。
D:\blast1\bin>blastall -i D:\blast1\fasta\T6SE_All_check.fasta -p blastp -d D:\blast1\fasta\T6SE_All_check.fasta -m 8 -e 0.001 -o T6se.txt
2 这里采取的是点是用数据库的fastahead头信息所以保证fasta文件中的头信息与数据库中的头信息保持一致也是很重要的。
代码部分:
StatisticsController
@RequestMapping("/gettestjsondata6")
public BastionResponse getJsonData6() throws IOException, JSONException {
HashMap output = new HashMap();
//read edges from csv
List edgeList = new ArrayList();
BufferedReader br;
br = new BufferedReader(new FileReader("C:\\Users\\hy\\Desktop\\blast\\T6se.txt"));
String stemp;
while ((stemp = br.readLine()) != null) {
HashMap jsonObject = new HashMap();
stemp = stemp.toLowerCase(); //读取的序列信息统一调整为小写
String[] list = stemp.split("\t"); //按照文件序列中的空格符作为切割,分别把数据存放到列表中。
//String[] list = stemp.split(",");
jsonObject.put("source", list[0]);//把取到的第一个信息,也就是头赋值给source
jsonObject.put("target", list[1]);
jsonObject.put("value", list[2]);
HashMap dataJsonObject = new HashMap();//初始化一个hashmap存储,然后存储
dataJsonObject.put("data", jsonObject); //
edgeList.add(dataJsonObject); //把边放入
}
output.put("edges", edgeList);
//read nodes from database;
List nodesList = new ArrayList();
List<Protein> proteins = proteinService.getProteinNodesByType("T6SE");//这里有问题 是因为在T6se的数据库中存在一条序列的fastahead为空,这里
//利用下面的在数据库中查找的头信息存储到链表中,实现了从数据库中获取的头信息
for (int i=0;i<proteins.size();i++){ //然后是遍历
String originalHead = proteins.get(i).getFastaHead(); //
originalHead = originalHead.toLowerCase();
String[] Heads = originalHead.split(" ");//头信息用空格分割
String matchHead = Heads[0];
Integer proteinID = proteins.get(i).getProteinID();//直接重新定义一份从数据库中获得蛋白质ID,然后把id从数据库中取出来,和取头信息的方法大同小异
String url = "http://localhost:8080/searchresults/showdetail?id=" + proteinID.toString();
HashMap nodeMap = new HashMap();
nodeMap.put("id",matchHead);//对应的头信息和url匹配,把这两个放入到hashmap中进行匹配
nodeMap.put("href",url);
HashMap nodeDataMap = new HashMap();
nodeDataMap.put("data",nodeMap);
nodesList.add(nodeDataMap);
}
output.put("nodes", nodesList);
return new BastionResponse().data(output);//把output结果放入到data中然后传送到前台js中
}
在ProteinService中定义一个
List<Protein> getProteinNodesByType(String type);//获得蛋白质的分泌类型
去定义需要从数据库中获取一个目的字段的信息
然后在ProteinSeriveImpl中去具体实现查询的过程
@Override
public List<Protein> getProteinNodesByType(String type) {
return proteinMapper.selectList(new QueryWrapper<Protein>().like("flagType", type));//在数据库中选择分泌种类
}
转载cytoscape:https://blog.csdn.net/cuishizun/article/details/82710493?tdsourcetag=s_pctim_aiomsg