Extract consensus sequences from a file in HML format.

@param inputHmlFile input HML file, if any
975361
static String getSubjectId(final File fastaFile){
    	String fileAsString = fastaFile.toString();
    	List<String> alleleParts = Splitter.on("_").splitToList(fileAsString);
    	List<String> pathParts  = Splitter.on("/").splitToList(alleleParts.get(0));
    	return pathParts.get(pathParts.size()-1);
    }
1348512
protected int interpretLs(LineParser lp, MessageMgr mm){
		String directory = lp.getArgs();
		IOFileFilter fileFilter = new WildcardFileFilter(new String[]{
					"*.ssc"
		});
		DirectoryLoader dl = new CommonsDirectoryWalker(directory, DirectoryFileFilter.INSTANCE, fileFilter);
		if(dl.getLoadErrors().hasErrors()){
			mm.report(dl.getLoadErrors());
			return 1;
		}
		FileSourceList fsl = dl.load();
		if(dl.getLoadErrors().hasErrors()){
			mm.report(dl.getLoadErrors());
			return 1;
		}
		for(FileSource fs : fsl.getSource()){
			//TODO need to adapt to new source return
			mm.report(MessageMgr.createInfoMessage("script file - dir <{}> file <{}>", directory, fs.getBaseFileName()));
		}
		return 0;
	}
1093962
def parse_file(self, inputstring, addhash=True):
        """"""
        if addhash:
            use_hash = self.genhash(False, inputstring)
        else:
            use_hash = None
        return self.parse(inputstring, self.file_parser, {"nl_at_eof_check": True}, {"header": "file", "use_hash": use_hash})
671554
def _get_input_args(bam_file, data, out_base, background):
    
    if dd.get_genome_build(data) in ["hg19"]:
        return ["--PileupFile", _create_pileup(bam_file, data, out_base, background)]
    else:
        return ["--BamFile", bam_file]
1149200
public static TopologyDef parseFile(String inputFile, boolean dumpYaml, boolean processIncludes,
                                        String propertiesFile, boolean envSub) throws IOException {
        Yaml yaml = yaml();
        FileInputStream in = new FileInputStream(inputFile);
        // TODO process properties, etc.
        TopologyDef topology = loadYaml(yaml, in, propertiesFile, envSub);
        in.close();
        if(dumpYaml){
            dumpYaml(topology, yaml);
        }
        if(processIncludes) {
            return processIncludes(yaml, topology, propertiesFile, envSub);
        } else {
            return topology;
        }
    }
456724
def seq(self):
        """"""

        if self.sequence_file:
            log.debug('{}: reading sequence from sequence file {}'.format(self.id, self.sequence_path))
            tmp_sr = SeqIO.read(self.sequence_path, 'fasta')
            return tmp_sr.seq

        elif self.metadata_file:
            log.debug('{}: reading sequence from metadata file {}'.format(self.id, self.metadata_path))
            tmp_sr = SeqIO.read(self.metadata_path, 'uniprot-xml')
            return tmp_sr.seq

        else:
            if not self._seq:
                log.debug('{}: no sequence stored in memory'.format(self.id))
            else:
                log.debug('{}: reading sequence from memory'.format(self.id))

            return self._seq
931632
def __read_seq_header(fh, prev_line):
  
  seq_header = ""
  if prev_line is not None and not _isSequenceHead(prev_line):
    raise FastaFileFormatError("terminated on non-read header: " + prev_line)
  if prev_line is None:
    while seq_header.strip() == "":
      seq_header = fh.readline()
  else:
    seq_header = prev_line
  return seq_header
954142
public static void decodeFileToFile(String infile, String outfile) throws IOException {
		byte[] decoded = Base64.decodeFromFile(infile);
		java.io.OutputStream out = null;
		try{
			out = new java.io.BufferedOutputStream(new FileOutputStream(outfile));
			out.write(decoded);
		} catch (IOException e) {
			throw e; // Catch and release to execute finally{}
		} finally {
			try {
				if (out != null) {
					out.close();
				}
			} catch (Exception ex) {
			}
		}
	}
