<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/sheap/">
    <title>sheap @ ウィキ</title>
    <link>http://w.atwiki.jp/sheap/</link>
    <atom:link href="https://w.atwiki.jp/sheap/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>sheap @ ウィキ</description>

    <dc:language>ja</dc:language>
    <dc:date>2008-07-10T17:04:31+09:00</dc:date>
    <utime>1215677071</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/19.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/18.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/17.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/16.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/15.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/14.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/13.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/12.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/11.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/sheap/pages/10.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/19.html">
    <title>7/10現在のDoSachicaの機能など</title>
    <link>https://w.atwiki.jp/sheap/pages/19.html</link>
    <description>
      今はMainMenu.javaから呼び出されて演算をして、異同やログなどを返す働き。これをWeb版(HTML? PHP?)と連動させて動かしたい。    </description>
    <dc:date>2008-07-10T17:04:31+09:00</dc:date>
    <utime>1215677071</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/18.html">
    <title>7月10日時点の目標</title>
    <link>https://w.atwiki.jp/sheap/pages/18.html</link>
    <description>
      ソースコードを解析し、入力フォーム・出力結果とWeb版Sachicaとが連携できるようにアルゴリズムを考える。ソース読みは100%終了。これから入力フォームを作る予定。

[17:00更新]問題点は、入力フォームからDoSachicaを呼び出して処理して出力に吐けるか、そのためにはどんな受け渡し方をすればいいか、ということ。    </description>
    <dc:date>2008-07-10T16:58:00+09:00</dc:date>
    <utime>1215676680</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/17.html">
    <title>このWikiの目的</title>
    <link>https://w.atwiki.jp/sheap/pages/17.html</link>
    <description>
      Sheapというゲノム比較プログラムのWeb版を作成するにあたり、裏側で何が起こっているか把握しないと根本的に何もできないので、ソースを解析して理解を深めています。その過程で自分が新しく学んだことや覚えたことをWikiの形でメモを取り自分の備忘録にしています。また同時に、自分と似た目的や方法で調べ物をする人のため、検索にかかりやすいWikiに書いて悩みが軽減するようにしています。    </description>
    <dc:date>2008-07-10T15:57:32+09:00</dc:date>
    <utime>1215673052</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/16.html">
    <title>OutputStreamクラスのflushメソッド</title>
    <link>https://w.atwiki.jp/sheap/pages/16.html</link>
    <description>
      公式リファレンスより。
http://sdc.sun.co.jp/java/docs/j2se/1.4/ja/docs/ja/api/java/io/OutputStream.html

OutputStreamクラス
&gt;この抽象クラスは、バイトの出力ストリームを表現するすべてのクラスのスーパークラスです。出力ストリームは、出力バイトを受け付けて、特定の受け手に送ります。
&gt;OutputStream のサブクラスを定義する必要のあるアプリケーションでは、少なくとも 1 バイトの出力を書き込むメソッドを必ず提供しなければなりなせん。(原文ママ)

flushメソッド
&gt;この出力ストリームをフラッシュし、バッファに入っている出力バイトをすべて強制的に書き込みます。flush の汎用規約では、それまでに書き込まれたバイトが出力ストリームの実装によってバッファに入れられている場合に flush を呼び出すと、それらのバイトはただちにその目的の転送先に書き込まれます。
&gt;OutputStream の flush メソッドは何も行いません。 

なんとなくわかったようなわからないような。出力に関するメソッドだということはわかりました。『なりなせん』はちゃんと通報した方がいいですよね。    </description>
    <dc:date>2008-07-10T15:44:33+09:00</dc:date>
    <utime>1215672273</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/15.html">
    <title>final属性</title>
    <link>https://w.atwiki.jp/sheap/pages/15.html</link>
    <description>
      final属性は、「これ以上変わらない」値等につける属性です。
クラスにつけると継承を受けつけず、メソッドにつけるとオーバーライドを受けつけず、変数につけると上書きができなくなります。

↓のサイトを参考させていただきました。
http://www.javaroad.jp/java_class12.htm    </description>
    <dc:date>2008-07-10T14:11:25+09:00</dc:date>
    <utime>1215666685</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/14.html">
    <title>いまここ7/9</title>
    <link>https://w.atwiki.jp/sheap/pages/14.html</link>
    <description>
      /**

 *

 * @author yaemon

 */



