Script
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
//get the output file location
FileWriter out = new FileWriter(filename2);
//use scanner to get the input scream
Scanner input = new Scanner (gbfile);
//store all the list line
List allInformation = new ArrayList();
// initialize the string will be used as parameters
// s0 is the start point to end point
// s1 is the gene number
// s2 is the lucus tag
// s3 is the translation table
// s4 is the function of the product
// s5 is the protein
// s6 is the tranlation protein
String s0 = " ";
String s1 = " ";
String s2 = " ";
String s3 = " ";
String s4 = " ";
String s5 = " ";
s6="";
// this function is used for write any specified string to as a prefix-table format
outputcontent(String anyString, int a, int b){
count = 0;
any = anyString.toCharArray();
while(count + b any.length)
{
out.write(anyString,count,any.length-count);
out.write("\n");
count = any.length;
}
}
// this function is used for write one single gene and its corresponding
// CDS information to a outputscream
outputthings(String startToEnd, String gene, String locus, String table,
String product, String protein, String translation )
{
out.write(" gene complement(");
out.write( startToEnd);
out.write(")");
out.write("\n");
out.write(" ");
outputcontent(gene, 21, 40);
out.write(" ");
outputcontent(locus, 21, 40);
out.write(" CDS complement(");
out.write( startToEnd);
out.write(")");
out.write("\n");
out.write(" ");
outputcontent(gene, 21, 40);
out.write(" ");
outputcontent(locus, 21, 40);
out.write(" /codon_start=1");
out.write("\n");
out.write(" ");
outputcontent(table, 21, 40);
out.write(" /product=");
outputcontent( product, 21, 40);
out.write(" /protein_id=");
outputcontent(protein, 21, 40);
out.write(" /translation=");
out.write("\n");
out.write(" ");
outputcontent(translation, 21, 40);
}
// write the initialization information for the genbank format
out.write("LOCUS ");
out.write("\n");
out.write("DEFINITION ");
out.write("\n");
out.write("ACCESSION ");
out.write("\n");
out.write("VERSION ");
out.write("\n");
out.write("DBLINK ");
out.write("\n");
out.write("KEYWORDS ");
out.write("\n");
out.write("SOURCE ");
out.write("\n");
out.write(" ORGANISM ");
out.write("\n");
out.write("REFERENCE ");
out.write("\n");
out.write(" AUTHORS ");
out.write("\n");
out.write(" TITLE ");
out.write("\n");
out.write("COMMENT ");
out.write("\n");
out.write("FEATURES Location/Qualifiers");
out.write("\n");
// get the protein ID information from the inputscream of a genbank gene file
String tems = input.next();
tems = input.next();
s5 = tems;
while(input.hasNext())
{
// get the gene identity number
if(tems.startsWith("/gene"))
{
s1=tems;
}
// get the locus_tag
else if(tems.startsWith("/locus"))
{
s2=tems;
}
// get the translation table number as a string
else if(tems.startsWith("/trans"))
{
s3=tems;
}
// get the specified information of the product
else if(tems.equals("DEFINITION"))
{
tems = input.next();
s4=tems;
tems = input.next();
s4 = s4.concat(" ");
s4 = s4.concat(tems);
}
// get the start point to end information
else if(tems.equals("source"))
{
tems = input.next();
s0=tems;
}
// get the translated protein sequence of this gene
else if(tems.equals("ORIGIN"))
{
while(!input.hasNext("//"))
{
if(input.hasNextInt())
{
input.next();
}
else
{
s6 = s6.concat(input.next());
}
}
}
tems = input.next();
}
// write the single gene information as to the genbank organism format
outputthings(s0,s1,s2,s3,s4,s5,s6);
out.close();
Comments (0)
No comments yet
Log in to make a comment