244610
public static TopologyDef parseFile(String inputFile, boolean dumpYaml, boolean processIncludes,
    	String propertiesFile, boolean envSub) throws IOException {
   
        FileInputStream in = new FileInputStream(inputFile);
        TopologyDef topology = parseInputStream(in, dumpYaml, processIncludes, propertiesFile, envSub);
        in.close();
        
        return topology;
    }
279614
private void readResources(ResourceMap hmResourcesRules) throws ResourceInitializationException {
		Pattern paReadRules = Pattern.compile("RULENAME=\"(.*?)\",EXTRACTION=\"(.*?)\",NORM_VALUE=\"(.*?)\"(.*)");
		Pattern paVariable = Pattern.compile("%(re[a-zA-Z0-9]*)");
		
		// read normalization data
		InputStream is = null;
		InputStreamReader isr = null;
		BufferedReader br = null;
		try {
			for (String resource : hmResourcesRules.keySet()) {
				is = hmResourcesRules.getInputStream(resource);
				isr = new InputStreamReader(is, "UTF-8");
				br = new BufferedReader(isr);
				Logger.printDetail(component, "Adding rule resource: " + resource);
				for(String line; (line = br.readLine()) != null; ) {
					if(line.startsWith("//") || line.equals("")) {
						continue;
					}
					
					Logger.printDetail("DEBUGGING: reading rules..."+ line);
					// check each line for the name, extraction, and normalization part
					for (MatchResult r : Toolbox.findMatches(paReadRules, line)) {
						String rule_name          = r.group(1);
						String rule_extraction    = r.group(2);
						String rule_normalization = r.group(3);
						
						////////////////////////////////////////////////////////////////////
						// RULE EXTRACTION PARTS ARE TRANSLATED INTO REGULAR EXPRESSSIONS //
						////////////////////////////////////////////////////////////////////
						// create pattern for rule extraction part
						RePatternManager rpm = RePatternManager.getInstance(language, false);
						for (MatchResult mr : Toolbox.findMatches(paVariable,rule_extraction)) {
							Logger.printDetail("DEBUGGING: replacing patterns..."+ mr.group());
							if (!(rpm.containsKey(mr.group(1)))) {
								Logger.printError("Error creating rule:"+rule_name);
								Logger.printError("The following pattern used in this rule does not exist, does it? %"+mr.group(1));
								System.exit(-1);
							}
							rule_extraction = rule_extraction.replaceAll("%"+mr.group(1), rpm.get(mr.group(1)));
						}
						rule_extraction = rule_extraction.replaceAll(" ", "[\\\\s]+");
						Pattern pattern = null;
						try{
							pattern = Pattern.compile(rule_extraction);
						}
						catch (java.util.regex.PatternSyntaxException e) {
							Logger.printError("Compiling rules resulted in errors.");
							Logger.printError("Problematic rule is "+rule_name);
							Logger.printError("Cannot compile pattern: "+rule_extraction);
							e.printStackTrace();
							System.exit(-1);
						}
						
						/////////////////////////////////////////////////
						// READ INTERVAL RULES AND MAKE THEM AVAILABLE //
						/////////////////////////////////////////////////
						if(resource.equals("intervalrules")){
							hmIntervalPattern.put(pattern,rule_name);
							hmIntervalNormalization.put(rule_name, rule_normalization);
						}
					}
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
			throw new ResourceInitializationException();
		} finally {
			try {
				if(br != null) {
					br.close();
				}
				if(isr != null) {
					isr.close();
				}
				if(is != null) {
					is.close();
				}
			} catch(Exception e) {
				e.printStackTrace();
			}
		}
	}
338851
def time_from_hhmmssmmm(string, decimal_separator="."):
    
    if decimal_separator == ",":
        pattern = HHMMSS_MMM_PATTERN_COMMA
    else:
        pattern = HHMMSS_MMM_PATTERN
    v_length = TimeValue("0.000")
    try:
        match = pattern.search(string)
        if match is not None:
            v_h = int(match.group(1))
            v_m = int(match.group(2))
            v_s = int(match.group(3))
            v_f = TimeValue("0." + match.group(4))
            v_length = v_h * 3600 + v_m * 60 + v_s + v_f
    except:
        pass
    return v_length
602316
def extract_haml(fileobj, keywords, comment_tags, options):
    

    import haml
    from mako import lexer, parsetree
    from mako.ext.babelplugin import extract_nodes 

    encoding = options.get('input_encoding', options.get('encoding', None))
    template_node = lexer.Lexer(haml.preprocessor(fileobj.read()), input_encoding=encoding).parse()
    for extracted in extract_nodes(template_node.get_children(), keywords, comment_tags, options):
        yield extracted
695621
public static Hml read(final File file) throws IOException {
        checkNotNull(file);
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            return read(reader);
        }
    }
219294
def filter_input_sequences
      # Ensure the sequences are in plain text.
      begin
        ActiveSupport::Multibyte::Unicode.u_unpack(self.sequence)
      rescue Exception => e
        logger.error e.message
        errors.add(
          :sequence,
          "Please enter your sequence(s) in Plain Text as FASTA."
        )
        self.sequence = ""
        return
      end

      hash = create_hash(self.sequence)
      tmp  = File.join(::Rails.root.to_s, 'tmp')

      # Ensure the sequences are FASTA via #write_input_sequence_to_file.
      begin
        write_input_sequence_to_file(tmp, hash, self.sequence)
      rescue Exception => e
        errors.add(:sequence, e.message)
        return
      else
        fasta = File.read(File.join(tmp, hash + ".fa"))
      ensure
        File.delete(File.join(tmp, hash + ".fa"))
        File.delete(File.join(tmp, hash + ".seq"))
      end

      self.na_sequence = ""
      self.aa_sequence = ""

      # Split the sequences on >, check the type (AA or NA) and separate.
      seqs = fasta.split('>')
      seqs.delete_if { |s| s.empty? }
      seqs.each do |s|
        type = discover_input_sequence_type(s)
        if type == "nucleic_acid"
          self.na_sequence << ">" << s
        end
        if type == "amino_acid"
          self.aa_sequence << ">" << s
        end
      end

      self.na_sequence = nil if self.na_sequence.empty?
      self.aa_sequence = nil if self.aa_sequence.empty?
    end
767150
static SourceFile extractSourceMap(
      SourceFile jsFile, String sourceMapURL, boolean parseInlineSourceMaps) {
    // Javascript version of the compiler can only deal with inline sources.
    if (sourceMapURL.startsWith(BASE64_URL_PREFIX)) {
      byte[] data =
          BaseEncoding.base64().decode(sourceMapURL.substring(BASE64_URL_PREFIX.length()));
      String source = new String(data, StandardCharsets.UTF_8);
      return SourceFile.fromCode(jsFile.getName() + ".inline.map", source);
    }
    return null;
  }
61839
private IndexInput openMtasFile(SegmentReadState state, String name,
      String extension) throws IOException {
    return openMtasFile(state, name, extension, null, null);
  }
519147
public static <S extends Sequence<S>> Alignment<S> alignLocal(AlignmentScoring<S> alignmentScoring,
                                                                  S seq1, S seq2) {
        if (alignmentScoring instanceof AffineGapAlignmentScoring)
            return alignLocalAffine((AffineGapAlignmentScoring<S>) alignmentScoring, seq1, seq2);
        if (alignmentScoring instanceof LinearGapAlignmentScoring)
            return alignLocalLinear((LinearGapAlignmentScoring<S>) alignmentScoring, seq1, seq2);
        throw new RuntimeException("Unknown scoring type.");
    }