Skip to content

Commit

Permalink
Version 1.25
Browse files Browse the repository at this point in the history
  • Loading branch information
jernst98 committed Dec 29, 2023
1 parent 58d448c commit 3e64f8f
Show file tree
Hide file tree
Showing 7 changed files with 868 additions and 306 deletions.
Binary file modified ChromHMM.jar
Binary file not shown.
Binary file modified ChromHMM.zip
Binary file not shown.
Binary file modified ChromHMM_manual.pdf
Binary file not shown.
84 changes: 53 additions & 31 deletions edu/mit/compbio/ChromHMM/BrowserOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ else if (n1 > n2)
*/
boolean bgzip;

/**
* True if header leaders on browser bed files should be surpressed
*/
boolean bnobrowserheader;

public BrowserOutput(String szsegmentfile, String szcolormapping,String szidlabelmapping,
String szsegmentationname, String szoutputfileprefix, int numstates, boolean bgzip) throws IOException
String szsegmentationname, String szoutputfileprefix, int numstates, boolean bgzip, boolean bnobrowserheader) throws IOException
{
this.szsegmentfile = szsegmentfile;
this.szcolormapping =szcolormapping;
Expand All @@ -136,6 +140,7 @@ public BrowserOutput(String szsegmentfile, String szcolormapping,String szidlabe
this.szoutputfileprefix = szoutputfileprefix;
this.numstates = numstates;
this.bgzip = bgzip;
this.bnobrowserheader = bnobrowserheader;

hmcolor = new HashMap();
hmlabelExtend = new HashMap();
Expand Down Expand Up @@ -383,7 +388,7 @@ public void makebrowserdense() throws IOException
int nend = Integer.parseInt(st.nextToken().trim());
String szFullID = st.nextToken().trim();
String szID = szFullID.substring(1); //this removes ordering type
if (bfirst)
if ((bfirst)&&(!bnobrowserheader))
{
String szout = "track name=\""+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szFullID.charAt(0))
+" ordered)"+"\" visibility=1 itemRgb=\"On\""+"\n";
Expand Down Expand Up @@ -423,15 +428,15 @@ public void makebrowserdense() throws IOException
String szLine;
boolean bfirst = true;

while ((szLine =brsegment.readLine())!=null)
while ((szLine = brsegment.readLine())!=null)
{
StringTokenizer st = new StringTokenizer(szLine,"\t");
String szcurrchrom = st.nextToken().trim();
int nbegin = Integer.parseInt(st.nextToken().trim());
int nend = Integer.parseInt(st.nextToken().trim());
String szFullID = st.nextToken().trim();
String szID = szFullID.substring(1); //this removes ordering type
if (bfirst)
if ((bfirst)&&(!bnobrowserheader))
{
pw.println("track name=\""+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szFullID.charAt(0))
+" ordered)"+"\" visibility=1 itemRgb=\"On\"");
Expand Down Expand Up @@ -559,19 +564,23 @@ public void makebrowserexpanded() throws IOException
if (bgzip)
{
GZIPOutputStream pwzip = new GZIPOutputStream(new FileOutputStream(szoutputfileprefix+ChromHMM.SZBROWSEREXPANDEDEXTENSION+".bed.gz"));
String szout = "track name=\"Expanded_"+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
byte[] btformat;
if (!bnobrowserheader)
{
String szout = "track name=\"Expanded_"+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
+" ordered)"+"\" visibility=2 itemRgb=\"On\""+"\n";
byte[] btformat = szout.getBytes();
pwzip.write(btformat,0,btformat.length);
btformat = szout.getBytes();
pwzip.write(btformat,0,btformat.length);

//pw.println("track name=\"Expanded_"+szsegmentationname+"\" description=\" "+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
// +" ordered)"+"\" visibility=2 itemRgb=\"On\"");
int nbrowserend = (int) (((Integer)hmchromMax.get(szChroms[0])).intValue()*.001)+1;
//pw.println("track name=\"Expanded_"+szsegmentationname+"\" description=\" "+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
// +" ordered)"+"\" visibility=2 itemRgb=\"On\"");
int nbrowserend = (int) (((Integer)hmchromMax.get(szChroms[0])).intValue()*.001)+1;

szout = "browser position "+szChroms[0]+":1-"+nbrowserend+"\n";
btformat = szout.getBytes();
pwzip.write(btformat,0,btformat.length);
//pwzip.println("browser position "+szChroms[0]+":1-"+nbrowserend);
szout = "browser position "+szChroms[0]+":1-"+nbrowserend+"\n";
btformat = szout.getBytes();
pwzip.write(btformat,0,btformat.length);
//pwzip.println("browser position "+szChroms[0]+":1-"+nbrowserend);
}

for (int nlabel = szLabels.length-1; nlabel >=0; nlabel--)
{
Expand Down Expand Up @@ -641,10 +650,14 @@ public void makebrowserexpanded() throws IOException
else
{
PrintWriter pw = new PrintWriter(new FileWriter(szoutputfileprefix+ChromHMM.SZBROWSEREXPANDEDEXTENSION+".bed"));
pw.println("track name=\"Expanded_"+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))

if (!bnobrowserheader)
{
pw.println("track name=\"Expanded_"+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
+" ordered)"+"\" visibility=2 itemRgb=\"On\"");
int nbrowserend = (int) (((Integer)hmchromMax.get(szChroms[0])).intValue()*.001)+1;
pw.println("browser position "+szChroms[0]+":1-"+nbrowserend);
int nbrowserend = (int) (((Integer)hmchromMax.get(szChroms[0])).intValue()*.001)+1;
pw.println("browser position "+szChroms[0]+":1-"+nbrowserend);
}

for (int nlabel = szLabels.length-1; nlabel >=0; nlabel--)
{
Expand Down Expand Up @@ -802,20 +815,25 @@ public void makebrowserexpandedLowMem() throws IOException

if (bgzip)
{
byte[] btformat;

GZIPOutputStream pwzip = new GZIPOutputStream(new FileOutputStream(szoutputfileprefix+ChromHMM.SZBROWSEREXPANDEDEXTENSION+".bed.gz"));
String szout = "track name=\"Expanded_"+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
+" ordered)"+"\" visibility=2 itemRgb=\"On\""+"\n";
byte[] btformat = szout.getBytes();
pwzip.write(btformat,0,btformat.length);
if (!bnobrowserheader)
{
String szout = "track name=\"Expanded_"+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
+" ordered)"+"\" visibility=2 itemRgb=\"On\""+"\n";
btformat = szout.getBytes();
pwzip.write(btformat,0,btformat.length);

//pw.println("track name=\"Expanded_"+szsegmentationname+"\" description=\" "+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
// +" ordered)"+"\" visibility=2 itemRgb=\"On\"");
int nbrowserend = (int) (((Integer)hmchromMax.get(szChroms[0])).intValue()*.001)+1;
//pw.println("track name=\"Expanded_"+szsegmentationname+"\" description=\" "+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
// +" ordered)"+"\" visibility=2 itemRgb=\"On\"");
int nbrowserend = (int) (((Integer)hmchromMax.get(szChroms[0])).intValue()*.001)+1;

szout = "browser position "+szChroms[0]+":1-"+nbrowserend+"\n";
btformat = szout.getBytes();
pwzip.write(btformat,0,btformat.length);
//pwzip.println("browser position "+szChroms[0]+":1-"+nbrowserend);
szout = "browser position "+szChroms[0]+":1-"+nbrowserend+"\n";
btformat = szout.getBytes();
pwzip.write(btformat,0,btformat.length);
//pwzip.println("browser position "+szChroms[0]+":1-"+nbrowserend);
}

for (int nchrom = 0; nchrom < szChroms.length; nchrom++)
{
Expand Down Expand Up @@ -915,10 +933,14 @@ public void makebrowserexpandedLowMem() throws IOException
else
{
PrintWriter pw = new PrintWriter(new FileWriter(szoutputfileprefix+ChromHMM.SZBROWSEREXPANDEDEXTENSION+".bed"));
pw.println("track name=\"Expanded_"+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
if (!bnobrowserheader)
{

pw.println("track name=\"Expanded_"+szsegmentationname+"\" description=\""+szsegmentationname+" ("+ChromHMM.convertCharOrderToStringOrder(szLabelFull.charAt(0))
+" ordered)"+"\" visibility=2 itemRgb=\"On\"");
int nbrowserend = (int) (((Integer)hmchromMax.get(szChroms[0])).intValue()*.001)+1;
pw.println("browser position "+szChroms[0]+":1-"+nbrowserend);
int nbrowserend = (int) (((Integer)hmchromMax.get(szChroms[0])).intValue()*.001)+1;
pw.println("browser position "+szChroms[0]+":1-"+nbrowserend);
}

for (int nchrom = 0; nchrom < szChroms.length; nchrom++)
{
Expand Down
Loading

0 comments on commit 3e64f8f

Please sign in to comment.