Question: Finding Upstream And Downstream Genes For Intergenic Region
0
gravatar for Divya
8.3 years ago by
Divya70
Divya70 wrote:

hi everyone..!! I have written a java program to find the upstream gene of the given value as input and also i have given annotation file as input. but now im not getting the upstream gene which im getting throgh gbrowse here is my program. plz kindly help me out

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
public class Sample
{
public static void main(String args[]) throws FileNotFoundException
{
FilePojo fp=null;
long n=0;
Boolean flag=false;
Long temp=0L;
int temp1=0;
System.out.println("Enter the value");
Scanner sc=new ScannerSystem.in);
n=sc.nextLong();
ArrayList<Integer> Val1list=new ArrayList<Integer>();
ArrayList<Integer> Val2list=new ArrayList<Integer>();
ArrayList<String> IDlist=new ArrayList<String>();
try
{
FileInputStream fis=new FileInputStream("chr01.gb");
InputStreamReader in = new InputStreamReader(fis, "UTF-8");
BufferedReader input = new BufferedReader(in);
String line;
while((line=input.readLine())!=null)
{

String splits[]=line.split("\t");

if(splits[2].equalsIgnoreCase("mrna"))
{
Val1list.add(Integer.parseInt(splits[3]));
Val2list.add(Integer.parseInt(splits[4]));
IDlist.add(splits[8]);
}
}
for(int i=0; i<Val2list.size(); i++)="" {="" if(i="=0)" {="" temp="(n-Val2list.get(i));" temp1="i;" }="" else="" {="" if(temp="">(n-Val2list.get(i)))
{
temp=n-Val2list.get(i);
temp1=i;
}
}
}
System.out.println("ID "+IDlist.get(temp1)+"difference "+temp);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

*and iput file sample two lines*

chr01    RAP3_rep    mRNA    22619184    22623061    .    -    .    ID=Os01t0556201-00;Name=Os01t0556201-00;ID_converter=Os01g0556201;Locus_id=Os01g0556201;Note=Hypothetical gene.;ORF_evidence=LongestORF;Transcript_evidence=BT016873 (DDBJ);Sequence_download=Os01t0556201-00
chr01    RAP3_rep    five_prime_UTR    22622716    22623061    .    -    .    Parent=Os01t0556201-00
chr01    RAP3_rep    five_prime_UTR    22619683    22620077    .    -    .    Parent=Os01t0556201-00
chr01    RAP3_rep    CDS    22619239    22619682    .    -    .    Parent=Os01t0556201-00
chr01    RAP3_rep    three_prime_UTR    22619184    22619238    .    -    .    Parent=Os01t0556201-00
chr01    RAP3_rep    mRNA    25818194    25820282    .    -    .    ID=Os01t0611050-00;Name=Os01t0611050-00;ID_converter=Os01g0611050;Locus_id=Os01g0611050;Note=Hypothetical gene.;ORF_evidence=LongestORF;Transcript_evidence=BT016258 (DDBJ);Sequence_download=Os01t0611050-00
chr01    RAP3_rep    five_prime_UTR    25820185    25820282    .    -    .    Parent=Os01t0611050-00
chr01    RAP3_rep    five_prime_UTR    25819756    25820007    .    -    .    Parent=Os01t0611050-00
chr01    RAP3_rep    five_prime_UTR    25819621    25819681    .    -    .    Parent=Os01t0611050-00
chr01    RAP3_rep    CDS    25819614    25819620    .    -    .    Parent=Os01t0611050-00
chr01    RAP3_rep    CDS    25818922    25819035    .    -    .    Parent=Os01t0611050-00
chr01    RAP3_rep    CDS    25818780    25818837    .    -    .    Parent=Os01t0611050-00
chr01    RAP3_rep    CDS    25818194    25818270    .    -    .    Parent=Os01t0611050-00
java • 1.8k views
ADD COMMENTlink modified 8.3 years ago by Istvan Albert ♦♦ 80k • written 8.3 years ago by Divya70
3

Why do you have to do this in java? Use a dedicated interval overlap library or IRanges in R. That will reduce your problem to about 2 lines of code.

ADD REPLYlink written 8.3 years ago by Michael Dondrup46k
2

Your code is hard to read, please add some indentations, comments to you source code & name your variables (n, temp, temp1, Val1List,... ) according to their functions.

ADD REPLYlink written 8.3 years ago by Pierre Lindenbaum121k
2
gravatar for Istvan Albert
8.3 years ago by
Istvan Albert ♦♦ 80k
University Park, USA
Istvan Albert ♦♦ 80k wrote:

Your code is suboptimal in too many ways to be fixable in a few lines of advice.

That being said I am guessing that your problem is due to your code not taking into account the comparison of negative numbers -1000 is smaller than -100

ADD COMMENTlink written 8.3 years ago by Istvan Albert ♦♦ 80k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1699 users visited in the last hour