Args<-commandArgs()
inputFile<-Args[6]
inputType<-Args[7]
inputNetwork<-Args[8]
outputType<-Args[9]
outputFile<-Args[10]
if(inputType=="mRNA"&&outputType=="mRNA"){
file<-read.csv(inputNetwork,header=T)
print("mRNA-mRNA")
}else if(inputType=="mRNA"&&outputType=="lncRNA"){
file<-read.csv(inputNetwork,header=T)
print("mRNA-lncRNA")
}else if(inputType=="lncRNA"&&outputType=="lncRNA"){
file<-read.csv(inputNetwork,header=T)
print("lncRNA-lncRNA")
}else if(inputType=="lncRNA"&&outputType=="mRNA"){
file<-read.csv(inputNetwork,header=T)
print("lncRNA-mRNA")
}else{
print ("Input RNA type is wrong")
}
gene<-read.table(inputFile,sep="t",header=F)
file<-as.matrix(file)
geneset<-as.character(gene[,1])
re<-c()
for(i in 1:length(geneset))
{
location1<-which(file[,1]%in%as.character(geneset[i]))
location2<-which(file[,3]%in%as.character(geneset[i]))
if(length(location1)!=0)
{
re<-rbind(re,file[location1,])
}
if(length(location2)!=0)
{
re1<-cbind(file[location2,3],file[location2,2],file[location2,1],file[location2,4])
re<-rbind(re,re1)
}
}
write.table(re,outputFile,sep="t",row.names=F,quote=F)