package jp.ac.nii.uno.sheap;//megun:パッケージはjp.ac.nii.uno.sheap



//megun:インポートするクラス　
//matsu:わっせわっせと準備します。

import java.io.BufferedReader;

import java.io.File;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.InputStreamReader;

import java.io.OutputStreamWriter;

import java.io.IOException;

import java.lang.Long;

import java.lang.ProcessBuilder;

import java.lang.Runtime;

import java.lang.String;

import java.lang.Throwable;

import java.util.Date;

import java.util.Iterator;

import java.util.List;

import java.util.ArrayList;



import jp.ac.nii.uno.sheap.ProgressLogger;//megun:jp.ac.nii.uno.sheap.ProgressLoggerからインポート





import java.lang.System;


//DoSachicaがはじまるよー！

public class DoSachica

{
    //いれもの準備ー

    private final boolean debug = false;    // if true, verbose to stderr.　megun:trueだとstderrがうるさいくらいに出る

    private final int commandsSteps = 10;   // 10 steps of sachica batch without sort(megun:Sachicaをいっぺんに10ステップずつソートする)

    private final int copyFileSteps = 2;    // 2 sort steps of sachica batch. but not sort, only copy.（megun:二つのSachicaを一括処理）



    private byte[] sachicaDataSeparator = { &#039;\n&#039; , &#039;\n&#039; };//megun：sachicaDataSeparator・sachicaを区切る改行タグ



    private final String Prefixes[] =　//megun:Prefixies−接頭辞

    {           // __tmp1__ is merged file・megun:混ざったファイル

                // __tmp2__ output repeat string・megun:繰り返す文字列を出力

                &quot;sachica_repeated&quot;,//sachicaリピート

                // __tmp3__ g,G:Exchange A&lt;-&gt;T, G&lt;-&gt;C for first, or 2nd to last string

                &quot;sachica_exchanged&quot;,//sachica変換

                &quot;sachica_linecount&quot;, // __tmp4__ is wc -l//sachicaラインカウント

                &quot;sachica_graphic&quot;  , // __tmp5__//sachicaグラフィック

                &quot;sachica_bold_graphic&quot; // __tmp6__//sachicaボールドグラフィック

    };
    //いれもの準備完了！
    
    //ファイルカモン♪

    public DoSachica( File inputFile1 , File inputFile2 , File outputFile, File logFile,

                                        long dataLength , long outputErrorCount )//DoSachicaメソッド
    //ファイルがこなくてがっかりしたらここをよめ。→うーんちょっとよくわかんないなー

       throws IOException

    {
    　　//ログとり開始〜

       ProgressLogger progress = new ProgressLogger( logFile );//進行ログ

　　　　　//念のため日付をいれときますか。

        Date now = new Date();//megun:現時刻の取得

        String tmpFileSuffix = Long.toString( now.getTime());//mgn:時刻を文字列化・suffixは接尾詞

　　　　　//デバックモードだったら丁寧に頼む。

        if ( debug )//mgn:debugがtrueの場合

        {

            System.err.println( &quot;tmpFileSuffix = &quot; + tmpFileSuffix );//mgn:tmpFileSuffixを表示

        }



	 //megun:tmpFiles, Commands, fileToCopyを宣言

        ArrayList&lt;File&gt; tmpFiles = new ArrayList&lt;File&gt;( Prefixes.length ); //megun:tenpFiles＝Prefixesの長さを求める　※複数形!!!

        ArrayList&lt;String[]&gt; Commands = new ArrayList&lt;String[]&gt;( commandsSteps ); //mgn:Commands＝commandsSteps(38行目)をリスト化

        ArrayList&lt;String[]&gt; fileToCopy = new ArrayList&lt;String[]&gt;( copyFileSteps ); //mgn:fileToCopy＝copyFileSteps(39行目)をリスト化

　　　　　
　　　　//さてそろそろはじめるかー

        try

        {
        　　　//ファイルが二個ありますね。

            File inputToSachica = mergeInputFile( inputFile1, inputFile2 , tmpFileSuffix ); //mgn:inputToSachica＝ファイル1＋ファイル2＋imtFileSuffixを混ぜる
            　//比較コマンドさんに助けをもとめた！

            initCommandsList( Commands , fileToCopy, tmpFiles ,

                              inputToSachica.getAbsolutePath() , outputFile.getAbsolutePath(),//mgn:入出力ファイルの絶対パスを取得

                              Long.toString( dataLength ) ,//mgn:データの長さを文字列化

                              Long.toString( outputErrorCount ) ,//mgn:エラーの数を文字列化

                              tmpFileSuffix );//mgn:tmpFileSuffix
                              
              //デバックモードならここを丁寧にね。

            if ( debug )//mgn:debugがtrueの場合

            {

                printCommands( Commands );//mgn:Commandsを表示

            }
            　//子供をつくった〜

            doChildProcess( Commands , /*progress*/prosess );//mgn:208行目にdoChildProcessメソッド

            fileCopyWithoutSort( fileToCopy , progress);//232行目からfileCopyWithoutSortメソッド

            if ( ! debug )//mgm:debugがfalseの場合・デバッグモードじゃない時

            {

                inputToSachica.delete();//mgn:デバッグしてないと消去

            }

        }

        catch( IOException e )//mgn:例外

        {

            progress.write( e.getLocalizedMessage() );//mgn:ローカライズされたメッセージを取得

        }



        // Is it need? mgn:(これいるの？)

        finally

        {

            progress.close();//mgn:進行ログを閉じる

        }

    }
    //入力ファイルを比較するメソッド

    private void initCommandsList(//CommandListを初期化

                            // output

                            ArrayList&lt;String[]&gt; Commands , ArrayList&lt;String[]&gt; fileToCopy,

                            // working files

                            ArrayList&lt;File&gt; tmpFiles,//mgn:複数形

                            // normal paramator

                            String inputFileName , String outputFileName ,

                            String dataLength      , String outputErrorCount ,

                            String tmpFileSuffix)

        throws IOException

    {

        //一時ファイルの名前をつける
        ArrayList&lt;String&gt; tmpFilesNames = new ArrayList&lt;String&gt;( Prefixes.length );//mgn:tmpFileName＝Prefixesの長さの配列

        //
        for ( int i = 0 ; i &lt; Prefixes.length ; i++ )//mgn:Prefixesの分まで

        {

            File tmpFile = File.createTempFile( Prefixes[i], tmpFileSuffix );//mgn:tmpFile＝Prefixed配列にtmpFileSuffixを収納　※単数形!!!!!!

            tmpFiles.add( i, tmpFile );//mgn:tmpFilesのi番目にtmpFileを加える

            tmpFilesNames.add( i , tmpFile.getPath() );//mgn:tmpFilesNamesのi番目にtmpFileのgetPathを加える

            tmpFile.deleteOnExit();//mgn:tmpFileの中身を消す

        }





        final String CurrentPath = &quot;.&quot; + File.separator;//mgn:カレントパス



        final String sachica  = CurrentPath + &quot;sachica&quot;;//.+sachica

        final String pairsort = CurrentPath + &quot;pairsort&quot;;//.+pairsort

        final String sachicax = CurrentPath + &quot;sachicax&quot;;//.+sachicax

        final String sachicam = CurrentPath + &quot;sachicam&quot;;//.+sachicam

        // final String sort     = CurrentPath + &quot;sort&quot;;//.+sort





        //Commandsに解析結果を投入

		Commands.add(  0, new String[]

                    { sachica , &quot;picoNV&quot; , &quot;-s&quot;, &quot;&#039;N&#039;&quot;, &quot;-k&quot; , &quot;255&quot;, &quot;-h&quot;,

                      tmpFilesNames.get(2) , inputFileName, dataLength , outputErrorCount ,

                      tmpFilesNames.get(0) } );



        Commands.add(  1, new String[]

                    { sachica , &quot;picoNRGV&quot;, &quot;-s&quot;, &quot;&#039;N&#039;&quot;, &quot;-k&quot; , &quot;255&quot;,

                      inputFileName, dataLength , outputErrorCount ,

                      tmpFilesNames.get(1) } );



        Commands.add(  2, new String[]

                    { pairsort , tmpFilesNames.get(0) , outputFileName + &quot;.out&quot; } );



        Commands.add(  3, new String[]

                    { sachicax , outputFileName + &quot;.out&quot; , &quot;3000&quot;, &quot;3&quot; , &quot;300&quot;,

                      outputFileName + &quot;x.out&quot; } );



        Commands.add(  4, new String[]

                    { pairsort , tmpFilesNames.get(1) , outputFileName + &quot;r.out&quot; } );



        Commands.add(  5, new String[]

                    { sachicax , outputFileName + &quot;r.out&quot; , &quot;3000&quot; , &quot;3&quot; , &quot;300&quot;, 

                      outputFileName + &quot;rx.out&quot; } );



        Commands.add(  6, new String[]

                    { sachicam , &quot;-H&quot; , tmpFilesNames.get(2), &quot;-R&quot;,

                      outputFileName + &quot;r.out&quot; ,

                      outputFileName + &quot;.out&quot; ,

                      &quot;1000&quot; , &quot;0&quot; ,

                      outputFileName + &quot;.pgm&quot; } );



        Commands.add(  7, new String[]

                    { sachicam , &quot;-t&quot; , &quot;1&quot; , &quot;-H&quot; ,

                      tmpFilesNames.get(2), &quot;-R&quot;,

                      outputFileName + &quot;rx.out&quot; ,

                      outputFileName + &quot;x.out&quot; ,

                      &quot;1000&quot; , &quot;0&quot; ,

                      outputFileName + &quot;x.pgm&quot; } );



        Commands.add(  8, new String[]

                    { sachicam , &quot;-d&quot; , tmpFilesNames.get(3),

                      outputFileName + &quot;x.out&quot; ,

                      &quot;1000&quot; , &quot;0&quot; ,

                      tmpFilesNames.get(4) } );



        Commands.add( 9, new String[]

                    { sachicam , &quot;-E&quot;, 

                      tmpFilesNames.get(3) , 

                      outputFileName + &quot;rx.out&quot; ,  

                      &quot;1000&quot; , &quot;0&quot; ,

                      tmpFilesNames.get(4)

                    } );



        /*



        // sort -n (GNU) not sort numeric ( with -t&quot;,&quot; option too ) 



        Commands.add(  9, new String[]

                    { sort , &quot;-n&quot; , tmpFilesNames.get(3) , &quot;&gt;&quot; ,

                      outputFileName + &quot;_pos.out&quot; } );



        Commands.add( 11, new String[]

                    { sort , &quot;-n&quot; , tmpFilesNames.get(3) , &quot;&gt;&quot; , 

                      outputFileName + &quot;r_pos.out&quot; } );

        */
        //fileToCopyに追加

        fileToCopy.add( 0, new String[]

                { tmpFilesNames.get(3) , outputFileName + &quot;_pos.out&quot; } );



        fileToCopy.add( 1, new String[]

                { tmpFilesNames.get(3) , outputFileName + &quot;r_pos.out&quot; } );



    }
    //子プロセスを作るメソッド(Commands,Progress)

    private void doChildProcess( ArrayList&lt;String[]&gt; Commands , ProgressLogger progress )

        throws IOException

    {

            String[] command;//commandsじゃなくてcommand

            ProcessBuilder process = new ProcessBuilder( &quot;&quot; );//ProcessBuilderから出てきました

            process.redirectErrorStream( true );

            for ( Iterator&lt;String[]&gt; walker = Commands.iterator(); walker.hasNext();)//walker数＝Commands数になるまで

            {

                command = walker.next();

                process.command( command );

                Process child =  process.start();//child＝スタート



                final BufferedReader logReader = new BufferedReader(

                        new InputStreamReader( child.getInputStream() )

                        );

                String line;//String型の変数line

                while( (line = logReader.readLine())  != null )

                {

                    progress.write( line );//lineの情報を書き出す。

                }

            }

    }

    private void fileCopyWithoutSort( ArrayList&lt;String[]&gt; fileToCopyPair , ProgressLogger progress )//fileToCopy､ ProgressLogger

        throws IOException//ファイルを並べ替えずにコピーするメソッド

    {

        for ( Iterator&lt;String[]&gt; walker = fileToCopyPair.iterator(); walker.hasNext(); )//walker＝fileToCopyPairになるまで

        {

            String[] pair = walker.next();//pairという名の配列

            progress.write( &quot;Create &quot; + pair[1] );//書き出す

            File src = new File( pair[0] );//srcとdstを宣言

            File dst = new File( pair[1] );



            BufferedReader srcStream = new BufferedReader( new FileReader( src ));//入力

            BufferedWriter dstStream = new BufferedWriter( new FileWriter( dst ));//出力

            String line;//String型・line



            while ( ( line = srcStream.readLine() ) != null )//同じ値が出るまで

            {

                dstStream.write( line );//lineの中を入力

                dstStream.newLine();

            }

            srcStream.close();

            dstStream.close();

        }

    }



    private File mergeInputFile( File inputFile1, File inputFile2 , String tmpFileSuffix)

        throws IOException

    {

        if ( debug )

        {

            System.err.println( &quot;I&#039;m in mergeInputFile &quot; + inputFile1.getPath() + &quot; &quot; + tmpFileSuffix );

        }



        final String tmpFilePrefix = &quot;sheap&quot;;

        File inputToSachica = File.createTempFile( tmpFilePrefix, tmpFileSuffix );

        if ( debug )

        {

            System.err.println( &quot;merged file name is &quot; + inputToSachica.getAbsolutePath() );

        }



        FileOutputStream out = new FileOutputStream( inputToSachica );



        FileInputStream in_1   = new FileInputStream( inputFile1 );

        dataOnlyWrite( out, in_1 );

        in_1.close();



        out.write( sachicaDataSeparator );



        FileInputStream in_2   = new FileInputStream( inputFile2 );

        dataOnlyWrite( out, in_2 );

        in_2.close();



        // Accept Java&#039;s buggy method

        // out.flush();

        out.close();



        return inputToSachica;

    }



    private void dataOnlyWrite( FileOutputStream out , FileInputStream in ) 

        throws IOException

    {

        BufferedReader readStream = new BufferedReader( new InputStreamReader( in ));

        BufferedWriter outStream  = new BufferedWriter( new OutputStreamWriter( out ));



        String line;

        while( ( line = readStream.readLine() ) != null )

        {

            if ( line.charAt(0) != &#039;&gt;&#039; )

            {

                outStream.write( line );

                outStream.newLine( );

            }

        }

        outStream.flush();

    }



    // to debug only

    private void printCommands( ArrayList&lt;String[]&gt; Commands )

    {

            String[] command;

            for ( Iterator&lt;String[]&gt; walker = Commands.iterator(); walker.hasNext();)

            {

                command = walker.next();

                for ( int i = 0 ; i &lt; command.length ; i++ )

                {

                    System.err.println( command[i] + &quot; &quot; );

                }

                System.err.println( &#039;\n&#039; );

            }

    }

}


漏れは生きていていいんでしょうか。久々の鬱期。    </description>
    <dc:date>2008-07-09T20:57:32+09:00</dc:date>
    <utime>1215604652</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/13.html">
    <title>newLine定数</title>
    <link>https://w.atwiki.jp/sheap/pages/13.html</link>
    <description>
      newLine定数は、文字列の改行に使います。環境(OS)に合わせた改行文字列を返すので、改行タグ&quot;/n&quot;よりも自由度が高いです。

↓のサイトを参考にさせていただきました。
http://dobon.net/vb/dotnet/string/newline.html    </description>
    <dc:date>2008-07-09T20:56:03+09:00</dc:date>
    <utime>1215604563</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/12.html">
    <title>init</title>
    <link>https://w.atwiki.jp/sheap/pages/12.html</link>
    <description>
          </description>
    <dc:date>2008-07-09T18:53:26+09:00</dc:date>
    <utime>1215597206</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/11.html">
    <title>viエディタの使い方</title>
    <link>https://w.atwiki.jp/sheap/pages/11.html</link>
    <description>
          </description>
    <dc:date>2008-07-08T18:51:43+09:00</dc:date>
    <utime>1215510703</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/sheap/pages/10.html">
    <title>プラグイン/コメント</title>
    <link>https://w.atwiki.jp/sheap/pages/10.html</link>
    <description>
      * コメントプラグイン
@wikiのwikiモードでは
 #comment()
と入力することでコメントフォームを簡単に作成することができます。
詳しくはこちらをご覧ください。
＝＞http://atwiki.jp/guide/17_60_ja.html


-----
たとえば、#comment() と入力すると以下のように表示されます。

#comment    </description>
    <dc:date>2008-07-08T18:29:39+09:00</dc:date>
    <utime>1215509379</utime>
  </item>
  </rdf:RDF>
