package ubic.gemma.util;

/*
 * The Gemma project
 * 
 * Copyright (c) 2008 University of British Columbia
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

/**
 * @author paul
 * @version $Id$
 */
public class ChannelUtils {

    /**
     * For two-color arrays: Given the quantitation type name, determine if it represents the channel A background.
     * 
     * @param name
     * @return
     */
    public static boolean isBackgroundChannelA( String name ) {
        return name.equals( "CH1B_MEDIAN" ) || name.equals( "CH1_BKD" )
                || name.toLowerCase().matches( "b532[\\s_\\.](mean|median)" )
                || name.equals( "BACKGROUND_CHANNEL 1MEDIAN" ) || name.equals( "G_BG_MEDIAN" )
                || name.equals( "Ch1BkgMedian" ) || name.equals( "ch1.Background" ) || name.equals( "CH1_BKG_MEAN" )
                || name.equals( "CH1_BKD_ Median" ) || name.equals( "BKG1Mean" );
    }

    /**
     * For two-color arrays: Given the quantitation type name, determine if it represents the channel B background.
     * 
     * @param name
     * @return
     */
    public static boolean isBackgroundChannelB( String name ) {
        return name.equals( "CH2B_MEDIAN" ) || name.equals( "CH2_BKD" )
                || name.toLowerCase().matches( "b635[\\s_\\.](mean|median)" )
                || name.equals( "BACKGROUND_CHANNEL 2MEDIAN" ) || name.equals( "R_BG_MEDIAN" )
                || name.equals( "Ch2BkgMedian" ) || name.equals( "ch2.Background" ) || name.equals( "CH2_BKG_MEAN" )
                || name.equals( "CH2_BKD_ Median" ) || name.equals( "BKG2Mean" );
    }

    /**
     * For two-color arrays: Given the quantitation type name, determine if it represents the channel A signal. (by
     * convention, green)
     * 
     * @param name
     * @return
     */
    public static boolean isSignalChannela( String name ) {
        return name.matches( "CH1(I)?_MEDIAN" ) || name.matches( "CH1(I)?_MEAN" ) || name.equals( "RAW_DATA" )
                || name.toLowerCase().matches( "f532[\\s_\\.](mean|median)" ) || name.equals( "SIGNAL_CHANNEL 1MEDIAN" )
                || name.toLowerCase().matches( "ch1_smtm" ) || name.equals( "G_MEAN" ) || name.equals( "Ch1SigMedian" )
                || name.equals( "ch1.Intensity" ) || name.equals( "CH1_SIG_MEAN" ) || name.equals( "CH1_ Median" )
                || name.toUpperCase().matches( "\\w{2}\\d{3}_CY3" ) || name.toUpperCase().matches( "NORM(.*)CH1" )
                || name.equals( "CH1Mean" ) || name.equals( "CH1_SIGNAL" ) || name.equals( "\"log2(532), gN\"" )
                || name.equals( "gProcessedSignal" );
    }

    /**
     * For two-color arrays: Given the quantitation type name, determine if it represents the channel B signal. (by
     * convention, red)
     * 
     * @param name
     * @return
     */
    public static boolean isSignalChannelB( String name ) {
        return name.matches( "CH2(I)?_MEDIAN" ) || name.matches( "CH2(I)?_MEAN" ) || name.equals( "RAW_CONTROL" )
                || name.toLowerCase().matches( "f635[\\s_\\.](mean|median)" ) || name.equals( "SIGNAL_CHANNEL 2MEDIAN" )
                || name.toLowerCase().matches( "ch2_smtm" ) || name.equals( "R_MEAN" ) || name.equals( "Ch2SigMedian" )
                || name.equals( "ch2.Intensity" ) || name.equals( "CH2_SIG_MEAN" ) || name.equals( "CH2_ Median" )
                || name.toUpperCase().matches( "\\w{2}\\d{3}_CY5" ) || name.toUpperCase().matches( "NORM(.*)CH2" )
                || name.equals( "CH2Mean" ) || name.equals( "CH2_SIGNAL" ) || name.equals( "\"log2(635), gN\"" )
                || name.equals( "rProcessedSignal" );
    }

}

@@ -2779,37 +2779,38 @@
 sity%22 ) %7C%7C name.
-equal
+matche
 s( %22CH1_SIG_MEAN
@@ -2801,31 +2801,56 @@
 s( %22CH1_SIG_
+(
 MEAN
-%22 )
+%7CMEDIAN)%22 )%0A               
  %7C%7C name.equ
@@ -2869,32 +2869,16 @@
 edian%22 )
-%0A               
  %7C%7C name
@@ -2921,16 +2921,32 @@
 %7D_CY3%22 )
+%0A               
  %7C%7C name
@@ -2984,32 +2984,16 @@
 *)CH1%22 )
-%0A               
  %7C%7C name
@@ -3008,24 +3008,40 @@
  %22CH1Mean%22 )
+%0A               
  %7C%7C name.equ
@@ -3140,32 +3140,67 @@
 ProcessedSignal%22
+ ) %7C%7C name.equals( %22CH1_SIG_MEDIAN%22
  );%0A    %7D%0A%0A    /
@@ -3857,37 +3857,38 @@
 sity%22 ) %7C%7C name.
-equal
+matche
 s( %22CH2_SIG_MEAN
@@ -3883,23 +3883,48 @@
 CH2_SIG_
+(
 MEAN
-%22 )
+%7CMEDIAN)%22 )%0A               
  %7C%7C name
@@ -3947,32 +3947,16 @@
 edian%22 )
-%0A               
  %7C%7C name
@@ -3999,16 +3999,32 @@
 %7D_CY5%22 )
+%0A               
  %7C%7C name
@@ -4062,32 +4062,16 @@
 *)CH2%22 )
-%0A               
  %7C%7C name
@@ -4086,24 +4086,40 @@
  %22CH2Mean%22 )
+%0A               
  %7C%7C name.equ

update for signal channel name patterns (for GSE10218)