// Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//     
//     private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//     
//     public static String getParent(String path) {
//         // check root
//         if(path.equals("/")) {
//             return null;
//         }
//         
//         int lastIdx = path.lastIndexOf("/");
//         if(lastIdx > 0) {
//             return path.substring(0, lastIdx);
//         } else {
//             return "/";
//         }
//     }
//     
//     public static String concatPath(String path1, String path2) {
//         StringBuffer sb = new StringBuffer();
//         
//         if(path1 != null && !path1.isEmpty()) {
//             sb.append(path1);
//         }
//         
//         if(!path1.endsWith("/")) {
//             sb.append("/");
//         }
//         
//         if(path2 != null && !path2.isEmpty()) {
//             if(path2.startsWith("/")) {
//                 sb.append(path2.substring(1, path2.length()));
//             } else {
//                 sb.append(path2);
//             }
//         }
//         
//         return sb.toString();
//     }
//     
//     public static String getExtensionOfDecompressedFile(String name) {
//         String myname = name;
//         int idx = myname.lastIndexOf(".");
//         if(idx > 0) {
//             String ext = myname.substring(idx + 1);
//             for(String cext : COMPRESSED_EXT) {
//                 if(cext.equalsIgnoreCase(ext)) {
//                     // compressed
//                     myname = myname.substring(0, idx);
//                     break;
//                 }
//             }
//         } else {
//             return null;
//         }
//         
//         idx = myname.lastIndexOf(".");
//         if(idx > 0) {
//             return myname.substring(idx + 1);
//         }
//         return null;
//     }
// }


import libra.common.helpers.PathHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
/*
 * Copyright 2016 iychoi.
 *
 * 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.
 */
package libra.common.sequence;


/**
 *
 * @author iychoi
 */
public class FastaPathFilter implements PathFilter {

    private static final String[] FASTA_EXT = {"fa", "ffn", "fna", "faa", "fasta", "fas", "fsa", "seq"};
    
    @Override
    public boolean accept(Path path) {
// Path: src/libra/common/helpers/PathHelper.java
// public class PathHelper {
//     
//     private static final String[] COMPRESSED_EXT = {"gz", "bz2"};
//     
//     public static String getParent(String path) {
//         // check root
//         if(path.equals("/")) {
//             return null;
//         }
//         
//         int lastIdx = path.lastIndexOf("/");
//         if(lastIdx > 0) {
//             return path.substring(0, lastIdx);
//         } else {
//             return "/";
//         }
//     }
//     
//     public static String concatPath(String path1, String path2) {
//         StringBuffer sb = new StringBuffer();
//         
//         if(path1 != null && !path1.isEmpty()) {
//             sb.append(path1);
//         }
//         
//         if(!path1.endsWith("/")) {
//             sb.append("/");
//         }
//         
//         if(path2 != null && !path2.isEmpty()) {
//             if(path2.startsWith("/")) {
//                 sb.append(path2.substring(1, path2.length()));
//             } else {
//                 sb.append(path2);
//             }
//         }
//         
//         return sb.toString();
//     }
//     
//     public static String getExtensionOfDecompressedFile(String name) {
//         String myname = name;
//         int idx = myname.lastIndexOf(".");
//         if(idx > 0) {
//             String ext = myname.substring(idx + 1);
//             for(String cext : COMPRESSED_EXT) {
//                 if(cext.equalsIgnoreCase(ext)) {
//                     // compressed
//                     myname = myname.substring(0, idx);
//                     break;
//                 }
//             }
//         } else {
//             return null;
//         }
//         
//         idx = myname.lastIndexOf(".");
//         if(idx > 0) {
//             return myname.substring(idx + 1);
//         }
//         return null;
//     }
// }


// Path: src/libra/common/sequence/FastaPathFilter.java
import libra.common.helpers.PathHelper;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;

/*
 * Copyright 2016 iychoi.
 *
 * 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.
 */
package libra.common.sequence;


/**
 *
 * @author iychoi
 */
public class FastaPathFilter implements PathFilter {

    private static final String[] FASTA_EXT = {"fa", "ffn", "fna", "faa", "fasta", "fas", "fsa", "seq"};
    
    @Override
    public boolean accept(Path path) {
        String ext = PathHelper.getExtensionOfDecompressedFile(path.getName());